mjdietzx / SimGAN

Implementation of Apple's Learning from Simulated and Unsupervised Images through Adversarial Training
MIT License
411 stars 101 forks source link

Why is the output shape of discriminator is (None, 2)? #13

Open hellojialee opened 6 years ago

hellojialee commented 6 years ago

Hi everyone. I'm a green hand in GAN. Seeing the following code:

`def discriminator_network(input_image_tensor): """ The discriminator network, Dφ, contains 5 convolution layers and 2 max-pooling layers.

:param input_image_tensor: Input tensor corresponding to an image, either real or refined.
:return: Output tensor that corresponds to the probability of whether an image is real or refined.
"""
x = layers.Convolution2D(96, 3, 3, border_mode='same', subsample=(2, 2), activation='relu')(input_image_tensor)
x = layers.Convolution2D(64, 3, 3, border_mode='same', subsample=(2, 2), activation='relu')(x)
x = layers.MaxPooling2D(pool_size=(3, 3), border_mode='same', strides=(1, 1))(x)
x = layers.Convolution2D(32, 3, 3, border_mode='same', subsample=(1, 1), activation='relu')(x)
x = layers.Convolution2D(32, 1, 1, border_mode='same', subsample=(1, 1), activation='relu')(x)
x = layers.Convolution2D(2, 1, 1, border_mode='same', subsample=(1, 1), activation='relu')(x)

# here one feature map corresponds to `is_real` and the other to `is_refined`,
# and the custom loss function is then `tf.nn.sparse_softmax_cross_entropy_with_logits`
return layers.Reshape((-1, 2))(x)`

How to understand ' here one feature map corresponds to is_real and the other to is_refined'? Usually, the discriminator output only one feature map indicating the confidence probability of true or false.

hellojialee commented 6 years ago

Ok, I may have figured out.