The question is about batchnorm

I use batchnorm2d to run net,and batch_size=10.
But When I test the net performance , I set batch_size=1,the result very bad.I know the reason is batchnorm2d, and What should I do about batchnorm2d when I train and test net?

Have you set your model to eval mode with: model.eval()?

Yes I set model.cuda().eval()

Is this .eval() will shutdown batchnorm2d?

This will make sure to use the running stats on your test samples instead of calculating them from the current batch.

You might play a bit with the momentum, which might help, if your batch stats are quite different.

BatchNorm layers usually work good with a batch size of > 64 so you might try group normalization.

Thank you for you help