A line of code: Hx.scatter(1, indices, kmatrix) in my project threw the error: “RuntimeError: invalid argument 3: Index tensor must have the same size as input tensor”. The error is invoked only on GPU, but not CPU. This is weird, especially it seems to relate to the variable size, which should not differ on different devices.
RuntimeError: invalid argument 3: Index tensor must have same dimensions as output tensor at c:\programdata\miniconda3\conda-bld\pytorch_1533096106539\work\aten\src\thc\generic/THCTensorScatterGather.cu:295
So this is not the same error as this one?
Anyway, most certainly a problem where you have too many dimensions? indices should be of size batch, not batch x 1.
Ah yes the error is the same (at least the same kind). Right now “indices” has shape [32x112x112]. It doesn’t change the error even if I remove the “indices.unsqueeze(1)” and instead just use indices instead. Changing the index dimension from 1 to 0 doesn’t help either.
Yes,
But the to_onehot function that you send call scatter on a 2D tensor that it creates and add one dimension to indices before giving it to scatter. So the original indices tensor given to to_onehot should be 1D.
Ah I see. Thanks! I will try to do something else then. This is part of the official pytorch Ignite library btw - that’s why I was quite sure it should have been working.
I got it working now - guess I ultimately was just confused by the documentation. The output measured should be a 1xN tensor for it to work. Thanks for your help!