Open kmttsh opened 6 years ago
The learning rate is too high!
You can check this by having a look at all images in the folder <log_dir>/bboxes
. You should see that the predicted bboxes jump around a lot!
I suggest setting the learning rate to 1e-4
or 1e-5
with the command line switch -lr
or --learning-rate
Thank you for your reply! As you suggested, the accuracy has improved, but it is not enough.
python train_svhn.py <dir>/svhn_dataset_and_models/specification.json ./work --gpus 3 --blank-label 10 --char-map ../datasets/svhn/svhn_char_map.json -b 64 --learning-rate 0.0001 --epoch 200
<dir>/lib/python3.5/site-packages/chainer/training/updaters/multiprocess_parallel_updater.py:131: UserWarning: optimizer.eps is changed to 1e-08 by MultiprocessParallelUpdater for new batch size.
format(optimizer.eps))
epoch iteration main/loss main/accuracy lr fast_validation/main/loss fast_validation/main/accuracy validation/main/loss validation/main/accuracy
0 100 7.30914 0.00507813 3.08566e-05
0 200 6.04959 0.0198828 4.25853e-05
0 300 5.97783 0.0191797 5.09208e-05
0 400 5.97065 0.0211719 5.74294e-05
0 500 5.94329 0.0212109 6.27392e-05
0 600 5.94245 0.0192969 6.71828e-05
0 700 5.95647 0.020625 7.0964e-05
0 800 5.89843 0.0215625 7.42193e-05
0 900 5.91704 0.0216406 7.70463e-05
0 1000 5.92901 0.0198828 7.95176e-05 6.10376 0.0174028
0 1100 5.92836 0.0207422 8.16892e-05
0 1200 5.92269 0.0225781 8.36054e-05
0 1300 5.89819 0.0221875 8.53021e-05
0 1400 5.89788 0.0219922 8.68087e-05
0 1500 5.88448 0.0226562 8.81497e-05
1 1600 5.89985 0.0208203 8.93457e-05
1 1700 5.87362 0.0215625 9.04141e-05
1 1800 5.87873 0.0211719 9.13701e-05
1 1900 5.88609 0.0219922 9.22265e-05
1 2000 5.86692 0.0218359 9.29946e-05 5.91479 0.021234
1 2100 5.87499 0.0230469 9.36842e-05
1 2200 5.90617 0.0214844 9.43037e-05
1 2300 5.88547 0.0224219 9.48608e-05
1 2400 5.88797 0.02125 9.5362e-05
1 2500 5.87188 0.0216797 9.58132e-05
1 2600 5.86528 0.0226953 9.62197e-05
1 2700 5.85535 0.0210156 9.6586e-05
1 2800 5.85524 0.0235156 9.69162e-05
1 2900 5.84669 0.0228906 9.7214e-05
1 3000 5.87788 0.0221484 9.74827e-05 5.86614 0.0217849
1 3100 5.86994 0.0215625 9.77252e-05
2 3200 5.84037 0.0232422 9.7944e-05
2 3300 5.83626 0.0228516 9.81416e-05
2 3400 5.79569 0.0234766 9.83201e-05
2 3500 5.78465 0.0230859 9.84812e-05
2 3600 5.74576 0.0256641 9.86268e-05
2 3700 5.76113 0.0221094 9.87584e-05
2 3800 5.73173 0.0233203 9.88773e-05
2 3900 5.731 0.02375 9.89847e-05
2 4000 5.71808 0.0241406 9.90818e-05 5.77324 0.0233624
2 4100 5.72374 0.0244141 9.91696e-05
2 4200 5.7117 0.0257031 9.9249e-05
2 4300 5.71056 0.0239453 9.93207e-05
2 4400 5.71849 0.0242188 9.93856e-05
2 4500 5.70581 0.02625 9.94443e-05
2 4600 5.68513 0.0243359 9.94973e-05
3 4700 5.70342 0.0253125 9.95453e-05
3 4800 5.67535 0.0263672 9.95887e-05
3 4900 5.67486 0.0269922 9.96279e-05
3 5000 5.64855 0.0248828 9.96634e-05 5.97818 0.0250651
3 5100 5.67777 0.0243359 9.96955e-05
3 5200 5.66923 0.0266016 9.97245e-05
3 5300 5.69099 0.0239063 9.97508e-05
~~~~~~~~~~~~~~~~~~~~~
198 310400 3.60274 0.178672 0.0001
198 310500 3.57621 0.180156 0.0001
198 310600 3.53797 0.181992 0.0001
198 310700 3.63558 0.180273 0.0001
198 310800 3.59109 0.179375 0.0001
198 310900 3.61663 0.176719 0.0001
199 311000 3.5567 0.180586 0.0001 6.24907 0.0733674
199 311100 3.60563 0.178945 0.0001
199 311200 3.66259 0.179727 0.0001
199 311300 3.59662 0.185078 0.0001
199 311400 3.53541 0.189766 0.0001
199 311500 3.58667 0.182734 0.0001
199 311600 3.52114 0.195586 0.0001
199 311700 3.58835 0.180156 0.0001
199 311800 3.5372 0.185391 0.0001
199 311900 3.57168 0.183438 0.0001
199 312000 3.47688 0.195195 0.0001 5.776 0.0995843
199 312100 3.48593 0.189102 0.0001
199 312200 3.55354 0.18082 0.0001
199 312300 3.48362 0.189219 0.0001
199 312400 3.52996 0.185586 0.0001
200 312500 3.53738 0.182422 0.0001
So, I have two questions.
what accuracy is obtained by this learning?
how many epochs does this network need to learn?
Do you mean what kind of accuracy is obtained? If so it is word level accuracy.
The network does not need many epochs to learn normally. 10 should be enough to get a first decent version, but then you should restart the training with randomly initialized recognition net, but using the trained weights for the localziation net.
Did you have a look at the pictures in <log_dir>/bboxes
? How do the predicted bboxes look like? These images are there to give you a feeling of the performance of the network and if you set all hyperparameters correctly.
Sorry, what I wanted to know is how much "main / accuracy" is improved when this script is executed. And I tried training with another parameter again, the accuracy has improved.
I think that I could not set an appropriate learning rate for batch size.
$ python train_svhn.py <dir>/svhn_dataset_and_models/specification.json ./work --gpus 0 1 2 3 --blank-label 10 --char-map ../datasets/svhn/svhn_char_map.json -b 16 --learning-rate 0.0008 --epoch 100
<dir>/lib/python3.5/site-packages/chainer/training/updaters/multiprocess_parallel_updater.py:131: UserWarning: optimizer.eps is changed to 4e-08 by MultiprocessParallelUpdater for new batch size.
format(optimizer.eps))
epoch iteration main/loss main/accuracy lr fast_validation/main/loss fast_validation/main/accuracy validation/main/loss validation/main/accuracy
0 100 7.08026 0.00921875 0.000246853
0 200 6.48398 0.0171875 0.000340683
0 300 6.3467 0.0167188 0.000407367
0 400 6.07347 0.0220312 0.000459436
0 500 6.14111 0.0207813 0.000501914
0 600 6.07865 0.019375 0.000537463
0 700 6.07493 0.0190625 0.000567712
0 800 6.04775 0.0148437 0.000593755
0 900 5.98705 0.0223437 0.00061637
0 1000 5.96897 0.0203125 0.000636141 5.9492 0.0199219
0 1100 6.01165 0.0189062 0.000653513
0 1200 5.96329 0.02375 0.000668843
98 153400 0.903547 0.760156 0.0008
98 153500 0.897576 0.7625 0.0008
98 153600 0.916847 0.756719 0.0008
98 153700 0.984916 0.741094 0.0008
98 153800 0.970778 0.742188 0.0008
98 153900 0.985056 0.745938 0.0008
98 154000 0.990586 0.739531 0.0008 1.20713 0.706172
98 154100 0.939159 0.7525 0.0008
98 154200 0.932501 0.754062 0.0008
98 154300 1.02911 0.727812 0.0008
98 154400 0.991427 0.747344 0.0008
98 154500 1.03597 0.730156 0.0008
98 154600 0.975343 0.747031 0.0008
99 154700 0.984289 0.744844 0.0008
99 154800 0.911613 0.760312 0.0008
99 154900 0.865186 0.767969 0.0008
99 155000 0.953758 0.743125 0.0008 1.42776 0.676875
99 155100 0.94563 0.751875 0.0008
99 155200 0.951638 0.746406 0.0008
99 155300 0.908591 0.756875 0.0008
99 155400 0.926625 0.750469 0.0008
99 155500 0.969775 0.748125 0.0008
99 155600 0.981316 0.75 0.0008
99 155700 0.93322 0.755625 0.0008
99 155800 0.999408 0.736719 0.0008
99 155900 1.00439 0.739844 0.0008
99 156000 0.944262 0.749375 0.0008 1.29065 0.695078
99 156100 0.968931 0.749687 0.0008
99 156200 0.955661 0.747344 0.0008
However, it seems that localization is not working well.
If so, could you tell me a good way to improve?
Hmm, two things:
1e-4
, you are using 8e-4
right now..npz
file) and restart the training, using this model (-r
or --resume
+ path to model). You should also make the network load only the trained weights of the localization network and not the weights of the recognition network (use --load-localization
for that). This should help.
Thank you for publishing source code. With reference to "Readme", I first tried out "train_svhn.py", but the train loss does not go down well. Could you check whether something is wrong?
Even if I use images generated by ”create_svhn_dataset_4_images.py”, the same result will be obtained.