1、target 2 out of bounds
是因为输出分类错了,因为不同数据集的标签分类可能有的是二有的是三。
2、在迁移模型到GPU时,提示模型has no attribute ‘to’
出错地方:模型忘记集成torch.nn.Module了
迁移数据记得转化成tensor
转化方式:tensor_a=torch.tensor(np.array(a))
这里把list转换成tensor有时候会报错,用这个语句就好了:
a=torch.LongTensor([item.cpu().detach().numpy for item in a])