ValueError: could not determine the shape of object type ‘Series’.

Could not determine the shape of object type ‘Series’.

在这个语句中,出现了这样的错误:

torch.LongTensor(Y_test)
'''
ValueError: could not determine the shape of object type 'Series'
'''

这是由于我们要转化的对象索引并不是从零开始的,这就导致了Tensor不能确定他的大小。

该问题一般出现在分割后的数据集中,处理方法也比较简单,只需要将数据先转成Series就行:

torch.LongTensor(Y_test.to_numpy())

猜你喜欢

转载自blog.csdn.net/qq_45957458/article/details/128116955