RuntimeError: can't assign a str to a scalar value of type int
Damonhaus opened this issue · comments
The code was written in python 3.5 and I suspect the problem comes from the differences in string handling between python 2.7 and 3.5
@Damonhaus To use in Python 2, change the batchify function for this:
def batchify(data, bsz):
ids = torch.LongTensor([ord(char) for char in data.encode()])
nbatch = ids.size(0) // bsz
ids = ids.narrow(0, 0, nbatch * bsz)
ids = ids.view(bsz, -1).t().contiguous()
return ids