-
Notifications
You must be signed in to change notification settings - Fork 22
/
main.py
48 lines (29 loc) · 884 Bytes
/
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
import tensorflow as tf
from model import Model
from trainOps import TrainOps
import glob
import os
import cPickle
import numpy.random as npr
import numpy as np
flags = tf.app.flags
flags.DEFINE_string('gpu', '0', "GPU to used")
flags.DEFINE_string('exp_dir', 'exp_dir', "Experiment directory")
flags.DEFINE_string('mode', 'mode', "Experiment directory")
FLAGS = flags.FLAGS
def main(_):
GPU_ID = FLAGS.gpu
os.environ["CUDA_DEVICE_ORDER"] = "PCI_BUS_ID" # see issue #152 on stackoverflow
os.environ["CUDA_VISIBLE_DEVICES"] = str(GPU_ID)
EXP_DIR = FLAGS.exp_dir
model = Model()
trainOps = TrainOps(model, EXP_DIR)
trainOps.load_exp_config()
if FLAGS.mode=='train':
print 'Training'
trainOps.train()
elif FLAGS.mode=='test':
print 'Testing'
trainOps.test('svhn')
if __name__ == '__main__':
tf.app.run()