Skip to content
This repository has been archived by the owner on Nov 17, 2023. It is now read-only.

Train-accuracy =1.000000 #4894

Closed
Agoniii opened this issue Feb 6, 2017 · 5 comments
Closed

Train-accuracy =1.000000 #4894

Agoniii opened this issue Feb 6, 2017 · 5 comments

Comments

@Agoniii
Copy link

Agoniii commented Feb 6, 2017

Environment info

Operating System: centos 7.1
MXNet version: v0.9
Python versio: v2.7

Error Message:

When I train with the googlenet, the Train_accuracy =1.000000 all the time. anyone can help?

INFO:root:Epoch[4] Batch [20] Speed: 436.48 samples/sec Train-accuracy=1.000000
INFO:root:Epoch[4] Batch [40] Speed: 418.70 samples/sec Train-accuracy=1.000000
INFO:root:Epoch[4] Batch [60] Speed: 419.75 samples/sec Train-accuracy=1.000000
INFO:root:Epoch[4] Batch [80] Speed: 418.40 samples/sec Train-accuracy=1.000000
INFO:root:Epoch[4] Batch [100] Speed: 421.43 samples/sec Train-accuracy=1.000000
INFO:root:Epoch[4] Batch [120] Speed: 419.66 samples/sec Train-accuracy=1.000000
INFO:root:Epoch[4] Batch [140] Speed: 415.42 samples/sec Train-accuracy=1.000000
INFO:root:Epoch[4] Batch [160] Speed: 415.30 samples/sec Train-accuracy=1.000000
INFO:root:Epoch[4] Batch [180] Speed: 416.12 samples/sec Train-accuracy=1.000000
INFO:root:Epoch[4] Batch [200] Speed: 420.10 samples/sec Train-accuracy=1.000000
INFO:root:Epoch[4] Batch [220] Speed: 416.36 samples/sec Train-accuracy=1.000000
INFO:root:Epoch[4] Batch [240] Speed: 416.22 samples/sec Train-accuracy=1.000000
INFO:root:Epoch[4] Batch [260] Speed: 418.99 samples/sec Train-accuracy=1.000000
INFO:root:Epoch[4] Batch [280] Speed: 415.44 samples/sec Train-accuracy=1.000000
INFO:root:Epoch[4] Batch [300] Speed: 414.69 samples/sec Train-accuracy=1.000000
INFO:root:Epoch[4] Batch [320] Speed: 415.61 samples/sec Train-accuracy=1.000000
INFO:root:Epoch[4] Batch [340] Speed: 417.83 samples/sec Train-accuracy=1.000000
INFO:root:Epoch[4] Batch [360] Speed: 412.90 samples/sec Train-accuracy=1.000000
INFO:root:Epoch[4] Batch [380] Speed: 417.75 samples/sec Train-accuracy=1.000000
INFO:root:Epoch[4] Batch [400] Speed: 416.55 samples/sec Train-accuracy=1.000000
INFO:root:Epoch[4] Batch [420] Speed: 416.80 samples/sec Train-accuracy=1.000000
INFO:root:Epoch[4] Batch [440] Speed: 415.29 samples/sec Train-accuracy=1.000000
INFO:root:Epoch[4] Batch [460] Speed: 415.40 samples/sec Train-accuracy=1.000000
INFO:root:Epoch[4] Batch [480] Speed: 415.84 samples/sec Train-accuracy=1.000000
INFO:root:Epoch[4] Batch [500] Speed: 417.56 samples/sec Train-accuracy=1.000000
INFO:root:Epoch[4] Batch [520] Speed: 424.66 samples/sec Train-accuracy=1.000000
INFO:root:Epoch[4] Batch [540] Speed: 416.23 samples/sec Train-accuracy=1.000000
INFO:root:Epoch[4] Batch [560] Speed: 414.90 samples/sec Train-accuracy=1.000000
INFO:root:Epoch[4] Batch [580] Speed: 423.35 samples/sec Train-accuracy=1.000000
INFO:root:Epoch[4] Batch [600] Speed: 408.58 samples/sec Train-accuracy=1.000000
INFO:root:Epoch[4] Batch [620] Speed: 418.28 samples/sec Train-accuracy=1.000000
INFO:root:Epoch[4] Batch [640] Speed: 424.21 samples/sec Train-accuracy=1.000000
INFO:root:Epoch[4] Batch [660] Speed: 418.61 samples/sec Train-accuracy=1.000000
INFO:root:Epoch[4] Batch [680] Speed: 412.77 samples/sec Train-accuracy=1.000000
INFO:root:Epoch[4] Batch [700] Speed: 415.54 samples/sec Train-accuracy=1.000000
INFO:root:Epoch[4] Batch [720] Speed: 416.24 samples/sec Train-accuracy=1.000000
INFO:root:Epoch[4] Batch [740] Speed: 415.85 samples/sec Train-accuracy=1.000000
INFO:root:Epoch[4] Resetting Data Iterator
INFO:root:Epoch[4] Time cost=113.786

Steps to reproduce

  1. The data is ILSVRC-2012 50000 .jpg images.
  2. prepare the .lst files
