Reusing the trained CGANs

After training a CGAN, you may find useful to use the produced images in other applications. The method generate_new can be used to extract single images as well as a set of images (in order to check the quality of results for a specific image class). It operates on a previously trained CGan class, so all you have to do is just to pickle it in order first to save it, then to restore it again when needed.

When the training is complete, you can save your CGan class using pickle, as shown by these commands:

import picklepickle.dump(gan, open('mnist.pkl', 'wb'))

In this case, we have saved the CGAN trained on the MNIST dataset.

After you have restarted the Python session and memory is clean of any variable, you can just ...

Get TensorFlow Deep Learning Projects now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.