# Image Segmentation\_Unet \_v2 Conv\_block code

**URL:** <https://community.deeplearning.ai/t/image-segmentation-unet-v2-conv-block-code/19164>\
**Category:** Convolutional Neural Networks\
**Tags:** coursera-platform\
**Created:** [July 5, 2021, 2:32am UTC](https://community.deeplearning.ai/t/image-segmentation-unet-v2-conv-block-code/19164 "2021-07-05T02:32:47Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![Askhan](https://avatars.discourse-cdn.com/v4/letter/a/f9ae1b/32.png) [@Askhan](https://community.deeplearning.ai/u/Askhan)\
**Post date:** [July 5, 2021, 2:32am UTC](https://community.deeplearning.ai/t/image-segmentation-unet-v2-conv-block-code/19164/1 "2021-07-05T02:32:47Z")

</div>

I am getting error in the conv\_block, I can not figure out where the problem is. I am including a copy of the script and the error messages, please help me to find out the problem. Thanks

---

<div class="post-metadata">

**Author:** ![TMosh](https://sea1.discourse-cdn.com/dlai/user_avatar/community.deeplearning.ai/tmosh/32/9321_2.png) [@TMosh](https://community.deeplearning.ai/u/TMosh)\
**Post date:** [July 5, 2021, 2:55am UTC](https://community.deeplearning.ai/t/image-segmentation-unet-v2-conv-block-code/19164/2 "2021-07-05T02:55:34Z")

</div>

Don’t use hard-coded values unless you’re told to specifically.  
So, don’t use 32, use “n\_filters”.  
Check for those types of problems.

Also, please edit your message and remove the code. Posting your code breaks the course Honor Code.

---

<div class="post-metadata">

**Author:** ![TMosh](https://sea1.discourse-cdn.com/dlai/user_avatar/community.deeplearning.ai/tmosh/32/9321_2.png) [@TMosh](https://community.deeplearning.ai/u/TMosh)\
**Post date:** [July 5, 2021, 2:56am UTC](https://community.deeplearning.ai/t/image-segmentation-unet-v2-conv-block-code/19164/3 "2021-07-05T02:56:39Z")

</div>

Also, instead of posting your code, just post any error messages you get from the unit tests.  
Those are usually enough to point to the problem in your code.

---

<div class="post-metadata">

**Author:** ![Askhan](https://avatars.discourse-cdn.com/v4/letter/a/f9ae1b/32.png) [@Askhan](https://community.deeplearning.ai/u/Askhan)\
**Post date:** [July 5, 2021, 2:59am UTC](https://community.deeplearning.ai/t/image-segmentation-unet-v2-conv-block-code/19164/4 "2021-07-05T02:59:10Z")

</div>

Thanks. I will try to edit the message.

---

<div class="post-metadata">

**Author:** ![TMosh](https://sea1.discourse-cdn.com/dlai/user_avatar/community.deeplearning.ai/tmosh/32/9321_2.png) [@TMosh](https://community.deeplearning.ai/u/TMosh)\
**Post date:** [July 5, 2021, 3:02am UTC](https://community.deeplearning.ai/t/image-segmentation-unet-v2-conv-block-code/19164/5 "2021-07-05T03:02:12Z")

</div>

You should have a “pencil” icon in the toolbar below your message. That’s the ‘edit’ tool.  
If you don’t see it, let me know and I can edit your message.

---

<div class="post-metadata">

**Author:** ![Askhan](https://avatars.discourse-cdn.com/v4/letter/a/f9ae1b/32.png) [@Askhan](https://community.deeplearning.ai/u/Askhan)\
**Post date:** [July 5, 2021, 4:00am UTC](https://community.deeplearning.ai/t/image-segmentation-unet-v2-conv-block-code/19164/6 "2021-07-05T04:00:06Z")

</div>

Thanks Mosh for the suggestions. I removed the code as you suggested.

The error is as following:  
Test failed  
Expected value

[‘Conv2D’, (None, 96, 128, 1024), 28672, ‘same’, ‘relu’, ‘HeNormal’]

does not match the input value:

[‘Conv2D’, (None, 96, 128, 32), 896, ‘same’, ‘relu’, ‘HeNormal’]

---

<div class="post-metadata">

**Author:** ![TMosh](https://sea1.discourse-cdn.com/dlai/user_avatar/community.deeplearning.ai/tmosh/32/9321_2.png) [@TMosh](https://community.deeplearning.ai/u/TMosh)\
**Post date:** [July 5, 2021, 4:22am UTC](https://community.deeplearning.ai/t/image-segmentation-unet-v2-conv-block-code/19164/7 "2021-07-05T04:22:08Z")

</div>

Most likely, in the first Conv2D layer, either your “filters=…” argument is wrong, or your “kernel\_size=…” is wrong.

Be sure you use the identifiers for the arguments, because if you leave them out, you’re just relying on getting them in exactly the correct order.

---

<div class="post-metadata">

**Author:** ![TMosh](https://sea1.discourse-cdn.com/dlai/user_avatar/community.deeplearning.ai/tmosh/32/9321_2.png) [@TMosh](https://community.deeplearning.ai/u/TMosh)\
**Post date:** [July 5, 2021, 4:32am UTC](https://community.deeplearning.ai/t/image-segmentation-unet-v2-conv-block-code/19164/8 "2021-07-05T04:32:49Z")

</div>

Another problem might be with embedding comments inside the argument definition. Try taking those out.

---

<div class="post-metadata">

**Author:** ![paulinpaloalto](https://sea1.discourse-cdn.com/dlai/user_avatar/community.deeplearning.ai/paulinpaloalto/32/187_2.png) [@paulinpaloalto](https://community.deeplearning.ai/u/paulinpaloalto)\
**Post date:** [July 5, 2021, 7:33pm UTC](https://community.deeplearning.ai/t/image-segmentation-unet-v2-conv-block-code/19164/9 "2021-07-05T19:33:41Z")

</div>

This was also asked and answered on [this other parallel thread.](https://community.deeplearning.ai/t/image-segmentation-unet-v2/19056/3) The bug is that you must be hard-coding the value of the number of filters to 32 instead of using the parameter that was passed in.

Oh, sorry, I see that @TMosh already also gave this answer earlier on this thread. So it’s been covered! 🤓

---

<div class="post-metadata">

**Author:** ![TMosh](https://sea1.discourse-cdn.com/dlai/user_avatar/community.deeplearning.ai/tmosh/32/9321_2.png) [@TMosh](https://community.deeplearning.ai/u/TMosh)\
**Post date:** [July 6, 2021, 7:08am UTC](https://community.deeplearning.ai/t/image-segmentation-unet-v2-conv-block-code/19164/10 "2021-07-06T07:08:19Z")

</div>

Note also that in the “conv10 = …” layer, you don’t use n\_filters there.
