def high_capacity_decoder(name, z, n_channels, is_training, mode=None, nonlinearity=tf.nn.relu): output = Linear(name + '.Input', z.get_shape().as_list()[1], DIM * 4 * 8 * 8, z) output = Normalize(name + '.BN0', [0], output, is_training, mode) output = nonlinearity(output) output = tf.reshape(output, [-1, DIM * 4, 8, 8]) output = Deconv2D(name + '.1', DIM * 4, DIM * 4, 5, output) output = Normalize(name + '.BN1', [0, 2, 3], output, is_training, mode) output = nonlinearity(output) output = Deconv2D(name + '.2', DIM * 4, DIM * 2, 5, output) output = Normalize(name + '.BN2', [0, 2, 3], output, is_training, mode) output = nonlinearity(output) output = Deconv2D(name + '.3', DIM * 2, DIM // 2, 5, output) output = Normalize(name + '.BN3', [0, 2, 3], output, is_training, mode) output = nonlinearity(output) output = Conv2D(name + '.4', DIM // 2, n_channels, 5, output) output = tf.reshape(output, [-1, n_channels * DIM * DIM]) return output
def dcgan_decoder(name, z, n_channels, is_training, mode=None, nonlinearity=tf.nn.relu): conv2d.set_weights_stdev(0.02) deconv2d.set_weights_stdev(0.02) linear.set_weights_stdev(0.02) output = Linear(name + '.Input', z.get_shape().as_list()[1], 4*4*8*DIM, z) output = tf.reshape(output, [-1, 8*DIM, 4, 4]) output = Normalize(name + '.BN1', [0,2,3], output, is_training, mode) output = nonlinearity(output) output = Deconv2D(name +'.2', 8*DIM, 4*DIM, 5, output) output = Normalize(name + '.BN2', [0,2,3], output, is_training, mode) output = nonlinearity(output) output = Deconv2D(name +'.3', 4*DIM, 2*DIM, 5, output) output = Normalize(name + '.BN3', [0,2,3], output, is_training, mode) output = nonlinearity(output) output = Deconv2D(name +'.4', 2*DIM, DIM, 5, output) output = Normalize(name + '.BN4', [0,2,3], output, is_training, mode) output = nonlinearity(output) output = Deconv2D(name +'.5', DIM, n_channels, 5, output) output = tf.reshape(output, [-1, n_channels*DIM*DIM]) conv2d.unset_weights_stdev() deconv2d.unset_weights_stdev() linear.unset_weights_stdev() return output