Course 4 Week 2 Programming Assignement 1: BatchNormalization in identity_block throwing ValueError

Hi,
When I run the tests for the identity_block(), I encounter and exception at the BatchNormalization in the second component:

/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/layers/normalization.py in build(self, input_shape)
    285     input_shape = tensor_shape.TensorShape(input_shape)
    286     if not input_shape.ndims:
--> 287       raise ValueError('Input has undefined rank:', input_shape)
    288     ndims = len(input_shape)
    289 

ValueError: ('Input has undefined rank:', TensorShape(None))

I had a similar issue with ZeroPadding2D in the previous week’s assigment and worked around by adding the input_shape parameter (which was a bit hard to figure out because the docs are sparse). Is there something like that I am missing here? My impression was the layers figure out the input shape from the actual input they receive at training time.

Just figured it out. I was missing the call with X after creating the Conv2D object in the previous step.
Conv2D(...) Should have been Conv2D(...)(X)
… the long lines in the notebook without line-wrapping did not help.

2 Likes