Chapter2 Limitations of RNN
Chapter2 Limitations of RNN
Chapter2 Limitations of RNN
recurrent neural
networks
N AT U R A L L A N G U A G E G E N E R AT I O N I N P Y T H O N
Biswanath Halder
Data Scientist
Simple neural networks
Nodes arranged in layers.
Biswanath Halder
Data Scientist
Long-term dependencies
Short-term dependency: "The birds are ying in the sky".
vocabulary = sorted(list(set(text)))
Input : "I may contrive our father; and, in their defeated quee"
Output: "n"
model = Sequential()
model.add(Dense(len(vocabulary), activation='softmax'))
model.compile(loss='categorical_crossentropy', optimizer='adam')
model.summary()
Biswanath Halder
Data Scientist
Training and validation
Training: error reduction on the training set.
Encoded sentence.
next_index = np.argmax(prob_next_char)
next_char = idx_to_char[next_index]
# Append the new character to the next input and generated text
sentence = sentence[1:] + next_char
generated += next_char