How to do it...

Instead of relisting all the same code, we will illustrate where our code in this section will differ from the previous section. For the full code, please see the GitHub repository at https://github.com/nfmcclure/tensorflow_cookbook or the Packt repository at https://github.com/PacktPublishing/TensorFlow-Machine-Learning-Cookbook-Second-Edition.

  1. We first need to set the number of layers for the model. We put this as a parameter at the beginning of our script, with the other model parameters:
num_layers = 3 
min_word_freq = 5
rnn_size = 128 
epochs = 10 
  1. The first major change is that we will load, process, and feed the text by characters, not by words. In order to accomplish this, after cleaning the text, we can separate ...

Get TensorFlow Machine Learning Cookbook - Second Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.