intrinsic_flow icon indicating copy to clipboard operation
intrinsic_flow copied to clipboard

small batch_size causes bad result

Open piaozhx opened this issue 5 years ago • 2 comments

when I run the test scripts with batch_size=8:

python scripts/test_pose_transfer_model.py --gpu_ids 0 --id PoseTransfer_0.5 --batch_size 8 --n_vis 8 --which_epoch best --save_output

the results look well: test_epochbest_bs8

but if I change batch_size to 1:

python scripts/test_pose_transfer_model.py --gpu_ids 0 --id PoseTransfer_0.5 --batch_size 1 --n_vis 8 --which_epoch best --save_output

the results are different and worse than batch_size=8 test_epochbest_bs1

piaozhx avatar Apr 29 '19 12:04 piaozhx

This is probably caused by the BN layer in the model. BN layers will track running statistics (mean and variance) in testing, so using a different batch_size from training setting (especially small batch_size like 1) will change the statistics of a minibatch, and lead to worse performance.

ly015 avatar Apr 30 '19 03:04 ly015

To figure out this problem, a usual method is fixing the parameters of BN layers in evaluation phase:

model = model.eval()

I test the results but they are not good as before: test_epochbest_bs8_eval

piaozhx avatar May 04 '19 14:05 piaozhx