Defining The LSTM Model For Text Generation

This deep learning model is a network 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 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)

This figure helps us visualize the model architecture:

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.144.97.216