maxjcohen / transformer

Implementation of Transformer model (originally from Attention is All You Need) applied to Time Series.
https://timeseriestransformer.readthedocs.io/en/latest/
GNU General Public License v3.0
842 stars 165 forks source link

RuntimeError: Sizes of tensors must match except in dimension 1. Got 249 and 250 (The offending index is 0) #33

Closed shamoons closed 3 years ago

shamoons commented 3 years ago

I have:

reconstruct_spect_model = Transformer(d_input=128, d_output=128, d_model=1024 N=2, q=8, v=8, h=4).to(DEVICE)
pred = reconstruct_spect_model(x)

where x has size of (4, 499, 128). 4 items in the batch, 499 is the sequence length and 128 features.

However, I get the error:

  File "/home/shamoon/.local/share/virtualenvs/speech-reconstruction-7HMT9fTW/lib/python3.8/site-packages/tst/multiHeadAttention.py", line 206, in forward
    queries = torch.cat(torch.cat(self._W_q(query).chunk(self._h, dim=-1), dim=0).chunk(n_chunk, dim=1), dim=0)
RuntimeError: Sizes of tensors must match except in dimension 1. Got 249 and 250 (The offending index is 0)
maxjcohen commented 3 years ago

Hi, please see #15