MCPcopy Index your code
hub / github.com/tensorpack/tensorpack / build_graph

Method build_graph

examples/GAN/Image2Image.py:119–143  ·  view source on GitHub ↗
(self, input, output)

Source from the content-addressed store, hash-verified

117 return l
118
119 def build_graph(self, input, output):
120 input, output = input / 128.0 - 1, output / 128.0 - 1
121
122 with argscope([Conv2D, Conv2DTranspose], kernel_initializer=tf.truncated_normal_initializer(stddev=0.02)):
123 with tf.variable_scope('gen'):
124 fake_output = self.generator(input)
125 with tf.variable_scope('discrim'):
126 real_pred = self.discriminator(input, output)
127 fake_pred = self.discriminator(input, fake_output)
128
129 self.build_losses(real_pred, fake_pred)
130 errL1 = tf.reduce_mean(tf.abs(fake_output - output), name='L1_loss')
131 self.g_loss = tf.add(self.g_loss, LAMBDA * errL1, name='total_g_loss')
132 add_moving_summary(errL1, self.g_loss)
133
134 # tensorboard visualization
135 if IN_CH == 1:
136 input = tf.image.grayscale_to_rgb(input)
137 if OUT_CH == 1:
138 output = tf.image.grayscale_to_rgb(output)
139 fake_output = tf.image.grayscale_to_rgb(fake_output)
140
141 visualize_tensors('input,output,fake', [input, output, fake_output], max_outputs=max(30, BATCH))
142
143 self.collect_variables()
144
145 def optimizer(self):
146 lr = tf.get_variable('learning_rate', initializer=2e-4, trainable=False)

Callers

nothing calls this directly

Calls 8

generatorMethod · 0.95
discriminatorMethod · 0.95
build_lossesMethod · 0.95
add_moving_summaryFunction · 0.90
argscopeFunction · 0.85
visualize_tensorsFunction · 0.85
addMethod · 0.45
collect_variablesMethod · 0.45

Tested by

no test coverage detected