Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

small batch_size causes bad result #1

Open
piaozhx opened this issue Apr 29, 2019 · 2 comments
Open

small batch_size causes bad result #1

piaozhx opened this issue Apr 29, 2019 · 2 comments

Comments

@piaozhx
Copy link

piaozhx commented Apr 29, 2019

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

@ly015
Copy link
Owner

ly015 commented Apr 30, 2019

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.

@piaozhx
Copy link
Author

piaozhx commented May 4, 2019

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants