09.05.2023 Views

pdfcoffee

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

Chapter 6

And handwritten digits generated by our GAN:

You can see from the preceding figures that as the epochs increase, the handwritten

digits generated by the GAN become more and more realistic.

To plot the loss and the generated images of the handwritten digits, we define two

helper functions, plotLoss() and saveGeneratedImages(). Their code is given

as follows:

# Plot the loss from each batch

def plotLoss(epoch):

plt.figure(figsize=(10, 8))

plt.plot(dLosses, label='Discriminitive loss')

plt.plot(gLosses, label='Generative loss')

plt.xlabel('Epoch')

plt.ylabel('Loss')

plt.legend()

plt.savefig('images/gan_loss_epoch_%d.png' % epoch)

[ 197 ]

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!