python tools/im2rec.py --list True --recursive True --train-ratio 0.8 example/image-classification/data/image-50000 ../imagenet_images/JPEG50000
  1. generate the rec file
python tools/im2rec.py --resize 227 --quality 95 --num-thread 16  example/image-classification/data/image-50000 ../imagenet_images/JPEG50000
  1. train_image5w.py is modified based on the train_imagenet.py
import os
import argparse
import logging
logging.basicConfig(level=logging.DEBUG)
from common import find_mxnet, data, fit
import mxnet as mx

if __name__ == '__main__':
    # parse args
    parser = argparse.ArgumentParser(description="train cifar10",
                                     formatter_class=argparse.ArgumentDefaultsHelpFormatter)
    fit.add_fit_args(parser)
    data.add_data_args(parser)
    data.add_data_aug_args(parser)
    # use a large aug level
    data.set_data_aug_level(parser, 3)
    parser.set_defaults(
        # network
        network          = 'resnet',
        num_layers       = 50,
        # data
        num_classes      = 1000,
        num_examples     = 50000,
        #num_examples     = 1281167,
        image_shape      = '3,224,224',
        min_random_scale = 1.143, # if input image has min size k, suggest to use
                              # 256.0/x, e.g. 0.533 for 480
        # train
        num_epochs       = 80,
        lr_step_epochs   = '30,60',
    )
    args = parser.parse_args()
    # load network
    from importlib import import_module
    net = import_module('symbol.'+args.network)
    sym = net.get_symbol(**vars(args))
    # train
    fit.fit(args, sym, data.get_rec_iter)
  1. train
python train_image5w.py \
 --batch-size 64 --lr 0.05 --lr-factor .94 --gpus 0,1,2,3 --num-epoch 60 --network googlenet \
 --data-train data/image-50000_train.rec --data-val  data/image-50000_val.rec
@Godricly
Copy link
Contributor

Godricly commented Feb 6, 2017

I guess your input image intensity is now in range [0, 255]. Try rescaling the input image to [-1.0, 1.0].

@Agoniii
Copy link
Author

Agoniii commented Feb 6, 2017

@Godricly Thanks for your reply. Could you tell me how to the input image to [-1.0, 1.0] ?

@Agoniii
Copy link
Author

Agoniii commented Feb 6, 2017

And my .lst file is as follows, the second argument is 0.000000. Does it affect the result?

15695 0.000000 ILSVRC2012_val_00019427.JPEG
35606 0.000000 ILSVRC2012_val_00038662.JPEG
28510 0.000000 ILSVRC2012_val_00022692.JPEG
33382 0.000000 ILSVRC2012_val_00002164.JPEG
19970 0.000000 ILSVRC2012_val_00006132.JPEG
10581 0.000000 ILSVRC2012_val_00004564.JPEG
7239 0.000000 ILSVRC2012_val_00033902.JPEG
4040 0.000000 ILSVRC2012_val_00021363.JPEG
25354 0.000000 ILSVRC2012_val_00022234.JPEG
5724 0.000000 ILSVRC2012_val_00001899.JPEG
43001 0.000000 ILSVRC2012_val_00027081.JPEG
4472 0.000000 ILSVRC2012_val_00042036.JPEG
22487 0.000000 ILSVRC2012_val_00044006.JPEG
43588 0.000000 ILSVRC2012_val_00023252.JPEG
14546 0.000000 ILSVRC2012_val_00024613.JPEG
35123 0.000000 ILSVRC2012_val_00030380.JPEG
14105 0.000000 ILSVRC2012_val_00028619.JPEG
6570 0.000000 ILSVRC2012_val_00031830.JPEG
4058 0.000000 ILSVRC2012_val_00028800.JPEG
24310 0.000000 ILSVRC2012_val_00023230.JPEG
8333 0.000000 ILSVRC2012_val_00042119.JPEG
15673 0.000000 ILSVRC2012_val_00037226.JPEG
31441 0.000000 ILSVRC2012_val_00027397.JPEG
13310 0.000000 ILSVRC2012_val_00009035.JPEG
13417 0.000000 ILSVRC2012_val_00039050.JPEG
34483 0.000000 ILSVRC2012_val_00006357.JPEG
27787 0.000000 ILSVRC2012_val_00033303.JPEG
24195 0.000000 ILSVRC2012_val_00027245.JPEG
48802 0.000000 ILSVRC2012_val_00042124.JPEG
16379 0.000000 ILSVRC2012_val_00019032.JPEG
42437 0.000000 ILSVRC2012_val_00035997.JPEG
......

@Godricly
Copy link
Contributor

Godricly commented Feb 6, 2017

There is a scale parameter in mxnet.io.ImageRecordIter which u can rescale the intensity. you need to add this parameter to this file if you are running the example. Also remember to subtract the mean before doing so.
I think the label should be ok.

@phunterlau
Copy link
Contributor

This issue is closed due to lack of activity in the last 90 days. Feel free to reopen if this is still an active issue. Thanks!

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

No branches or pull requests

3 participants