1500字范文,内容丰富有趣,写作好帮手!
1500字范文 > Expected more than 1 value per channel when training got input size torch.Size

Expected more than 1 value per channel when training got input size torch.Size

时间:2018-10-18 05:13:26

相关推荐

Expected more than 1 value per channel when training  got input size torch.Size

Expected more than 1 value per channel when training, got input size torch.Size

训练的时候,batch size必须大于1

但是预测的时候,batch size可以等于1

解决方法:

1. 加大batch_size

2.网络设置eval模式:

model=MyModel()model.eval()

2.网上查找的原因为模型中用了batchnomolization,训练中用batch训练的时候当前batch恰好只含一个sample,而由于BatchNorm操作需要多于一个数据计算平均值,因此造成该错误。

本内容不代表本网观点和政治立场,如有侵犯你的权益请联系我们处理。
网友评论
网友评论仅供其表达个人看法,并不表明网站立场。