Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

In the GAN notebook, generated images have the undesired effect of #112

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

In the GAN notebook, generated images have the undesired effect of #112

wants to merge 1 commit into from

Conversation

phunc20
Copy link

@phunc20 phunc20 commented May 26, 2019

bright, single-colored pots. I happened to realize that it is not
entirely due to GAN itself (if at all), but to the way we convert
it to PIL images and plot it afterwards. This is due to the fact that
the final layer of the generator model uses tanh activation, which
results in neuron output in the range of [-1, 1], unlike real_images,
which are in [0, 1]. So I find it best to leave, for the lines of
code involving image.array_to_img() [I believe there are only three],
leave real_images part unchanged, and modify generated_images part to
sth like:
image.array_to_img(generated_images[i], scale=True).
This will remove the above-mentioned undesired effect.

The reason is that the [-1, 0] part of [-1, 1] when multiplied by
255 and then converted to unit8 will have unexpected color behaviour.
(The negative values will circle periodically back like in Z_256)

Actually, the training process and hyperparameters of the optimizers
can also be altered accordingly if we have the generator output's range
be consistent with the real images range and train.

bright, single-colored pots. I happened to realize that it is not
entirely due to GAN itself (if at all), but to the way we convert
it to PIL images and plot it afterwards. This is due to the fact that
the final layer of the generator model uses tanh activation, which
results in neuron output in the range of [-1, 1], unlike real_images,
which are in [0, 1]. So I find it best to leave, for the lines of
code involving image.array_to_img() [I believe there are only three],
leave real_images part unchanged, and modify generated_images part to
sth like:
image.array_to_img(generated_images[i], scale=True).
This will remove the above-mentioned undesired effect.

The reason is that the [-1, 0] part of [-1, 1] when multiplied by
255 and then converted to unit8 will have unexpected color behaviour.
(The negative values will circle periodically back like in Z_256)

Actually, the training process and hyperparameters of the optimizers
can also be altered accordingly if we have the generator output's range
be consistent with the real images range and train.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant