Error in UNQ_C1 W3

I ve been working on this assignment for hours but i still dont understand why im getting this error at question 1: TypeError: Cannot interpret feed_dict key as Tensor: Can not convert a Model into a Tensor.

i think the mistake is in one of those code lines but i dont find it, appreciate your help:

2. Get gradients of last layer with respect to output

# get the gradients of y_c with respect to the spatial map layer (it's a list of length 1)
grads_l = K.gradients(y_c, spatial_map_layer)

# Get the gradient at index 0 of the list
grads = grads_l[0]
   
# 3. Get hook for the selected layer and its gradient, based on given model's input
# Hint: Use the variables produced by the previous two lines of code
spatial_map_and_gradient_function = K.function([input_model], [spatial_map_layer, grads])

# Put in the image to calculate the values of the spatial_maps (selected layer) and values of the gradients
spatial_map_all_dims, grads_val_all_dims = spatial_map_and_gradient_function([image])

Hi @JAMA,
I found the error in your code. In the following line:
“spatial_map_and_gradient_function = K.function([input_model], [spatial_map_layer, grads])”, you need to take the input of the input model, because this input model has an input and an output. So the line should be:
“spatial_map_and_gradient_function = K.function([input_model.input], [spatial_map_layer, grads])”

Let me know if this works!

It worked thank you!!