The GAN network combines the discriminator and generator from previous recipes into a conditional adversarial configuration for training.
Keep track of the fact that you remembered to add gan.py
to your working directory:
├── docker │ ├── build.sh │ ├── clean.sh │ └── Dockerfile ├── README.md ├── run.sh └── src | ├── generator.py | ├── gan.py
The GAN network in this case is arguably the easiest part to implement—we're simply going to link up our networks so they can train together:
- Import all of the libraries we need to use for this class:
#!/usr/bin/env python3 import sys import numpy as np from keras.models import Sequential, Model from keras.layers import Input from keras.optimizers import Adam, SGD from keras.utils import plot_model
- Implement the
init
class with theAdam
optimizer and then an array ofmodel_inputs
andmodel_outputs
:
class GAN(object): def __init__(self, model_inputs=[],model_outputs=[]): self.inputs ...