【Debug】Pytorch Debug 全记录

Expected more than 1 value

Value error: Expected more than 1 value per channel when training, got input size torch.Size([1, 512])

原因:

模型中用了batchnomolization,训练中用batch训练的时候,应该是有单数,比如dataset的总样本数为17,你的batch_size为8,就会报这样的错误

Expected scalar type but

RuntimeError: Expected object of scalar type Byte but got scalar type Float for argument #2 'mat2'

多半是forward中输入类型错误,把forward输入转换类型为dtype = torch.uint8

如果是long, 就转换为 torch.int64

如果是 X, 就转换为torch.x

转换的几种方式:

tensor1.type_as(tensor2)

torch.Tensor(tensor1,dtype=uint8)

Pytorch 的12个坑

https://zhuanlan.zhihu.com/p/91485607

©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。