
Keras is a powerful and easy-to-use deep learning library for Theano and TensorFlow that provides a high-level neural networks API to develop and evaluate deep learning models.
1  | import numpy as np  | 
Your data needs to be stored as NumPy arrays or as a list of NumPy arrays. Ideally, you split the data in training and test sets, for which you can also resort to the train_test_split module of sklearn.cross_validation.
1  | from keras.datasets import boston_housing,  | 
1  | from urllib.request import urlopen  | 
1  | from keras.preprocessing import sequence  | 
1  | from keras.utils import to_categorical  | 
1  | from sklearn.model_selection import train_test_split  | 
1  | from sklearn.preprocessing import StandardScaler  | 
1  | from keras.models import Sequential  | 
Binary Classification
1  | from keras.layers import Dense  | 
Multi-Class Classification
1  | from keras.layers import Dropout  | 
Regression
1  | model.add(Dense(64,activation='relu',input_dim=train_data.shape[1]))  | 
1  | from keras.layers import Activation,Conv2D,MaxPooling2D,Flatten  | 
1  | from keras.klayers import Embedding,LSTM  | 
1  | # Model output shape  | 
MLP: Binary Classification
1  | model.compile(optimizer='adam',  | 
MLP: Multi-Class Classification
1  | model.compile(optimizer='rmsprop',  | 
MLP: Regression
1  | model.compile(optimizer='rmsprop', loss='mse', metrics=['mae'])  | 
Recurrent Neural Network
1  | model3.compile(loss='binary_crossentropy',  | 
1  | model3.fit(x_train4,  | 
1  | score = model3.evaluate(x_test,  | 
1  | model3.predict(x_test4, batch_size=32)  | 
1  | from keras.models import load_model  | 
1  | from keras.optimizers import RMSprop  | 
1  | from keras.callbacks import EarlyStopping  | 
Data-Science, Deep-Learning, Keras — Sep 21, 2019
Made with ❤️ and ☀️ on Earth.