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