Training with Keras
In this exercise, we return to our sign language letter classification problem. We have 2000 images of four letters--A, B, C, and D--and we want to classify them with a high level of accuracy. We will complete all parts of the problem, including the model definition, compilation, and training.
Note that keras
has been imported from tensorflow
for you. Additionally, the features are available as sign_language_features
and the targets are available as sign_language_labels
.
This exercise is part of the course
Introduction to TensorFlow in Python
Exercise instructions
- Define a sequential model named
model
. - Set the output layer to be dense, have 4 nodes, and use a
softmax
activation function. - Compile the model with the
SGD
optimizer andcategorical_crossentropy
loss. - Complete the fitting operation and set the number of epochs to 5.
Hands-on interactive exercise
Have a go at this exercise by completing this sample code.
# Define a sequential model
____
# Define a hidden layer
model.add(keras.layers.Dense(16, activation='relu', input_shape=(784,)))
# Define the output layer
____
# Compile the model
model.compile('____', loss='____')
# Complete the fitting operation
model.fit(____, ____, epochs=____)