Discussions>PyTorch - Error: Expected more than 1 value per channel when training>

PyTorch - Error: Expected more than 1 value per channel when training

The training process gives a weird error at the end of the epoch. I designed a network for segmentation and get this weird error at the end of the epoch

Error: Expected more than 1 value per channel when training, but got input size [1, 16, 1, 1]

What's wrong with this? I'm using
Ubuntu 18.04
Python 3.6
PyTorch 1.6

3 votesJO266.00
1 Answers
JW297.00
2

It looks like you pass just 1 example during training. I'm guessing you've got a Batch Normalization layer in your network and it requires more than 1 example in training mode (cause it calculates moving_mean and moving_variance during training). 
Either you have to pass more than 1 example during training mode, or you have to change the mode into eval with model.eval() function.

Reply
Couldn't find what you were looking for?and we will find an expert to answer.
How helpful was this page?