Week 2 A1 ResNet50

I’m getting this error.

---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
Input In [8], in <cell line: 3>()
      1 tf.keras.backend.set_learning_phase(True)
----> 3 model = ResNet50(input_shape = (64, 64, 3), classes = 6)
      4 print(model.summary())

Input In [7], in ResNet50(input_shape, classes, training)
     29 X = MaxPooling2D((3, 3), strides=(2, 2))(X)
     31 # Stage 2
---> 32 X = convolutional_block(X, f = 3, filters = [64, 64, 256], s = 1)(X)
     33 X = identity_block(X, 3, [64, 64, 256])(X)
     34 X = identity_block(X, 3, [64, 64, 256])(X)

TypeError: 'KerasTensor' object is not callable

“convolutional_block” is a function, and you already provided X as a parameter. So you don’t need the (X) at the end.

I removed the (X) at the end, but I still get the error as in stages 1 and 2 (which are outside “start code here”). Also at the end, (AVGPool) it says to use “X = AveragePooling2D()(X)”

Please post a screen capture image that shows the error message.

That’s the same error we already discussed.

I meant that I still get the same error. The error message says or points to Stage 2 as having the error

sorry for the confusion

When you delete the (X), that error will go away.

Please post a screen capture image that shows the results after you delete the (X).

I removed the (X) here


and the error is still the same here:
Screenshot 2023-12-16 212845

I’m not following your reasoning here: if it’s an error in one place, then it’s also an error if you do the same thing in another place, right? It’s not that way in my notebook in the template portions, so you must have changed it and broken it in that way. If you don’t believe that, I suggest you get a clean copy and compare.

If you removed it, then why does it still appear in your error message?

I think the issue is that you added (X) to Stage 2, which you should not have modified.

image

The (X) are not there in the original notebook.
This is because convolutional_block() and identity)_block() are functions, not layers. So you pass X within the parameter list.

And you should not modify the code outside of the START CODE HERE areas.

Thanks, I was able to finish it. It seems like I modified the code the first time before seeing START CODE HERE

Thanks for your patience with me @paulinpaloalto @TMosh

1 Like