I'm implementing a LSTM
model with Keras. My dataset is composed by words and each word is an 837 long vector. I grouped the words in groups of 20 and to do this I padded them: initially I had groups of words of variable length and the maximum group length that I found was 20, this is why I padded all groups to 20.
For example, a group of 5 words is:
[[x1,x2....x837],
[x1,x2....x837],
[x1,x2....x837],
[x1,x2....x837],
[x1,x2....x837]]
where xi
is the i-th feature of the vector.
To pad this group to a length of 20, I added 15 vectors composed by 837 feature with value equal to zeros:
[[0.......0],
............
............
[0........0]]
So, at the end, my group is of the form:
[[x1,x2....x837],
[x1,x2....x837],
[x1,x2....x837],
[x1,x2....x837],
[x1,x2....x837],
[0...........0],
..............
..............
[0...........0]]
How could I ignore the vectors of zeros during training?