Week2 : ResNets def convolutional_block

in
11 f = 2,
12 filters = [2, 4, 6],
—> 13 training=False)
14
15 assert type(A) == EagerTensor, “Use only tensorflow and keras functions”

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

/opt/conda/lib/python3.7/site-packages/tensorflow/python/keras/engine/base_layer.py in call(self, *args, **kwargs)
980 with ops.name_scope_v2(name_scope):
981 if not self.built:
→ 982 self._maybe_build(inputs)
983
984 with ops.enable_auto_cast_variables(self._compute_dtype_object):

/opt/conda/lib/python3.7/site-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

/opt/conda/lib/python3.7/site-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:

/opt/conda/lib/python3.7/site-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.

/opt/conda/lib/python3.7/site-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 (2, 2, 6) (4, 4, 6)

I am getting this and not able to figure it out . Any help would be appreciated.Thanks

Hey, can you check the stride you’ve used for the Conv2D layer in the shortcut path with the instructions?

Thanks . Issue got resolved

I got a same error. What did you do to resolve?

check the stride you used in 2nd con2d cross check it