C2_W1_Assignment: error message

I finished the Practice Lab of Week 1. Everything looks OK but I received an error as below. My code passed the previous test correctly. I don’t know why.

UNIT TESTS

test_c3(my_dense_v)

AssertionError Traceback (most recent call last)
in
1 # UNIT TESTS
----> 2 test_c3(my_dense_v)

~/work/public_tests.py in test_c3(target)
70 assert A_tst.shape[0] == len(b_tst)
71 assert np.allclose(A_tst, [10., 20.]),
—> 72 “Wrong output. Check the dot product”
73
74 b_tst = np.array([3., 5.]) # (2 features)

AssertionError: Wrong output. Check the dot product

Your code needs to do these three things.

  • Compute the matrix product of A_in and W.
  • Add b.
  • Use the ‘g()’ function and assign the result to A_out.

If you choose to, it can be done in one line of code.

I used sigmoid() function instead of g().

It worked for the first quick check but failed the Unit Test. I still don’t know why.

I replaced the sigmoid() with g() and it passed the test.

Thanks!

To check if you are using g( ) correctly, the unit test uses a different activation function.

I got the same error in the unit test when I did not use np broadcast in the code.

def my_dense_v(A_in, W, b, g):
    """
    Computes dense layer
    Args:
      A_in (ndarray (m,n)) : Data, m examples, n features each
      W    (ndarray (n,j)) : Weight matrix, n features per unit, j units
      b    (ndarray (1,j)) : bias vector, j units  
      g    activation function (e.g. sigmoid, relu..)
    Returns
      A_out (tf.Tensor or ndarray (m,j)) : m examples, j units
    """
### START CODE HERE ### 

# moderator edit: code removed
    
### END CODE HERE ### 
    return(A_out)

But if I replace np.tile with broadcast, I pass the unit test without any error:

### START CODE HERE ### 
 # moderator edit: code removed
### END CODE HERE ### 

Sorry, I do not know exactly what you are asking about.

I would really like to see a screen capture image of the error message.

Note: Personally I don’t like using the @ operator, because it doesn’t clearly define what operation is being done. I prefer using np.matmul().

In your code, I’d use another set of parenthesis to be sure that ‘b’ is being added after the product is computed.

In the future, please don’t post your code on the forum. That’s not allowed by the Code of Conduct.

I was not aware of the Code of Conduct and did not know that I should not post my code on the forum. Can you share the link to the Code of Conduct or elaborate why we should not post our code on the forum?

Try using the forum Search tool for “Code of Conduct”.
You’ll find this topic: