Padding or broadcasting errors in Week 2 Exercise 1 Res Nets Identity Block

This is regarding the first exercise (identity block) in Week 2 of Convolutional Neural Networks.
First, I got a broadcasting error in the last (Addition) stage. The input array has shape (4,4,3) and after the 3rd layer of the exercise it is (3,3,3). The problem seemed (to me) to be with padding = “valid” in the 3rd layer (option already present in the exercise). It of course results in shrinking of dimensions 1 and 2.
I changed padding to “same” and did not get the broadcasting error, but then an Assertion Error appeared. “Check padding and strides”.

1 Like

I am answering my own question because I understood my error. The filters in 3rd layer must have kernel size (1,1), not (f,f). Then the valid padding will not reduce the size of the output