# Training ImageNet- VGG16

**URL:** <https://discuss.pytorch.org/t/training-imagenet-vgg16/11543>\
**Category:** vision\
**Created:** [December 25, 2017, 2:50pm UTC](https://discuss.pytorch.org/t/training-imagenet-vgg16/11543 "2017-12-25T14:50:21Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![abhyantrika](https://discuss.pytorch.org/user_avatar/discuss.pytorch.org/abhyantrika/32/2852_2.png) [@abhyantrika](https://discuss.pytorch.org/u/abhyantrika)\
**Post date:** [December 25, 2017, 2:50pm UTC](https://discuss.pytorch.org/t/training-imagenet-vgg16/11543/1 "2017-12-25T14:50:21Z")

</div>

I am trying to train(kind of finetuning) the VGG16 network.  
I am using a custom set of CNN filters and am trying to retrain the final dense classification layer only. I am using the default settings provided in

> <https://github.com/pytorch/examples/blob/master/imagenet/main.py>

  
Where I have modified model creation from lines 73-88, to import the model with my CNN filters. I have also made sure that “requires\_grad=True” parameter is enabled only for the dense layer.

This is my result after around 22 epochs,  
Epoch: [22][4510/5005] Time 1.438 (2.538) Data 0.001 (1.757) Loss 6.9070 (6.9070) Prec@1 0.000 (0.103) Prec@5 0.391 (0.520)

As you can see prec@1 is Zero!

I suspect there is something wrong in the data loading and labeling of the imagenet dataset.  
I downloaded and extracted the ILSVRC2012 file to obtain train,test and eval.

The folder names inside train/ directory corresponds to some kind of synset id (“n02084071”).  
I am assuming the pytorch loaders use this as the class label.

The eval/ folder does not come with the same set of folders, instead comes with a .txt file that maps the images to numerical classes (1-1000). So I wrote a script to create folders accordingly for each images using the numerical class labels, using the data/metadata.mat file (this file has all the info & minute details)

Why is my precision zero, even after 22 epochs?  
Please do inform if my data processing methods are wrong or feel free to point out any other errors.  
 **Please help !**

---

<div class="post-metadata">

**Author:** ![Giocobon](https://discuss.pytorch.org/user_avatar/discuss.pytorch.org/giocobon/32/11809_2.png) [@Giocobon](https://discuss.pytorch.org/u/Giocobon)\
**Post date:** [March 16, 2020, 2:44pm UTC](https://discuss.pytorch.org/t/training-imagenet-vgg16/11543/2 "2020-03-16T14:44:13Z")

</div>

Hi @abhyantrika. Have you been able to solve the issue? I have the same problem. My guess is that the pretrained model uses labels in different orders than the one you have in the train/val datasets.
