CIA-Oceanix / TrAISformer

Pytorch implementation of TrAISformer---A generative transformer for AIS trajectory prediction (https://arxiv.org/abs/2109.03958).
Other
108 stars 37 forks source link

Last element dropped from mask #8

Open isaacOnline opened 2 years ago

isaacOnline commented 2 years ago

@dnguyengithub

Why is the last element being dropped from the mask? I believe the mask only has as many 1s as there are non-padded values in the sequence, so if the sequence is (in 1D, for the example) [1, 2, 3, PADDING], the mask will be [1, 1, 1, 0]. This would make inputs [1, 2, 3] and targets [2, 3, PADDING]. Since the last element of the mask is being dropped, the mask becomes [1, 1, 1], and so the prediction going from 3 -> PADDING gets counted toward the loss. Is this a feature of transformers or am I missing something?