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

当batch里只有一个样本时,再调用batch_norm就会报下面这个错误:

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

在训练前用 num_of_samples % batch_size 计算一下合适的大小

posted @ 2020-10-03 20:27  Xycdada  阅读(1707)  评论(0编辑  收藏  举报