I am working on this assignment
First practice lab for week 1
I think there is a bug in this unit test
# UNIT TESTS
test_c2(my_dense)
I have been trying to debug the code it is testing and have tried the following print statements (without revealing my code)
print(W[:,unit])
print(a_in)
print(np.dot([0.1,0.4],[0.1,0.2]))
print(np.dot(np.array([0.1,0.4]),np.array([0.1,0.2])))
print(0.1*0.1+0.4*0.2)
The following cell runs this
# Quick Check
x_tst = 0.1*np.arange(1,3,1).reshape(2,) # (1 examples, 2 features)
W_tst = 0.1*np.arange(1,7,1).reshape(2,3) # (2 input features, 3 output features)
b_tst = 0.1*np.arange(1,4,1).reshape(3,) # (3 features)
A_tst = my_dense(x_tst, W_tst, b_tst, sigmoid)
print(A_tst)
When I run the following cell, the first few lines of my output are
[0.1 0.4]
[0.1 0.2]
0.09000000000000001
0.09000000000000001
0.09000000000000001
These are all correct answers for this dot product. And clearly the dot product is running successfully for non-square matricies.
But when I run the unit test, I get this error
AssertionError Traceback (most recent call last)
<ipython-input-33-b4cce73b9594> in <module>
1 # UNIT TESTS
2
----> 3 test_c2(my_dense)
~/work/public_tests.py in test_c2(target)
41 assert A_tst.shape[0] == len(b_tst)
42 assert np.allclose(A_tst, [10., 20.]), \
---> 43 "Wrong output. Check the dot product"
44
45 b_tst = np.array([3., 5.]) # (2 features)
AssertionError: Wrong output. Check the dot product
I’ve tried changing around the names of my variables a bit in case that’s the issue, but I’m not finding exactly what the assertion error is. I put back my variable names as they were.
This is definitely the correct dot product, especially based on checking this math with the printed output. That trailing one at the end of the decimal is called roundoff error, but shouldn’t make a difference to a well-constructed unit test. It’s a fact of how computers do arithmetic.
I do believe this is a bug in the unit test. Can anyone help?
Edit: I just double checked and it is definitely two features. Not only is it definitely two features based on its characteristics, but it says so in the code I’m running to test that was provided but also in the unit test error.
Thanks,
Steven