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 | 64,activation='relu',input_dim=train_data.shape[1])) model.add(Dense( |
1 | from keras.layers import Activation,Conv2D,MaxPooling2D,Flatten |
1 | from keras.klayers import Embedding,LSTM |
1 | # Model output shape |
MLP: Binary Classification
1 | 'adam', model.compile(optimizer= |
MLP: Multi-Class Classification
1 | 'rmsprop', model.compile(optimizer= |
MLP: Regression
1 | 'rmsprop', loss='mse', metrics=['mae']) model.compile(optimizer= |
Recurrent Neural Network
1 | 'binary_crossentropy', model3.compile(loss= |
1 | model3.fit(x_train4, |
1 | score = model3.evaluate(x_test, |
1 | 32) model3.predict(x_test4, batch_size= |
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.