Table of Contents

Text generation with LSTM

A long time ago I remember I first tried an LSTM implementation in Torch, trying to generate text based on some large text corpus from shakespear (see reference below). The result that could be achieved at that time were already quite surprising. But now I want to give this concept another try. Except that this time, it should be implemented in Tensorflow instead of torch. SO let's get started!

References

Initial implementation

<sxh python>

from tensorflow.python.keras import backend as K

def loss(labels, logits):

  return K.sparse_categorical_crossentropy(labels, logits, from_logits=True)
</sxh>

First results

⇒ Not too bad for a training phase of less than 1 hour! (60 epochs, 1024 GRU units in a single hidden layer)