VGG_19 training loss does not reduce
Please let us know which model this issue is about (specify the top-level directory)
https://github.com/tensorflow/models/blob/master/slim/nets/vgg.py
Did anybody train Slim/VGG_19 from scratch recently. I used TF0.12, ran train_image_classifier.py with default parameter settings. The training loss started with 7.1 and stayed around that level even after 10K iterations. Evaluation showed accuracy stayed at 0.1%, equivalent to random guess.
I tried both with and without "--labels_offset=1", no difference. If anyone successfully trained VGG_19, please share your parameters. Thanks.
@sguada Any ideas?
A few more data points:
-
I ran slim/inception_v3 network successfully, with default parameters. Top-5 accuracy increases to 55% in about 12 hours.
-
For VGG_19, I changed weight-decay to 0.0005, the initial training loss is around 36.2, then quickly reduces to 6.9, then stays there forever.
-
I don't get any error without "--labels_offset=1", contradicting to this link: https://github.com/tensorflow/models/tree/master/slim#the-resnet-and-vgg-models-have-1000-classes-but-the-imagenet-dataset-has-1001
Training VGG_19 from scratch is very difficult. See paper for how the authors trained in stages http://arxiv.org/pdf/1409.1556.pdf
I trained VGG from scratch successfully by following the steps explained in the paper. The default values from Slim won't work. Thanks for your help. Closing the tickets...
Hi @junshi15, could you elaborate on how you followed the training steps in the paper using Slim? I am trying to train from scratch but it didn't work. I modified the training parameters based on Slim default and some suggestion in the paper and these are the details: labels_offset=1 weight_decay=4e-5 learning_rate=1e-2 rmsprop optimizer: momentum=0.9, rmsprop_decay=0.9, opt_epsilon=1e-10 learning_rate schedule: decrease by 0.94 at every 2 epoch batch_size=80 Initialization method: default
My training loss starts from 7.1, and gradually decreases to around 4 and then bouncing back to 7.5. (The whole chart spans to 18 epochs)

The most weird thing is that the evaluation top-1 accuracy keeps around 0.1%, which means it is not learning at all.
The differences between my setting and the paper are:
- the weight_decay (5e-4 in the paper)
- Initialization
- batch_size (256 in the paper)
- the optimizer (the vanilla momentum GSD is used in the paper)
- learning_rate schedule
My guess is that the failure of the training are mainly due to the weight decay and the initialization, since rmsprop optimizer is robuster than the vanilla one, and the learning_rate schedule is irrelevant here since the learning doesn't work from the every beginning. Batch size might be relevant too, but mine is bounded by my machine so I can't increase it.
My question is that how did you duplicate the initialization procedure using Slim? I can't figure out how to control the initialization via Slim. And how do you control the learning_rate schedule? The paper is using dynamic one which changes the learning rate when it doesn't change. Could you share how did you do this in Slim? Thank you!
The following setting worked for me.
--model_name=vgg_19
--num_preprocessing_threads=16
--num_gpus=8
--num_clones=8
--batch_size=32
--learning_rate=0.01
--num_epochs_per_decay=2.5
--learning_rate_decay_factor=0.1
--optimizer=momentum
--weight_decay=0.0005
--max_number_of_steps=450000
It's easier to train if you add batch_norm by adding "normalizer_fn=slim.batch_norm" as follows. But in original paper, batch norm is not implemented.
with slim.arg_scope([slim.conv2d, slim.fully_connected, normalizer_fn=slim.batch_norm, outputs_collections=end_points_collection):