Image_segmentation_Unet_v2 - shapes issues in unet_model

Hi all :slight_smile:

I keep getting the following error in the unet function:

Test failed 
 Expected value 

 ['Conv2D', (None, 96, 128, 23), 759, 'same', 'linear', 'GlorotUniform'] 

 does not match the input value: 

 ['Conv2D', (None, 96, 128, 32), 1056, 'same', 'linear', 'GlorotUniform']
AssertionError                            Traceback (most recent call last)
<ipython-input-14-4a1225a2a898> in <module>
      6 unet = unet_model((img_height, img_width, num_channels))
----> 7 comparator(summary(unet), outputs.unet_model_output)

/tf/W3A2/ in comparator(learner, instructor)
     17                   "\n\n does not match the input value: \n\n",
     18                   colored(f"{a}", "red"))
---> 19             raise AssertionError("Error in test")
     20     print(colored("All tests passed!", "green"))

AssertionError: Error in test

I thought I had the shapes figured out - the conv_block function takes only the first element of each previous block as input; the upsampling_block function takes the previous ublock6 and the second element of the cblock as input (trying to describe this in words and not post my code here :wink: ). I’ve been playing around with the filter of conv_block(cblock4…) a bit, because I wasn’t sure if it should be n_filters16 or n_filters8. But neither of them gets the correct result.

I’m not sure where the error might be and am grateful for any hints!
If you want me to post code for easier debugging, let me know :slight_smile:

Do not post your code.

The five conv_block() layers use n_filters with multipliers of 1, 2, 4, 8, and 16.
The last two also have dropout values as given in the instructions.

1 Like

Thanks for the quick reply! Ok cool, so those are exactly the values that I have that gave me the above error message (and also included the dropout). What could be another source of error?

In the conv10 = … layer, did you use filters = n_classes? Or did you use n_filters there?

1 Like

That did the trick, don’t know how I missed that. Thank you - you guys are really helpful! :slight_smile:


had the same problem - i had assigned cblock5 with 8x n_filters instead of 16. thanks!