Applying the deep learning model with Keras
At this point, we are ready to apply Keras to our data.
Getting ready
We will be using the following from Keras:
from keras.models import Sequential
from keras.layers import Dense, Activation
How to do it...
This section walks through the following steps to apply a deep learning model, using Keras on our dataset:
- Import the following libraries to build a
Sequential
model fromkeras
, using the following script:
from keras.models import Sequential from keras.layers import Dense, Activation
- Configure the
Sequential
model fromkeras
, using the following script:
model = Sequential() model.add(Dense(32, activation='relu', input_dim=xtrain_array.shape[1])) model.add(Dense(10, activation='relu')) model.add(Dense(ytrain_OHE.shape[1], activation='softmax')) model.compile(optimizer='adam', loss='categorical_crossentropy', metrics=['accuracy'])
- We
fit
and train the model and store the results to a variable calledaccuracy_history
, using the following script:
accuracy_history...