我是Pythorch的新手,我遇到了这个错误:
x.gather(1, c)
RuntimeError: Invalid index in gather at /pytorch/aten/src/TH/generic/THTensorEvenMoreMath.cpp:457
以下是关于张量的一些信息:
print(x.size())
print(c.size())
print(type(x))
print(type(c))
torch.Size([128, 2])
torch.Size([128, 1])
<class 'torch.Tensor'>
<class 'torch.Tensor'>
x是浮点值,c是整数,这是问题吗?在
这仅仅意味着索引张量
^{1}$c
有无效的索引。 例如,以下索引张量是有效的:但是,以下索引张量无效:
^{pr2}$它给出了你提到的例外情况
相关问题 更多 >
编程相关推荐