-
Notifications
You must be signed in to change notification settings - Fork 9
/
Copy pathmain.py
57 lines (53 loc) · 2.23 KB
/
main.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
import sys
sys.path.append('./trainer')
import argparse
import googlenet
import nutszebra_data_augmentation
import nutszebra_cifar10
import nutszebra_optimizer
if __name__ == '__main__':
parser = argparse.ArgumentParser(description='cifar10')
parser.add_argument('--load_model', '-m',
default=None,
help='trained model')
parser.add_argument('--load_optimizer', '-o',
default=None,
help='optimizer for trained model')
parser.add_argument('--load_log', '-l',
default=None,
help='optimizer for trained model')
parser.add_argument('--save_path', '-p',
default='./',
help='model and optimizer will be saved every epoch')
parser.add_argument('--epoch', '-e', type=int,
default=200,
help='maximum epoch')
parser.add_argument('--batch', '-b', type=int,
default=32,
help='mini batch number')
parser.add_argument('--gpu', '-g', type=int,
default=-1,
help='-1 means cpu mode, put gpu id here')
parser.add_argument('--start_epoch', '-s', type=int,
default=1,
help='start from this epoch')
parser.add_argument('--train_batch_divide', '-trb', type=int,
default=4,
help='divid batch number by this')
parser.add_argument('--test_batch_divide', '-teb', type=int,
default=4,
help='divid batch number by this')
parser.add_argument('--lr', '-lr', type=float,
default=0.0015,
help='leraning rate')
args = parser.parse_args().__dict__
lr = args.pop('lr')
print('generating model')
model = googlenet.Googlenet(10)
print('Done')
optimizer = nutszebra_optimizer.OptimizerGooglenet(model, lr=lr)
args['model'] = model
args['optimizer'] = optimizer
args['da'] = nutszebra_data_augmentation.DataAugmentationCifar10NormalizeBigger
main = nutszebra_cifar10.TrainCifar10(**args)
main.run()