C1_W3 UNQ_C1 question on test code for "equation_output_check"

My code pass “datatype_check” and “shape_check” and failed on “equation_output_check” which result in “Error: Wrong Output”.

My understand is that our code in function get_sub_volume should return a sub-volume that has background ratio less than background_threashold (default 0.95).

The test image has a 4x4x3, and the ask is to extract 2x2x2.
bgrd_ratio = np.sum(y[:, :, :, 0]) / (output_x * output_y * output_z)
so as long as any of the image label is not 0, we’ll have bgrd_ratio less than 0.95.

label for z=1 and z=2 are all 1 and 2. ( see below). so any of the 2x2x2 will not be all zero, hence will meet the background_threshold requirement.

However, the test code hard-coded to check for the following image set,

expected_output = (np.array([[[[1., 2.],
                               [2., 4.]],
                              [[2., 4.],
                               [4., 8.]]]]), 

which is the center sub-volume and only the certer sub-volume. This logic does not make sense to me since other sub-volume should also pass. Do I misunderstand the problem or some concept? Thank you.

Label:
z = 0
[[0. 0. 0. 0.]
[0. 0. 0. 0.]
[0. 0. 0. 0.]
[0. 0. 0. 0.]]
z = 1
[[1. 1. 1. 1.]
[1. 1. 1. 1.]
[1. 1. 1. 1.]
[1. 1. 1. 1.]]
z = 2
[[2. 2. 2. 2.]
[2. 2. 2. 2.]
[2. 2. 2. 2.]
[2. 2. 2. 2.]]

Image:
z = 0
[[0. 0. 0. 0.]
[0. 0. 0. 0.]
[0. 0. 0. 0.]
[0. 0. 0. 0.]]
z = 1
[[0. 0. 0. 0.]
[0. 1. 2. 3.]
[0. 2. 4. 6.]
[0. 3. 6. 9.]]
z = 2
[[ 0. 0. 0. 0.]
[ 0. 2. 4. 6.]
[ 0. 4. 8. 12.]
[ 0. 6. 12. 18.]]

1 Like

Can you share the codes via personal DM for the particular stack you got this error.

Regards
DP

Hi @sunolbanjo,

After looking at your code, I noticed you added a lot of your own code in the assignment. Feel free to experiment, but don’t do so before your have a successful submission and the desired grade. This will not only mess up your assignment results, but also the autograder.

For example, instead of using np.random.randint, you have used rng.integers, to begin with. Please follow the instructions, use the functions we have asked for before you experiment.

As for your exercise 1,

  • you missed a very important hint:
# hint: make sure to leave enough room for the output dimensions!
# do not remove/delete the '0's
  • don’t hard-code unless specifically asked for.

Best,
Mubsi

P.S I have added a fresh copy of test_utils.py in your workspace and left your edited version as YOUR_test_utils.py

2 Likes

Thank you so much, @Mubsi . Let me investigate further and try again. I appreciate your help

1 Like

I reran the code and it pass now. Looks like the problem was caused by my modification to the test_utils.py. Thank you so much, @Mubsi

1 Like