Get_sub_volume function misunderstanding in C1M3_Assignment

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!

Hi @gautamaltman,

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


Great! I look forward to seeing the update!

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

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.

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

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