Course 4, week 3, Unet, Exercise 3

I got the following error in the test and could not figure out where the problem is. Could some help to point the direction for debug?

ValueError: Layer conv2d_20 expects 1 inputs, but it received 2 input tensors. Inputs received: [<tf.Tensor ‘max_pooling2d_6/MaxPool:0’ shape=(None, 48, 64, 32) dtype=float32>, <tf.Tensor ‘conv2d_19/Relu:0’ shape=(None, 96, 128, 32) dtype=float32>]

Thanks

Which function are you working on? “Exercise 3” isn’t specific enough.

Function: unet_model

Note that the output (return value) of the downsampling blocks is a 2-tuple with 2 tensors. Whereas for the upsampling blocks, the output is a single tensor. Both the downsampling blocks and the upsampling blocks take inputs that are one of the outputs of a downsampling block, right? But it’s a different one in the upsampling case.

1 Like

Thank you for the hint. With this help. The problem is solved.

1 Like

It’s great to hear that you found the solution! Thanks for confirming.

Hello Mr Paul,

I am facing the same error

ValueError: A `Concatenate` layer requires inputs with matching shapes except for the concat axis. Got inputs shapes: [(None, 48, 64, 128), (None, 24, 32, 128)]

Although I am confident I am using the correct expansive_input, contractive_input as

ublock6, cblock3[1]

I am able to pass although previous tests before the function unet_model.

Can you please confirm, if I am thinking correctly?

Thanks

I added a print before that call to see the shape of ublock6 and cblock3[1] and here’s what I get:

ublock6.shape = (None, 12, 16, 256)
cblock3[1].shape = (None, 24, 32, 128)

So it looks like your code must have gone off the rails earlier. Are you sure you are using the correct number of filters in the previous step? Either that or your upsampling block logic must be incorrect. E.g. maybe hard-coding the number of filters so that you just happen to pass the test in the notebook.

Thanks for the suggestion. I will investigate on these lines.

Thanks

Thanks for the guidance. I was using the wrong input in one of the conv_block.

Thanks