Index out of range
Hi, I've just cloned this nice repo but I'm having issues in running the movielens noteboot out-of-the-box.
When I try to run the training code I get the error below, can you help me in finding the reason and fix it? I suspect it has something to do with embeddings size. Many thanks!
`RuntimeError Traceback (most recent call last)
~\AppData\Local\Continuum\anaconda3\lib\site-packages\torch\nn\modules\module.py in call(self, *input, **kwargs) 491 result = self._slow_forward(*input, **kwargs) 492 else: --> 493 result = self.forward(*input, **kwargs) 494 for hook in self._forward_hooks.values(): 495 hook_result = hook(self, input, result)
~\AppData\Local\Continuum\anaconda3\lib\site-packages\torch\nn\modules\module.py in call(self, *input, **kwargs) 491 result = self._slow_forward(*input, **kwargs) 492 else: --> 493 result = self.forward(*input, **kwargs) 494 for hook in self._forward_hooks.values(): 495 hook_result = hook(self, input, result)
~\AppData\Local\Continuum\anaconda3\lib\site-packages\torch\nn\modules\sparse.py in forward(self, input) 115 return F.embedding( 116 input, self.weight, self.padding_idx, self.max_norm, --> 117 self.norm_type, self.scale_grad_by_freq, self.sparse) 118 119 def extra_repr(self):
~\AppData\Local\Continuum\anaconda3\lib\site-packages\torch\nn\functional.py in embedding(input, weight, padding_idx, max_norm, norm_type, scale_grad_by_freq, sparse) 1504 # remove once script supports set_grad_enabled 1505 no_grad_embedding_renorm(weight, input, max_norm, norm_type) -> 1506 return torch.embedding(weight, input, padding_idx, scale_grad_by_freq, sparse) 1507 1508
RuntimeError: index out of range at ..\aten\src\TH/generic/THTensorEvenMoreMath.cpp:193 `
I found this code today and ran into the same issue.
If you change the indexing in "In [37]" outputs = net(x_batch[:, 1], x_batch[:, 0], minmax) into outputs = net(x_batch[:, 0], x_batch[:, 1], minmax)
, it works fine. Hope it helps.