generative deep learning def deprocess_image( ) [:: + zero-centering by removing the mean pixel value [:: + from imagenet this reverses transformation done by vgg preprocess_input [:: + [::::- np clip( astype('uint 'converts images from 'bgrto 'rgbthis is also part of the reversal of return vgg preprocess_input let' set up the vgg network it takes as input batch of three imagesthe stylereference imagethe target imageand placeholder that will contain the generated image placeholder is symbolic tensorthe values of which are provided externally via numpy arrays the style-reference and target image are static and thus defined using constantwhereas the values contained in the placeholder of the generated image will change over time listing loading he pret rained vgg net work and applying it he hree images placeholder that will contain the generated image from keras import backend as target_image constant(preprocess_image(target_image_path)style_reference_image constant(preprocess_image(style_reference_image_path)combination_image placeholder(( img_heightimg_width )input_tensor concatenate([target_imagestyle_reference_imagecombination_image]axis= model vgg vgg (input_tensor=input_tensorweights='imagenet'include_top=falseprint('model loaded 'combines the three images in single batch builds the vgg network with the batch of three images as input the model will be loaded with pretrained imagenet weights let' define the content losswhich will make sure the top layer of the vgg convnet has similar view of the target image and the generated image listing cont ent loss def content_loss(basecombination)return sum( square(combination base)next is the style loss it uses an auxiliary function to compute the gram matrix of an input matrixa map of the correlations found in the original feature matrix listing st yle loss def gram_matrix( )features batch_flatten( permute_dimensions( ( ))gram dot(featuresk transpose(features)return gram licensed to