Week 3, assignment, Exercise 4, why error?

Hello,

I did the below code for Exercise 4, and the results exactly match the expected outcome, but why does it says Test Failed? Can anyone help how to fix please?

{Moderator Edit: Solution Code Removed}


Here again, you have posted this under DLS Course 1, but this is not the way it looks in DLS Course 1 Week 3. I am guessing you are taking Math for Machine Learning.

Notice that you are using elementwise product in the linear activation part of the calculation. The math formula is

Z = W \cdot X + b

But * is elementwise multiply. You need np.dot there.

I don’t know how this is structured in your course, but in DLS we also need to apply an activation function to the linear result.

I guess this is the first course of M4ML. I am moving the category. But you need to read this, so, in future, you post your query in the correct category.

As Paul mentioned, you need to use dot product. And, here we are using a linear activation function so your implementation of Y_hat is correct. Just look out for the Z.

Best,
Saif.

PS: Posting your code is not allowed, so I am deleting it after this reply.

Thank you for the tips, helped resolve my error. Once again, why do we have to use np.dot instead of W*x please? Not clear why

A dot product computes the sum of the products of all of the elements.
An element-wise product just does the multiplication, but not the sum.

The equation you’re implementing requires a sum.

thank you so much you solved my problem also