Before I upgraded to the latest pytorch, this command worked for me:
ss = pp.gather(1, labels)
where pp
is:
Variable containing:
0.0651 0.9349
0.6208 0.3792
0.3024 0.6976
0.2226 0.7774
0.0394 0.9606
0.4197 0.5803
0.1205 0.8795
0.3774 0.6226
0.1682 0.8318
0.2281 0.7719
0.3845 0.6155
0.4658 0.5342
0.4982 0.5018
0.2653 0.7347
0.2694 0.7306
0.6550 0.3450
[torch.cuda.FloatTensor of size 16x2 (GPU 0)]
and where labels
Variable containing:
1
1
1
1
1
1
1
1
0
0
0
0
0
0
0
0
[torch.cuda.LongTensor of size 16 (GPU 0)]
However after I upgraded to the latest version off of master, this same line gives me the following error:
*** RuntimeError: Input tensor must have same dimensions as output tensor at /data/pytorch/torch/lib/THC/generic/THCTensorScatterGather.cu:16
I’m not sure how/why this error occurs now, and in fact it does not even make sense to me, I do not see why/what sizes need to be the same here.
Thanks