Closed arixlin closed 6 years ago
make sure the labels` data type is torch.cuda.LongTensor i saw your log that something wrong in the labels' datatype (torch.cuda.IntTensor)
File "D:/github/torch_light/Image-Cap/train.py", line 235, in
target, _ = actor(hidden, labels)
@ne7ermore
hi, I don't modify Image-Cap/train.py, i saw return labels is int list.
thx!
what did you get from the data_loader. Data_loader try to get the labels` datatype form this line below i show
https://github.com/ne7ermore/torch_light/blob/master/Image-Cap/data_loader.py#L41
or you can try this simple test code: https://github.com/ne7ermore/torch_light/blob/master/Image-Cap/data_loader.py#L58
img, labels = next(training_data) from https://github.com/ne7ermore/torch_light/blob/master/Image-Cap/data_loader.py#L66
print(labels)
@ne7ermore Hi, when I run Image-Cap/data_loader.py, labels is [torch.cuda.IntTensor of size 2x16 (GPU 0)], Image-Cap/train.py#115 labels is [torch.cuda.IntTensor of size 32x17 (GPU 0)] thx!
I guess sth change between pytorch`s versions my version is 0.3.1 and i have added long() function to change the datatype of labels
https://github.com/ne7ermore/torch_light/blob/master/Image-Cap/data_loader.py#L46
please try again :)
if found error again, show the pytorch's version which you used
@ne7ermore Thank you so much, it works out! train.py has been running!
When I run train.py, show type error:
Traceback (most recent call last): File "D:/github/torch_light/Image-Cap/train.py", line 235, in
loss = pre_train_actor()
File "D:/github/torch_light/Image-Cap/train.py", line 120, in pre_trainactor
target, = actor(hidden, labels)
File "D:\Anaconda3\envs\python36\lib\site-packages\torch\nn\modules\module.py", line 357, in call
result = self.forward(*input, *kwargs)
File "D:\github\torch_light\Image-Cap\model.py", line 91, in forward
emb_enc = self.lookup_table(labels[:, i])
File "D:\Anaconda3\envs\python36\lib\site-packages\torch\nn\modules\module.py", line 357, in call
result = self.forward(input, **kwargs)
File "D:\Anaconda3\envs\python36\lib\site-packages\torch\nn\modules\sparse.py", line 103, in forward
self.scale_grad_by_freq, self.sparse
File "D:\Anaconda3\envs\python36\lib\site-packages\torch\nn_functions\thnn\sparse.py", line 57, in forward
output = torch.index_select(weight, 0, indices)
TypeError: torch.index_select received an invalid combination of arguments - got (torch.cuda.FloatTensor, int, !torch.cuda.IntTensor!), but expected (torch.cuda.FloatTensor source, int dim, torch.cuda.LongTensor index)