Skip to content

Instantly share code, notes, and snippets.

@mmeendez8
Last active January 23, 2019 14:46
Show Gist options
  • Select an option

  • Save mmeendez8/ea9e71ad05d2f79f448b34f1a8b5be6c to your computer and use it in GitHub Desktop.

Select an option

Save mmeendez8/ea9e71ad05d2f79f448b34f1a8b5be6c to your computer and use it in GitHub Desktop.
def decoder(z):
activation = tf.nn.relu
with tf.variable_scope("Decoder"):
x = tf.layers.dense(z, units=FLAGS.inputs_decoder, activation=activation)
x = tf.layers.dense(x, units=FLAGS.inputs_decoder, activation=activation)
recovered_size = int(np.sqrt(FLAGS.inputs_decoder))
x = tf.reshape(x, [-1, recovered_size, recovered_size, 1])
x = tf.layers.conv2d_transpose(x, filters=64, kernel_size=4, strides=1, padding='same', activation=activation)
x = tf.layers.conv2d_transpose(x, filters=64, kernel_size=4, strides=1, padding='same', activation=activation)
x = tf.layers.conv2d_transpose(x, filters=64, kernel_size=4, strides=1, padding='same', activation=activation)
x = tf.contrib.layers.flatten(x)
x = tf.layers.dense(x, units=28 * 28, activation=None)
x = tf.layers.dense(x, units=28 * 28, activation=tf.nn.sigmoid)
img = tf.reshape(x, shape=[-1, 28, 28, 1])
return img
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment