Icon

01_​Training_​LSTM_​Solution

Train a LSTM model to perform text generation.

- Define a suitable network structure
- Train the model using the preprocessed data
- Save the trained model

URL: Guide to Intelligent Data Science https://www.datascienceguide.org/

Pre-processing and Encoding

Define a network structure for a many-to-one architecture


- Keras Input Layer node


Tips:
- The input shape should be ?, dictionary size
- Check the dictionary table to get the dictionary size
- Keras LSTM Layer node


Tip: Change the number of units to 512


- Keras Dropout Layer node
- Keras Dense Layer node


Tip: Use the activation softmax and the dictionary size as the number of units

Train the network and save it as a TensorFlow model

- Train the network using the Keras Network Learner node


Tips:
- Use for the input and the target data the conversion:
From Collection of Number (integer) to One-hot Tensor
- Use Categorical-Cross Entropy as loss function
- The trained model in the data folder was trained on half of the book for 50 epochs. This took two days. You can stop the training earlier by clicking the Stop learning button in the Monitor View and move on. In the deployment workflow you can use the pretrained network.
- Convert the network using the Keras to TensorFlow Network Converter node
- Save the model uisng the TensorFlow Network Writer node


Tip: Don't overwrite the trained model

- Optional: Save the model as Keras model (.h5 file) using the Keras Network Writer node

one column,each char in single row
Reshape Text & Create Dictionary
for regularization
Keras Dropout Layer
Keras to TensorFlow Network Converter
Create overlappingsequences
Lag Column
?, dictionary size
Keras Input Layer
Keras Network Writer
Keras Network Learner
output: sequence of hidden states
Keras LSTM Layer
Resort Columns
TensorFlow Network Writer
1 to 100
Row Filter
dictionary size
Keras Dense Layer
Othello
CSV Reader
Apply dictionary
Value Lookup

Nodes

Extensions

Links