整理一下我自己-一名深度学习小白,在跑代码的过程中遇到的一些小问题
1、报错:RuntimeError: Expected all tensors to be on the same device, but found at least two devices, cuda:0 and cpu! (when checking argument for argument target in method wrapper__nll_loss2d_forward)
可能的原因是:在将数据抛到GPU上时忘记用等号赋值回去了,例如把data=data.to(device)
写成了data.to(device)
2、报错:RuntimeError: only batches of spatial targets supported (3D tensors) but got targets of size: : [4]
解决方法:原理看原文,具体解决办法看评论区
……持续更新中