In the Adversarial attack to fool a neural network section, we discussed our strategy of how to generate an image that looks very similar to the original images. In this section, we will implement the process of generating a digit's image from the MNIST dataset (the code file is available as Vanilla_and_DC_GAN.ipynb in GitHub):
- Import the relevant packages:
import numpy as npfrom keras.datasets import mnistfrom keras.layers import Input, Dense, Reshape, Flatten, Dropoutfrom keras.layers import BatchNormalizationfrom keras.layers.advanced_activations import LeakyReLUfrom keras.models import Sequentialfrom keras.optimizers import Adamimport matplotlib.pyplot as plt%matplotlib inlineplt.switch_backend('agg')from keras.models ...