# Get\_sub\_volume function misunderstanding in C1M3\_Assignment

**URL:** <https://community.deeplearning.ai/t/get-sub-volume-function-misunderstanding-in-c1m3-assignment/113595>\
**Category:** AI for Medical Diagnosis\
**Tags:** week-module-3\
**Created:** [March 29, 2022, 6:21am UTC](https://community.deeplearning.ai/t/get-sub-volume-function-misunderstanding-in-c1m3-assignment/113595 "2022-03-29T06:21:49Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![gautamaltman](https://avatars.discourse-cdn.com/v4/letter/g/c0e974/32.png) [@gautamaltman](https://community.deeplearning.ai/u/gautamaltman)\
**Post date:** [March 29, 2022, 6:21am UTC](https://community.deeplearning.ai/t/get-sub-volume-function-misunderstanding-in-c1m3-assignment/113595/1 "2022-03-29T06:21:49Z")

</div>

Hi there, I’m having trouble getting through the get\_sub\_volume() function and wonder if anyone had a similar issue? I am not sure I understand the instructions for computing the numerator of the background ratio. There is a lot of edits to make in this function, and it would probably be easiest if a mentor/kind samaritan could check my code. I have due diligence rereading all the instructions and searching for other learners questions. Thanks so much in advance!

---

<div class="post-metadata">

**Author:** ![Mubsi](https://sea1.discourse-cdn.com/dlai/user_avatar/community.deeplearning.ai/mubsi/32/94983_2.png) [@Mubsi](https://community.deeplearning.ai/u/Mubsi)\
**Post date:** [March 29, 2022, 7:12am UTC](https://community.deeplearning.ai/t/get-sub-volume-function-misunderstanding-in-c1m3-assignment/113595/2 "2022-03-29T07:12:00Z")

</div>

Hi @gautamaltman,

An update has been made to the assignment in this regard.

Cheers,  
Mubsi

---

<div class="post-metadata">

**Author:** ![gautamaltman](https://avatars.discourse-cdn.com/v4/letter/g/c0e974/32.png) [@gautamaltman](https://community.deeplearning.ai/u/gautamaltman)\
**Post date:** [March 29, 2022, 7:54am UTC](https://community.deeplearning.ai/t/get-sub-volume-function-misunderstanding-in-c1m3-assignment/113595/3 "2022-03-29T07:54:49Z")

</div>

Great! I look forward to seeing the update!

---

<div class="post-metadata">

**Author:** ![gautamaltman](https://avatars.discourse-cdn.com/v4/letter/g/c0e974/32.png) [@gautamaltman](https://community.deeplearning.ai/u/gautamaltman)\
**Post date:** [March 30, 2022, 5:12am UTC](https://community.deeplearning.ai/t/get-sub-volume-function-misunderstanding-in-c1m3-assignment/113595/4 "2022-03-30T05:12:59Z")

</div>

I think I still need some assistance, especially when composing the value of y in get\_sub\_volume() In the following section:  
# One-hot encode the categories.  
# This adds a 4th dimension, ‘num\_classes’  
# (output\_x, output\_y, output\_z, num\_classes)  
I think this is the main reason I am getting different results from the expected test results

---

<div class="post-metadata">

**Author:** ![Armin\_Dietz](https://avatars.discourse-cdn.com/v4/letter/a/f0a364/32.png) [@Armin\_Dietz](https://community.deeplearning.ai/u/Armin_Dietz)\
**Post date:** [May 4, 2022, 2:56pm UTC](https://community.deeplearning.ai/t/get-sub-volume-function-misunderstanding-in-c1m3-assignment/113595/5 "2022-05-04T14:56:36Z")

</div>

I am not able to complete the assignment, I am getting errors in the test function, and I am not sure what to adjust, as the description is not clear.

Currently, it states:

> ### Exercise 1 - get\_sub\_volume
> 
> Fill in the function below takes in:
> 
> - a 4D image (shape: [240, 240, 155, 4])
> - its 3D label (shape: [240, 240, 155]) arrays,
> 
> The function returns:
> 
> - A randomly generated sub-volume of size [160, 160, 16]
> - Its corresponding label in a 1-hot format which has the shape [3, 160, 160, 160]

So, the subvolume becomes 3 dimensional (before it was 4D!) What happens to the fourth dimension? In the code, the comments say:

> ```
> # change dimension of X
> # from (x_dim, y_dim, z_dim, num_channels)
> # to (num_channels, x_dim, y_dim, z_dim)
> 
> ```

So here, we still have 4 dimensions. This does not match the description.

Also the label dimension is not correct. It says: [3, 160, 160, 160]. But I guess it should be [3, 160, 160, 16] ?

I am currently creating an output for X with shape: (4, 160, 160, 16) and for y with shape: (3, 160, 160, 16). However, 2 tests pass, 1 test fails. I do not know why? The visualization of the output matches the expected output in the cell below.

---

<div class="post-metadata">

**Author:** ![Quincy\_Rondei](https://avatars.discourse-cdn.com/v4/letter/q/f19dbf/32.png) [@Quincy\_Rondei](https://community.deeplearning.ai/u/Quincy_Rondei)\
**Post date:** [June 11, 2022, 9:10pm UTC](https://community.deeplearning.ai/t/get-sub-volume-function-misunderstanding-in-c1m3-assignment/113595/6 "2022-06-11T21:10:38Z")

</div>

Did you find a solution? It seems I’m getting stuck in a very similar way. (I opened a new thread).

---

<div class="post-metadata">

**Author:** ![Quincy\_Rondei](https://avatars.discourse-cdn.com/v4/letter/q/f19dbf/32.png) [@Quincy\_Rondei](https://community.deeplearning.ai/u/Quincy_Rondei)\
**Post date:** [June 11, 2022, 9:11pm UTC](https://community.deeplearning.ai/t/get-sub-volume-function-misunderstanding-in-c1m3-assignment/113595/7 "2022-06-11T21:11:41Z")

</div>

Did you solve it? I seem to get stuck on the same thing. (I opened a new thread before I found this).
