I am following this tutorial: http://nlp.seas.harvard.edu/2018/04/03/attention.html to implement the Transformer model from the "Attention Is All You Need" paper.
However I am getting the following error : RuntimeError: "exp" not implemented for 'torch.LongTensor'
This is the line, in the PositionalEnconding class, that is causing the error:
div_term = torch.exp(torch.arange(0, d_model, 2) * -(math.log(10000.0) / d_model))
When it is being constructed here:
pe = PositionalEncoding(20, 0)
Any ideas?? I've already tried converting this to perhaps a Tensor Float type, but this has not worked.
I've even downloaded the whole notebook with accompanying files and the error seems to persist in the original tutorial.
Any ideas what may be causing this error?
Thanks!
float()
on some of the tensors and converting them toFloatTensor
s. But now I'm getting this error:Floating point exception: 8
and python quits. I was wondering if you had the same problem. If you didn't what did you do to fix those other problems with the float type? – Gyratory