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])
每天制造一些小bug=.=
最新推荐文章于 2025-12-30 10:28:09 发布
本文探讨了如何处理输出分类错误(target2outofbounds)问题,涉及不同标签集的处理,并提供了在将模型迁移到GPU时遇到'hasnoattribute 'to''错误的解决方案,强调了集成torch.nn.Module和数据类型转换的最佳实践。
889

被折叠的 条评论
为什么被折叠?



