MCPcopy Create free account
hub / github.com/OUCMachineLearning/OUCML / generator

Function generator

GAN/datadownloader/model.py:15–50  ·  view source on GitHub ↗
(inputs, is_train=True, reuse=False)

Source from the content-addressed store, hash-verified

13FLAGS = flags.FLAGS
14
15def generator(inputs, is_train=True, reuse=False):
16 image_size = 64
17 s16 = image_size // 16
18 gf_dim = 64 # Dimension of gen filters in first conv layer. [64]
19 c_dim = FLAGS.c_dim # n_color 3
20 w_init = tf.glorot_normal_initializer()
21 gamma_init = tf.random_normal_initializer(1., 0.02)
22
23 with tf.variable_scope("generator", reuse=reuse):
24
25 net_in = InputLayer(inputs, name='g/in')
26 net_h0 = DenseLayer(net_in, n_units=(gf_dim * 8 * s16 * s16), W_init=w_init,
27 act = tf.identity, name='g/h0/lin')
28 net_h0 = ReshapeLayer(net_h0, shape=[-1, s16, s16, gf_dim*8], name='g/h0/reshape')
29 net_h0 = BatchNormLayer(net_h0, act=tf.nn.relu, is_train=is_train,
30 gamma_init=gamma_init, name='g/h0/batch_norm')
31
32 net_h1 = DeConv2d(net_h0, gf_dim * 4, (5, 5), strides=(2, 2),
33 padding='SAME', act=None, W_init=w_init, name='g/h1/decon2d')
34 net_h1 = BatchNormLayer(net_h1, act=tf.nn.relu, is_train=is_train,
35 gamma_init=gamma_init, name='g/h1/batch_norm')
36
37 net_h2 = DeConv2d(net_h1, gf_dim * 2, (5, 5), strides=(2, 2),
38 padding='SAME', act=None, W_init=w_init, name='g/h2/decon2d')
39 net_h2 = BatchNormLayer(net_h2, act=tf.nn.relu, is_train=is_train,
40 gamma_init=gamma_init, name='g/h2/batch_norm')
41
42 net_h3 = DeConv2d(net_h2, gf_dim, (5, 5), strides=(2, 2),
43 padding='SAME', act=None, W_init=w_init, name='g/h3/decon2d')
44 net_h3 = BatchNormLayer(net_h3, act=tf.nn.relu, is_train=is_train,
45 gamma_init=gamma_init, name='g/h3/batch_norm')
46
47 net_h4 = DeConv2d(net_h3, c_dim, (5, 5), strides=(2, 2),
48 padding='SAME', act=None, W_init=w_init, name='g/h4/decon2d')
49 net_h4.outputs = tf.nn.tanh(net_h4.outputs)
50 return net_h4
51
52def discriminator(inputs, is_train=True, reuse=False):
53 df_dim = 64 # Dimension of discrim filters in first conv layer. [64]

Callers 1

mainFunction · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected