Putting it all together

At this point, we usually implement the train method, but because CycleGAN has more components, we'll show you how to build the entire model. First, we instantiate the data_loader object, where you can specify the name of the training set (feel free to experiment with the different datasets). All the images will be resized to img_res=(IMG_SIZE, IMG_SIZE) for the network input, where IMG_SIZE = 256 (you can also try 128 to speed up the training process):

# Input shapeimg_shape = (IMG_SIZE, IMG_SIZE, 3)# Configure data loaderdata_loader = DataLoader(dataset_name='facades',                         img_res=(IMG_SIZE, IMG_SIZE))

Then, we'll define the optimizer and the loss weights:

lambda_cycle = 10.0  # Cycle-consistency losslambda_id = 0.1  ...

Get Advanced Deep Learning with Python 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.