Generative Adversarial Nets with Delira - A very short introduction¶
Author: Justus Schock
Date: 04.12.2018
This Example shows how to set up a basic GAN PyTorch experiment and Visdom Logging Environment.
HyperParameters¶
Let’s first setup the essential hyperparameters. We will use
delira
’s Parameters
-class for this:
Since we specified torch.nn.L1Loss
as criterion and
torch.nn.MSELoss
as metric, they will be both calculated for each
batch, but only the criterion will be used for backpropagation. Since we
have a simple generative task, this should be sufficient. We will train
our network with a batchsize of 64 by using Adam
as optimizer of
choice.
Logging and Visualization¶
To get a visualization of our results, we should monitor them somehow.
For logging we will use Visdom
. To start a visdom server you need to
execute the following command inside an environment which has visdom
installed:
visdom -port=9999
This will start a visdom server on port 9999 of your machine and now we can start to configure our logging environment. To view your results you can open http://localhost:9999 in your browser.
Since a single visdom server can run multiple environments, we need to specify a (unique) name for our environment and need to tell the logger, on which port it can find the visdom server.
Data Preparation¶
Loading¶
Next we will create a small train and validation set (based on
torchvision
MNIST):
Augmentation¶
For Data-Augmentation we will apply a few transformations:
With these transformations we can now wrap our datasets into datamanagers:
Training¶
After we have done that, we can finally specify our experiment and run
it. We will therfore use the already implemented
GenerativeAdversarialNetworkBasePyTorch
which is basically a vanilla
DCGAN:
Congratulations, you have now trained your first Generative Adversarial
Model using delira
.
See Also¶
For a more detailed explanation have a look at * the introduction tutorial * the 2d segmentation example * the 3d segmentation example * the classification example