in Section 5.4 - Load Pre-trained VGG19 Model/ function get_layer_outputs,
what does “input” mean in line
model = tf.keras.Model([vgg.input], outputs)
def get_layer_outputs(vgg, layer_names):
""" Creates a vgg model that returns a list of intermediate output values."""
outputs = [vgg.get_layer(layer[0]).output for layer in layer_names]
model = tf.keras.Model([vgg.input], outputs)
return model
also, when we use this function to get content_target content_target content_target =vgg_model_outputs(content_image), do i understand this correctly that get layer output returns a model that propagates forward the input image. In this case, why do we not use the “predict” method instead?
vgg19.inputs refers to the input shape of the image.
In [1]: import tensorflow as tf
In [2]: vgg19 = tf.keras.applications.VGG19()
In [3]: vgg19.inputs
Out[3]: [<KerasTensor: shape=(None, 224, 224, 3) dtype=float32 (created by layer 'input_1')>]
A tensorflow model can be asked to predict using predict() or like a function call which invokes __call__ method. Using predict is preferred (see discussion here )
With Balaji’s explanation in mind, the answer is that what we are doing there is actually creating (defining) a model: the return value of that function is a Keras Model object. Then we can use the predict() method of the resulting model to generate actual outputs by feeding it particular inputs.