我想做一个标签火炬张量。我选择了两种不同的方法,第一种方法在使用^{
第一种方法:
labels = torch.hstack((torch.zeros(100),torch.ones(100),1+torch.ones(100)))
第二种方法:
labels_np = np.vstack((np.zeros((100,1)),np.ones((100,1)),1+np.ones((100,1))))
labels = torch.squeeze(torch.tensor(labels_np).long())
错误:
expected scalar type Long but found Float in Pytoch
要修复第一个方法,应通过调用
labels = labels.long()
转换数据类型来更改类型:相关问题 更多 >
编程相关推荐