Course4 Week3 Assignment2 - ValueError

Hi,
It seems that something with my dimensions is wrong, but I can’t find my bug.
This is the line that raises the error:
ublock7 = upsampling_block(ublock6[0], cblock3[1], n_filters*4)

The bottleneck layer is layer number 5, my expansive_input and contractive_input are as follows:
ublock7 = upsampling_block(ublock6[0], cblock3[1], n_filters*4)
ublock8 = upsampling_block(ublock7[0], cblock2[1], n_filters * 2)
ublock9 = upsampling_block(ublock8[0], cblock1[1], n_filters)

I get this error: ValueError: Input 0 of layer conv2d_transpose_4 is incompatible with the layer: : expected min_ndim=4, found ndim=3. Full shape received: [12, 16, 256]
I don’t know how to fix this.

The thing to notice is that the downsampling and upsampling blocks are fundamentally different, not just in what they do internally, but in their output: the downsampling blocks output two separate return values (one for the next downsampling step and one for the “skip” connection), but the upsampling blocks output only one tensor, right? So you need to index the output of the downsampling blocks to pick which of the two outputs you want. But it is a mistake to treat the output of the upsampling blocks in the same way: indexing it just ends up stripping off one of the dimensions of the single output tensor with the unhappy result that you are seeing.

Thank you, solved! :slight_smile: