Week 4 Assignment 2: Neural Style Transfer

I have doubt regarding the following step where the model is created to do the following task:

“Creates a vgg model that returns a list of intermediate output values.”

def get_layer_outputs(vgg, layer_names):
outputs = [vgg.get_layer(layer[0]).output for layer in layer_names]
model = tf.keras.Model([vgg.input], outputs)
return model

content_layer = [('block5_conv4', 1)] vgg_model_outputs = get_layer_outputs(vgg, STYLE_LAYERS + content_layer)

To get intermediate layers activations, should not the input image be passed thorough all the layers from start upto that selected layers?

But in above code, it seems that the model is created which takes an input and generates output by directly passing input to that layers?

What am I missing here?

Hello @Faraz,

This function aims to create another model, not to immediately calculate any activation values. And the special thing about that model is to take vgg’s input as the model’s input, and some of vgg’s intermediate layers’ outputs as the model’s outputs. That’s it and nothing more.

Note that the created model is not a new model with new weights. The created model shares some layers (along with the layers’ weights) with vgg.

Cheers,
Raymond