This is a very simple implement of GANs by PyTorch 1.7.1.
This code is modifies, adapts by PyTorch 1.71 based on the GANs implemented in devneg. Moreover, I adds some comments to the original code and personal understandings of some code segments.
Task goal:
The goal of this GANs is to generate a Gaussian normal distribution from a uniform distribution; The task goal can be visualize like this:
the network architecture of generator and discriminator:
Result Show:
The following lists the data distribution results generated by the generator G for every 500 epochs of training.
epochs = 0
epochs = 1000
epochs = 5000
If we visualize the process iteration training, the sample mean and variance of the data distribution generated by the generator can be seen that:
After a certain epochs, the samples mean and variance of the generated data converge stably to the initial value we set for the target data distribution.
It means that our GANs trained successfully!
you can see the detailed analysis of the source code in my CSDN blog or Zhihu column.
References: