Keras-GAN icon indicating copy to clipboard operation
Keras-GAN copied to clipboard

AAE Model - Encoder Output - Training Order

Open pGit1 opened this issue 7 years ago • 3 comments

@eriklindernoren as always thank you for the amazing library!

Can you explain what this code is doing here for the encoder starting from the variable "mu"? Im not sure which model this corresponds to in the paper. Are you doing this merge layer as "hack" to make the latent code closer to normal to make training easier on the network?

Really curious on your interpretation of the merge layer...This seems like a good trick but I want to make sure I understand what is going on and the why behind it.

    def build_encoder(self):
        # Encoder

        img = Input(shape=self.img_shape)

        h = Flatten()(img)
        h = Dense(512)(h)
        h = LeakyReLU(alpha=0.2)(h)
        h = Dense(512)(h)
        h = LeakyReLU(alpha=0.2)(h)
        mu = Dense(self.latent_dim)(h)
        log_var = Dense(self.latent_dim)(h)
        latent_repr = merge([mu, log_var],
                mode=lambda p: p[0] + K.random_normal(K.shape(p[0])) * K.exp(p[1] / 2),
                output_shape=lambda p: p[0])

         return Model(img, latent_repr)

Concerning the training loop code I notice you do like the below when training the discrminator, but does this adversely affect performance? Isn't it better to feeds nets data randomly (e.g. send a minbatch with both positives and negatives in it and do train_on_batch once)?

            # Train the discriminator
            d_loss_real = self.discriminator.train_on_batch(latent_real, valid)
            d_loss_fake = self.discriminator.train_on_batch(latent_fake, fake)
            d_loss = 0.5 * np.add(d_loss_real, d_loss_fake)

Can you explain you rationale for this type of setup? Im NOT questioning your methods, just trying to understand.

pGit1 avatar May 19 '18 02:05 pGit1

Traceback (most recent call last): File "D:/py_project/untitled/keras/Keras-GAN-master/aae/aae.py", line 189, in aae = AdversarialAutoencoder() File "D:/py_project/untitled/keras/Keras-GAN-master/aae/aae.py", line 36, in init self.encoder = self.build_encoder() File "D:/py_project/untitled/keras/Keras-GAN-master/aae/aae.py", line 71, in build_encoder output_shape=lambda p: p[0]) TypeError: 'module' object is not callable

i also want know what happened

Taoerwang avatar Nov 22 '18 06:11 Taoerwang

same issue with me also. did anyone solve it??

mahimanzum avatar Aug 21 '19 04:08 mahimanzum