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

Training scheme of the pretrained imagenet models? #1986

Closed
tzm1003306213 opened this issue Mar 15, 2020 · 8 comments
Closed

Training scheme of the pretrained imagenet models? #1986

tzm1003306213 opened this issue Mar 15, 2020 · 8 comments

Comments

@tzm1003306213
Copy link

Hi,

Are the pretrained models reported by torchvision using the same hyper-parameters as https://github.com/pytorch/examples/blob/master/imagenet/main.py? I used the default hyper-parameters to train mobilenet_v2, but the results were much worse than reported.

Thanks

@pmeier
Copy link
Collaborator

pmeier commented Mar 17, 2020

You can find the training scripts for all torchvision models here. For classification this is the script you want

https://github.com/pytorch/vision/blob/master/references/classification/train.py

@fmassa
Copy link
Member

fmassa commented Mar 17, 2020

As @pmeier mentioned, we also provide the default hyperparameters for the pre-trained models in torchvision under the references folder.
For mobilenet_v2 we used https://github.com/pytorch/vision/tree/master/references/classification#mobilenetv2

python -m torch.distributed.launch --nproc_per_node=8 --use_env train.py\
     --model mobilenet_v2 --epochs 300 --lr 0.045 --wd 0.00004\
     --lr-step-size 1 --lr-gamma 0.98

Let us know if you have further questions

@magamba
Copy link

magamba commented Mar 19, 2020

Hello,

I have a similar issue. I am using pretrained AlexNet and VGG models from torchvision for a scientific paper and, in order to interpret my results, I would like to know how the models were trained. I have checked here as suggested, but I am unable to find any reference to VGG19, its shallower variants, and AlexNet. Are they published anywhere else?

Thank you

@pmeier
Copy link
Collaborator

pmeier commented Mar 19, 2020

I expect these models were trained with the default parameters given in train.py, but I can't be sure. @fmassa ?

@fmassa
Copy link
Member

fmassa commented Mar 19, 2020

AlexNet and VGG have been trained a long time ago by @colesbury , I think they might follow the same procedure as ResNet (and thus default parameters), but I'm not 100% sure. Original PR adding those is inn #23

@colesbury
Copy link
Member

Models with batch normalization were trained with the default parameters. Models without batch normalization were trained with an initial learning rate of 0.01 (i.e. 1/10th the default learning rate).

See https://github.com/pytorch/examples/tree/master/imagenet#training

@pmeier
Copy link
Collaborator

pmeier commented Mar 19, 2020

Should we add this in the classification reference README? If yes, I could send a PR tomorrow.

@fmassa
Copy link
Member

fmassa commented Mar 19, 2020

@pmeier yes please, if you could send a PR improving the README it would be great

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

No branches or pull requests

5 participants