infogan | Keras implementation of InfoGAN | Machine Learning library
kandi X-RAY | infogan Summary
kandi X-RAY | infogan Summary
Keras implementation of InfoGAN: Interpretable Representation Learning by Information Maximizing Generative Adversarial Nets by Xi Chen, Yan Duan, Rein Houthooft, John Schulman, Ilya Sutskever, Pieter Abbeel.
Support
Quality
Security
License
Reuse
Top functions reviewed by kandi - BETA
- Plot a figure of a grid .
- Initialize the model .
- Train the discriminator .
- Setup the generator .
- Train discriminator on fake data .
- Process the MNIST dataset .
- Computes the mutual info loss of the discriminator .
- Generate a filename for a timestamp .
- Samples a categorical .
- Generate a random unit Gaussian .
infogan Key Features
infogan Examples and Code Snippets
Community Discussions
Trending Discussions on infogan
QUESTION
I am new to python and DL. Please help me to correct the error. This class was originly created with mnist dataset (28 x 28) I tried to adapt it to my work and the image that I am using are (224 x 224). I changed the input image shape but still have the incompatible shape image and the model still use the old shapes of mnist. Knowng that the that I am using: X_train=(676, 224, 224)/y_train(676,)/X_test(170, 224, 224)/y_test(170,)
The code :
...ANSWER
Answered 2020-Oct-06 at 13:47You forgot to change the architecture of the generator. The generator's output shape and the discriminator's input shape have to match. That's what causing the error.
To fix it, you need to fix the architecture. The generator produces images in shape (28, 28, 1), but you want (224, 224, 1). The shape the architecture produces is the result of the architecture itself and its parameters.
So I added two Upsampling layers and changed the size of the other layers to match the discriminator's output.
Also, I removed ZeroPadding2D layer from discriminator, since it made the shape odd (15, 15, ..), and therefore it was impossible to match the same size in the generator.
Here's the code:
QUESTION
I'm more familiar with tensorflow graph training than Keras, but I'm trying out Keras here.
In building a GAN the generator needs be optimized against a different loss than the discriminator (the opposite loss). In base tensorflow this is easy enough to implement using either 2 optimizers or by calling optimizer.compute_gradients(...)
and optimizer.apply_gradients(...)
separately with the appropriate group of weights.
In Keras, I don't see that I can achieve either of these. In implementations such as Keras-GAN, it appears that the training of generator and discriminator are split into separate models and then trained independently batch-by-batch. This means many more passes are required per effective update than would be required with the base tensorflow implementation with two optimizers operating on one pass.
Is there a way to implement the optimizer for GANs so that both generator and discriminator get trained in one pass in Keras?
TF 1.14
...ANSWER
Answered 2019-Jul-15 at 22:48This is a really tough question for Keras for several reasons:
A model can only have one optimizer... it would be necessary to change the source code for it to accept two or more
Even when you are using a custom optimizer, it would be possible to separate the weights, but it doesn't offer support to separate the losses, as can be seen in the source code for optimizers. The probability is that the optimizer already computes a final common loss (which would then make it impossible to attribute one loss for a group of weights and another for the other group)
The training mechanisms are not easy to find in the code. Things are spread all around, supporting many things such as loss weights, sample weights, etc. The time that it would take to summarize everything and then decide what to do/change would be too much.
Make your model in Keras as you would. The discriminator, the generator, their connections and outputs.
Just don't compile it. Instead, keep track of the main tensors (generator output, discriminator output, generator input), create the loss functions in Tensorflow style and train everything in tensorflow style.
QUESTION
I was trying to implement various GANs in Tensorflow (after doing it successfully in PyTorch), and I am having some problems while coding the discriminator part.
The code of the discriminator (very similar to the MNIST CNN tutorial) is:
...ANSWER
Answered 2017-Jun-21 at 09:59Instead of passing None
to reshape you must pass -1.
So this:
Community Discussions, Code Snippets contain sources that include Stack Exchange Network
Vulnerabilities
No vulnerabilities reported
Install infogan
You can use infogan like any standard Python library. You will need to make sure that you have a development environment consisting of a Python distribution including header files, a compiler, pip, and git installed. Make sure that your pip, setuptools, and wheel are up to date. When using pip it is generally recommended to install packages in a virtual environment to avoid changes to the system.
Support
Reuse Trending Solutions
Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items
Find more librariesStay Updated
Subscribe to our newsletter for trending solutions and developer bootcamps
Share this Page