错误点:
data, target = data.to(self.device), target.to(self.device)
AttributeError: 'list' object has no attribute 'to'
测试显示:print("6666666666666666666 ",target)
解决方案:将列表元素取出(即list类型转换成tensor类型,将[tensor[....], ...]
的数据改为tensor[....], ...
)在错误点前输入:target=torch.stack(target, dim=1)
target=torch.stack(target, dim=1)
data, target = data.to(self.device), target.to(self.device)
结果显示:通过