C1_W3_Assignment - stuck with get_sub_volume

Hi

the test function get_sub_volume_test(get_sub_volume) returns:

Extracting (2, 2, 2) sub-volume

Error: Data-type mismatch.
Error: Wrong shape.
Error: Wrong output.

UnboundLocalError Traceback (most recent call last)
in ()
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)
144 print(“\033[92m All tests passed.”)
145 else:
→ 146 learner_func_sample_image, learner_func_sample_label = learner_func_answer
147
148 print(“\033[0m\nSampled Image:”)

UnboundLocalError: local variable ‘learner_func_answer’ referenced before assignment

Thanks for your help
M

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: Data-type mismatch.
Error: Wrong shape.
Error: Wrong output.

Hi @grizbi

Thank you for following community guidelines. Also the reason I told you to share your error because error might look similar but reason for your error output might not be same to other who have got same error type.

You are incorrectly recalling codes for

#change in dimension of X

#change in dimension of y

as you use the transpose function you are suppose to mention the axis and not use value dimension x, y and z.

Regards
DP

posting codes is against community guidelines

I tried this instead but no more lucky with that

Please don’t post code here, it is against community guidelines, rather share what error it still threw

also when you send codes in DM or post an error here, a better choice is to share a screenshot rather than copy paste as some of the syntax error gets missed out with copy paste.

There is probably more error to lookout for if you continue to get error

for one-hot encode the categories, you are suppose to use

keras.utils.to_categorical

Also while calculating bgrd_ratio, you are suppose to mention the axis for dimension specification

Hi, I keep getting the same error. Were you able to fix it, and how?

Thanks!

i keep getting this error:
"AssertionError Traceback (most recent call last)
in ()
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."

could you help me figure out why, please?

I was also wondering if there is an option to grade the assignment if all the other tests are passed, just this first one missing one. I tried but it says grade 0% even though everything else has passed

hi @tenoriosilvia24

Always create new post rather than commenting on an older thread.

Your error is telling in one of the function you are using global variable instead of local variables, i.e. you are suppose to call the variable for that particular grade cell according to call arguments assigned.

You can DM me codes. Click on my name and then message.

Regards
DP