You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
class GAN(object):
def __init__(self, params):
# This defines the generator network - it takes samples from a noise
# distribution as input, and passes them through an MLP.
with tf.variable_scope('G'):
self.z = tf.placeholder(tf.float32, shape=(params.batch_size, 1))
self.G = generator(self.z, params.hidden_size)
# The discriminator tries to tell the difference between samples from
# the true data distribution (self.x) and the generated samples
# (self.z).
#
# Here we create two copies of the discriminator network
# that share parameters, as you cannot use the same network with
# different inputs in TensorFlow.
self.x = tf.placeholder(tf.float32, shape=(params.batch_size, 1))
with tf.variable_scope('D'):
self.D1 = discriminator(
self.x,
params.hidden_size,
params.minibatch
)
with tf.variable_scope('D', reuse=True):
self.D2 = discriminator(
self.G,
params.hidden_size,
params.minibatch
)
# Define the loss for discriminator and generator networks
# (see the original paper for details), and create optimizers for both
self.loss_d = tf.reduce_mean(-log(self.D1) - log(1 - self.D2))
self.loss_g = tf.reduce_mean(-log(self.D2))
vars = tf.trainable_variables()
self.d_params = [v for v in vars if v.name.startswith('D/')]
self.g_params = [v for v in vars if v.name.startswith('G/')]
self.opt_d = optimizer(self.loss_d, self.d_params)
self.opt_g = optimizer(self.loss_g, self.g_params)
self.G is not relevent to self.x, I am not understand why define self.x earlier will affect the result.
when I change the position of placeholder of x, it goes wrong
the original is:
I change to:
the training result is completely wrong. I am so confused, can anyone tell me why this change will effect the result.
The text was updated successfully, but these errors were encountered: