asmekal / keras-monotonic-attention

seq2seq attention in keras
GNU Affero General Public License v3.0
40 stars 7 forks source link

Question about input data format #4

Closed xun468 closed 5 years ago

xun468 commented 6 years ago

While trying to implement a version of your code I noticed that your y outputs seem to be the desired sequence but transposed. If that is correct could you explain why? I am curious since I have not seen that before while looking up seq2seq stuff.

asmekal commented 6 years ago

Are you asking why true labels are made that way?

x = np.random.randint(0, n_labels, size=(n, t))
y = np.expand_dims(x, axis=-1)

The only reason why I could not instead just set y=x is that sparse_categorical_crossentropy expects labels_true shape (batch, time, 1) and not (batch, time)