解决ValueError: Expected more than 1 value per channel when training, got input size [1, 256, 1, 1]

出现 ValueError: Expected more than 1 value per channel when training, got input size [1, 256, 1, 1] 问题,

可能是输入批次只有一个数据点,而由于BatchNorm操作需要多于一个数据计算平均值,因此造成该错误。

解决方法:

在获取数据集时,将DataLoader中drop_last设置为True。

把不够一个批次的数据丢弃。

猜你喜欢

转载自blog.csdn.net/sinat_39307513/article/details/87917537