I implemented the forward prop equation in a straightforward way:
{moderator edit  solution code removed}
The dimensions for my matrices and answer look right. But I am failing the tests. Apparently my calculation works for the first case but does not generalize to the other test cases. But I can’t figure out why. Also confusing is the error about using global variables since I do see any in my function. I thought that maybe I need to account for A^{[1]} = X. But how can I do this with only one line of code? Below is the code and output. Any help would be greatly appreciated.
{moderator edit  solution code removed}
t_A, t_W, t_b = linear_forward_test_case()
t_Z, t_linear_cache = linear_forward(t_A, t_W, t_b)
print("Z = " + str(t_Z))
linear_forward_test(linear_forward)
W = [[ 1.74481176 0.7612069 0.3190391 ]]
A = [[ 1.62434536 0.61175641]
[0.52817175 1.07296862]
[ 0.86540763 2.3015387 ]]
b = [[0.24937038]]
W.shape = (1, 3)
A.shape = (3, 2)
b.shape = (1, 1)
Z.shape = (1, 2)
Z = [[ 3.26295337 1.23429987]]
W = [[ 1.74481176 0.7612069 0.3190391 ]]
A = [[ 1.62434536 0.61175641]
[0.52817175 1.07296862]
[ 0.86540763 2.3015387 ]]
b = [[0.24937038]]
W.shape = (1, 3)
A.shape = (3, 2)
b.shape = (1, 1)
Z.shape = (1, 2)
W = [[ 1.74481176 0.7612069 0.3190391 ]]
A = [[ 1.62434536 0.61175641]
[0.52817175 1.07296862]
[ 0.86540763 2.3015387 ]]
b = [[0.24937038]]
W.shape = (1, 3)
A.shape = (3, 2)
b.shape = (1, 1)
Z.shape = (1, 2)
Error: Wrong shape for variable 0.
Error: Wrong shape for variable 1.
W = [[ 1.74481176 0.7612069 0.3190391 ]]
A = [[ 1.62434536 0.61175641]
[0.52817175 1.07296862]
[ 0.86540763 2.3015387 ]]
b = [[0.24937038]]
W.shape = (1, 3)
A.shape = (3, 2)
b.shape = (1, 1)
Z.shape = (1, 2)
Error: Wrong output for variable 0.
Error: Wrong output for variable 1.
1 Tests passed
2 Tests failed
AssertionError Traceback (most recent call last)
in
3 print("Z = " + str(t_Z))
4
> 5 linear_forward_test(linear_forward)
~/work/release/W4A1/public_tests.py in linear_forward_test(target)
107 ]
108
→ 109 multiple_test(test_cases, target)
110
111 def linear_activation_forward_test(target):
~/work/release/W4A1/test_utils.py in multiple_test(test_cases, target)
140 print(’\033[92m’, success," Tests passed")
141 print(’\033[91m’, len(test_cases)  success, " Tests failed")
→ 142 raise AssertionError(“Not all tests were passed for {}. Check your equations and avoid using global variables inside the function.”.format(target.name))
143
AssertionError: Not all tests were passed for linear_forward. Check your equations and avoid using global variables inside the function.

0 ↩︎