Lesson 8 - when is layer_model.predict called?
In the code for lesson 8 we run the image through the layer_model
and attempt to predict the output of a specific convolutional layer of VGG called on the input image.
ia = np.asarray(img)
ib = np.expand_dims(ia, 0)
b = preproc(ib)
target = K.variable(layer_model.predict(b))
loss = metrics.mse(layer, target)
grad = K.gradients(loss, vgg_ap_model.input)
fn = K.function([vgg_ap_model.input], [loss, grad[0]])
We constantly update the input image in the backwards pass (we calculate the gradient loss function with respect to the input image).
Questions
- Does
target
ever change or is it static? - Is
layer_model.predict(b)
called just once? - Is
grad
an output of the function?