Hello 老师!



 NLPnewcomer:

`When I try to rebuild a Transformer model based on HarvardNLP paper ’ The Annotated Transformer’ and try to train that model, I got a problem ‘RuntimeError: Expected tensor for argument #1 ‘indices’ to have scalar type Long; but got torch.IntTensor instead (while checking arguments for embedding)’.
But in the paper’s Colab, that problem did not occur.


Without seeing the code, I don’t know the specifics.
But, yes, there are pytorch functions that expect LongTensors,
and won’t convert their inputs for you, so you have to convert
them yourself.  Depending on the specific situation, this might
be as simple as:
funcRequiringLongTensor (myIntTensor.to (torch.long))

Best.
K. Frank