October 2018
Intermediate to advanced
472 pages
10h 57m
English
This deep model is a network that's made up of one hidden LSTM layer with 128 memory units, followed by a Dense classifier layer with a softmax activation function over all possible characters. Targets are one-hot encoded, and this means that we'll train the model using categorical_crossentropy as the loss function.
The following code block defines the model's architecture:
model = keras.models.Sequential()model.add(layers.LSTM(128, input_shape=(maxlen, len(chars))))model.add(layers.Dense(len(chars), activation='softmax')) optimizer = keras.optimizers.RMSprop(lr=0.01)model.compile(loss='categorical_crossentropy', optimizer=optimizer)
The following diagram helps us visualize the model's architecture: ...
Read now
Unlock full access