Resnet50 Error. Previous tests passed

I am getting the following error in Resnet50 code:
Operands could not be broadcast together with shapes (15, 15, 512) (8, 8, 512)

It seems that there is an error in convolutional_block code, but I don’t believe that I hard coded any dimensions. All previous functions passed. Do you have any suggestions?

Here is the link to my notebook.

If your identity_block and convolutional_block functions pass their tests, then the most likely possibility is that you have passed the wrong arguments when you call them from resnet50. This whole assignment is an excruciating exercise in proofreading. I suggest you make a very careful march through the instructions in that section and compare them to the code that you actually wrote.

Also please note that no-one else can follow that link to your notebook. Only the course staff can see other students work.

Please post a screen capture image that shows the entire assert stack.

Also, sharing your code isn’t allowed, so posting your link would not be appropriate even if it worked (which it doesn’t).

ValueError Traceback (most recent call last)
in
----> 1 model = ResNet50(input_shape = (64, 64, 3), classes = 6)
2 print(model.summary())

in ResNet50(input_shape, classes)
37
38 ## Stage 3 (≈4 lines)
—> 39 X = convolutional_block(X, f = 3, filters = [128, 128, 512], s = 2)
40 X = identity_block(X, 3, [128, 128, 512])
41 X = identity_block(X, 3, [128, 128, 512])

in convolutional_block(X, f, filters, s, training, initializer)
52
53 # Final step: Add shortcut value to main path (Use this order [X, X_shortcut]), and pass it through a RELU activation
—> 54 X = Add()([X,X_shortcut])
55 X = Activation(‘relu’)(X)
56

/usr/local/lib/python3.6/dist-packages/tensorflow/python/keras/engine/base_layer.py in call(self, *args, **kwargs)
924 if _in_functional_construction_mode(self, inputs, args, kwargs, input_list):
925 return self._functional_construction_call(inputs, args, kwargs,
→ 926 input_list)
927
928 # Maintains info about the Layer.call stack.

/usr/local/lib/python3.6/dist-packages/tensorflow/python/keras/engine/base_layer.py in _functional_construction_call(self, inputs, args, kwargs, input_list)
1096 # Build layer if applicable (if the build method has been
1097 # overridden).
→ 1098 self._maybe_build(inputs)
1099 cast_inputs = self._maybe_cast_inputs(inputs, input_list)
1100

/usr/local/lib/python3.6/dist-packages/tensorflow/python/keras/engine/base_layer.py in _maybe_build(self, inputs)
2641 # operations.
2642 with tf_utils.maybe_init_scope(self):
→ 2643 self.build(input_shapes) # pylint:disable=not-callable
2644 # We must set also ensure that the layer is marked as built, and the build
2645 # shape is stored since user defined build functions may not be calling

/usr/local/lib/python3.6/dist-packages/tensorflow/python/keras/utils/tf_utils.py in wrapper(instance, input_shape)
321 if input_shape is not None:
322 input_shape = convert_shapes(input_shape, to_tuples=True)
→ 323 output_shape = fn(instance, input_shape)
324 # Return shapes from fn as TensorShapes.
325 if output_shape is not None:

/usr/local/lib/python3.6/dist-packages/tensorflow/python/keras/layers/merge.py in build(self, input_shape)
110 else:
111 shape = input_shape[i][1:]
→ 112 output_shape = self._compute_elemwise_op_output_shape(output_shape, shape)
113 # If the inputs have different ranks, we have to reshape them
114 # to make them broadcastable.

/usr/local/lib/python3.6/dist-packages/tensorflow/python/keras/layers/merge.py in _compute_elemwise_op_output_shape(self, shape1, shape2)
83 raise ValueError(
84 'Operands could not be broadcast ’
—> 85 'together with shapes ’ + str(shape1) + ’ ’ + str(shape2))
86 output_shape.append(i)
87 return tuple(output_shape)

ValueError: Operands could not be broadcast together with shapes (8, 8, 512) (15, 15, 512)

Hmmmm, well maybe my previous theory is incorrect. That seems to be the first invocation of conv block in your code and your arguments look correct to me. Note that it fails at the step that adds the shortcut with the dimension mismatch. Are you sure you passed all the tests for the conv block?

Yes, I did. I have restarted and cleared output of the kernel and rerun, and I still pass the tests for convolutional_block.

Ok, maybe it is time to look at your code, but there is a way we can do that privately. Please check your DMs for a message from me.