I got this error in the Unet model exercise, the problem with matching the shapes of blocks, and the skip connections in the upsampling step.
However, I tried multiple things but the error still exists.
For your ublock7
, you are using skip3
but the instruction is:
# Note that you must use the second element of the contractive block i.e before the maxpooling layer.
Do you know how to do this? If I want to get the second element of X
, I will do like X[1]
, indexing starts from 0 in Python.
Okay! I also noticed that your ublock6
is incorrect. Maybe previous blocks are incorrect too. Instruction is clear:
# Use the cblock5[0] as expansive_input and cblock4[1] as contractive_input and n_filters * 8
And, for cblock1, 2, 3, 4, and 5
, instruction is:
# Chain the first element of the output of each block to be the input of the next conv_block.
Please read all the instructions again if still facing any errors.
You’ve written the code in such a way that you’ve already “decomposed” the 2-tuple that is returned by conv_block
. So that means you don’t need to index it to select the first element as you do by saying cblock1[0]
, right? When you do that, it ends up stripping off one of the dimensions of that 4D tensor, which is why that error is being thrown.
Another simple solution is not to change the pre-written code. If you have given this:
cblock1 = conv_block(None, None)
Then your job is to replace the None
with correct terms and not edit other things. As we can see you have edited the left-hand side to cblock1, skip1
(same for other blocks,) hence error occurs. All the instructions given to you are according to the pre-written code. If you change any of the pre-written code, then the instructions will not work.
To simplify this, revert the pre-written code to the original form and follow the instructions.