def discriminator(x, z_size, is_training, reuse, n_hid=500, isize=28 * 28): fc = dense(x, n_hid, is_training, reuse, w_normalized=True, name='fc1') fc = tf.nn.relu(fc, name='fc1/relu') fc = dense(fc, n_hid, is_training, reuse, w_normalized=True, name='fc2') fc = tf.nn.relu(fc, name='fc2/relu') out = dense(fc, 1, is_training, reuse, name='d_out') return out
def generator(z, is_training, reuse, n_hid=500, isize=28 * 28, use_bn=False): fc = dense(z, n_hid, is_training, reuse, w_regularizer=None, name='fc1') if use_bn: fc = tf.nn.relu( batch_norm(fc, is_training=is_training, reuse=reuse, name='fc1/bn')) else: fc = tf.nn.relu(hid, name='fc1/prelu') fc = dense(fc, n_hid, is_training, reuse, w_regularizer=None, name='fc2') if use_bn: fc = tf.nn.relu( batch_norm(fc, is_training=is_training, reuse=reuse, name='fc2/bn')) else: fc = rtf.nn.elu(fc, name='fc2/prelu') out = tf.nn.sigmoid( dense(fc, isize, is_training, reuse, w_regularizer=None, name='g_out')) return out
def discriminator_from_params(x, params, is_training, reuse, isize=28 * 28, n_hid=100): fc = dense(x, n_hid, is_training, reuse, w_normalized=True, name='fc1', params=params[:2]) fc = tf.nn.relu(fc, name='fc1/relu') fc = dense(fc, n_hid, is_training, reuse, w_normalized=True, name='fc2', params=params[2:4]) fc = tf.nn.relu(fc, name='fc2/relu') out = dense(fc, 1, is_training, reuse, name='d_out', params=params[4:]) return out