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 计算一下合适的大小

原文地址:https://www.cnblogs.com/Xycdada/p/13765379.html