Python Deep Learning - Second Edition
by Ivan Vasilev, Daniel Slater, Gianmario Spacagna, Peter Roelants, Valentino Zocca
Sampling
Once the model has been trained, we can generate new text by sampling the sequences. We can initialize our sampling architecture with the same code we used to train the model, but we'll need to set batch_size to 1 and sequence_length to None. In this way, we can generate a single string and sample sequences of different lengths. Then, we can initialize the parameters of the model with the parameters that were saved after the training. To start with the sampling, we'll feed the model an initial string (prime_string) to prime the state of the network. After that, we can sample the next character based on the output distribution of the softmax. Then, we can feed the newly sampled character as a new network input and get the output distribution ...