Help with For U-Net Assignment

Trying to finish # UNQ_C3 # GRADED FUNCTION: unet_model

I’m unable to code the Expanding Path (decoding). trying to do that I get: **ValueError: Input 0 of layer conv2d_transpose_16 is incompatible with the layer: : expected min_ndim=4, found ndim=3. Full shape received: [12, 16, 256]

It seems I get stuck following this instruction:

#Chain the output of the previous block as expansive_input and the corresponding contractive block output.

#Note that you must use the second element of the contractive block i.e before the maxpooling layer. # At each step, use half the number of filters of the previous block

I’m trying to up sampling the previous block as expansive_input, from my understanding this is the last conv_block first element but I’m unable to understand what you mean with "the corresponding contractive block output."

Please can you elaborate those comments? Thanks!


On the contractive path, each layer has two outputs, right? The second one is intended for the “Shortcut” path to the expanding layer. The instructions aren’t so clear on this, but the easiest way to “get the picture” is to study the diagram they show of how U-Net is constructed.

I’m also a little worried that you may have “indexed off” one of the elements of the expansive output when you use it as input to the following layer. The expansive layers only have one output, so you don’t need to “index off” either the first or second as you do with the contractive layers.

1 Like

Thanks very much for your support!

1 Like

on the indexing, i a bit confused, is the index is always 0 for first parameter and 1 for second parameter while using upsampling_block

Please read my previous reply on this thread. The upsampling blocks are fundamentally different in that they produce only one output, right? So you don’t need to index the output of the upsampling block. So the first input to any upsampling block (other than the first one) is the output of the previous upsampling block. For the second input to the upsampling blocks, it is the second output of the corresponding contractive block (conv_block).