sherjilozair / char-rnn-tensorflow

Multi-layer Recurrent Neural Networks (LSTM, RNN) for character-level language models in Python using Tensorflow
MIT License
2.64k stars 960 forks source link

Why we need ydata[-1] = xdata[0]? #26

Open hunkim opened 8 years ago

hunkim commented 8 years ago

In def create_batches(self) (util.py):

        ydata[:-1] = xdata[1:]
        ydata[-1] = xdata[0]

The first line is fair enough. However, why we need the second line? Say our data is "Hello", then

x = "hello" y="elloh"

So when h is given we expect e (h->e), e->l, etc. But why o->h (ydata[-1] = xdata[0])? Perhaps this hurts the training model.

Did I miss something here? Or you think this is only one char, so we ignore?