[[+content_image]]
N
N
notxleb2018-09-30 00:36:51
Python
notxleb, 2018-09-30 00:36:51

How to train neural networks with LSTM in keras?

I want to predict the next word from the previous one. I have data like "[[0,1],[1,2],[3,4] ... ]". Let's say I want to train through train_on_batch(). In what form (shape) should I submit training data?

Answer the question

In order to leave comments, you need to log in

[[+comments_count]] answer(s)
I
ivodopyanov, 2018-10-02
@ivodopyanov

https://keras.io/layers/recurrent/
Input shape
3D tensor with shape (batch_size, timesteps, input_dim).
<number of examples in one batch, length of sequence, dimension of one element>
LSTM assumes that each element of a sequence is a vector. In the case when in the basic version they are some numbers (for example, the id of a word in a dictionary), then it is distilled into one-hot encoding or through an embedding layer.
If the length of the sequence is different from the example, then it is usually completed with zeros so that it is the same for everyone in the batch.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question