train error
as3896001 opened this issue · 6 comments
I used the training instructions you provided, but there are some problems, I don’t know how to solve them
File "codes/run.py", line 361, in
main(parse_args())
File "codes/run.py", line 305, in main
log = kge_model.train_step(kge_model, optimizer, train_iterator, args)
File "codes\model.py", line 267, in train_step
negative_score = model((positive_sample, negative_sample), mode=mode)
File "C:\Users\Kano_Hayashi.conda\envs\rota\lib\site-packages\torch\nn\modules\module.py", line 550, in _call
_
result = self.forward(*input, **kwargs)
File "codes\model.py", line 144, in forward
index=tail_part.view(-1)
RuntimeError: Expected object of scalar type Long but got scalar type Int for argument #3 'index' in call to _th_index_select
Hi, Yi-Rong, what's your PyTorch version?
My PyTorch version is 1.15.0,Is it too new?
I made its version into 1.3.0 and 1.0.2, but the problem still there
RuntimeError: Expected object of scalar type Long but got scalar type Int for argument #3 'index'
@as3897001, I have the same issue, this is not the version problem, the place which occurs error is in model.py:
tail = torch.index_select(
self.entity_embedding,
dim=0,
index=tail_part.view(-1)
).view(batch_size, negative_sample_size, -1)
Solution:
You just modify "negative_sample = torch.from_numpy(negative_sample) " [this is in dataloader.py] to "negative_sample = torch.LongTensor(negative_sample)"
Hi @ToneLi ,
Thanks for the correction. The code is updated.
Hi @as3896001 , does this solve your problem?
Thank you,I'll give it a try.