-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathgan.py
More file actions
40 lines (31 loc) · 1.07 KB
/
Copy pathgan.py
File metadata and controls
40 lines (31 loc) · 1.07 KB
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
from config import GanConfig
from gan_model import GanModel
from data_generator import DataGenerator
from train import GanTrainer
import tensorflow as tf
FLAGS = tf.app.flags.FLAGS
tf.app.flags.DEFINE_boolean('is_train', True, """ Whether it is a training or testing""")
tf.app.flags.DEFINE_boolean('cont_train', False, """ whether to Load the Model and Continue Training or not """)
class GAN:
def __init__(self, sess):
"""
:param sess: the tensorflow session
"""
self.sess = sess
self.config = GanConfig()
self.model = GanModel(self.config)
self.data = DataGenerator(self.config)
self.trainer = GanTrainer(self.sess, self.model, self.data, self.config)
def train(self):
self.trainer.train()
def main(_):
init = tf.global_variables_initializer()
config = tf.ConfigProto()
config.gpu_options.per_process_gpu_memory_fraction = 0.7
sess = tf.Session(config=config)
sess.run(init)
gan = GAN(sess)
if FLAGS.is_train:
gan.train()
if __name__ == '__main__':
tf.app.run()