C1_W3_Assignment issue with get_sub_volume

I’ve used the Hint’s suggestion, but it didn’t help, still getting the same error:

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.]]


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.]]

Extracting (2, 2, 2) sub-volume

Error: Wrong output. for variable in position 0.
Error: Wrong output. for variable in position 1.

Sampled Image:
z = 0
[[0. 0.]
 [0. 0.]]
z = 1
[[0. 0.]
 [0. 1.]]

Sampled Label:
class = 0
z = 0
[[0. 0.]
 [0. 0.]]
z = 1
[[1. 1.]
 [1. 1.]]
class = 1
z = 0
[[0. 0.]
 [0. 0.]]
z = 1
[[0. 0.]
 [0. 0.]]
 2  Tests passed
 1  Tests failed
---------------------------------------------------------------------------
AssertionError                            Traceback (most recent call last)
<ipython-input-5-d04fa8fc92d0> in <module>()
      1 ### test cell ex1 - do not modify this test cell
----> 2 get_sub_volume_test(get_sub_volume)

~/work/W3A1/public_tests.py in get_sub_volume_test(target)
     68     ]
     69 
---> 70     learner_func_sample_image, learner_func_sample_label = multiple_test_get_sub_volume(test_cases, target)
     71 
     72     print("\033[0m\nSampled Image:")

~/work/W3A1/test_utils.py in multiple_test_get_sub_volume(test_cases, target)
    160         print('\033[92m', success," Tests passed")
    161         print('\033[91m', len(test_cases) - success, " Tests failed")
--> 162         raise AssertionError("Not all tests were passed for {}. Check your equations and avoid using global variables inside the function.".format(target.__name__))
    163 
    164     return learner_func_answer

AssertionError: Not all tests were passed for get_sub_volume. Check your equations and avoid using global variables inside the function.

hi @serko

Go through these thread comments and see if it helps you

Solution 1

Solution 2

Solution 3

Please read each post comments carefully and with your codes, which help you to compare and decide your codes.

Regards
DP

“+ 1” helped from

for the first code line where randomly sample the sub-volume, You are suppose to add + 1 to all the samples which you have not done according to instructions provided before the grade cell.

Thanks!

1 Like