Week 2 Assignment 1 Errors

I keep getting this error and am not sure how to fix it other than setting a condition explicitly for this case


if np.all(u == -v):
        return -1

After I get pass that error, I get this error

Pretty sure I implemented cosine similarity correctly. I tried both using numpy’s norm function and coding the norm function using just np.sum and np.sqrt.

What am I doing wrong?

it has syntax error i don’t know whether it is correct or wrong

I don’t see the error. Can you point to the line?

Please do not post your code here.

Do not use the lambda function.

Ok remove the screenshot of my code and am no longer using the lambda function, but I’m still getting that second error above.

Woops kinda embarrassing. I needed parentheses around the denominator. But kinda odd cause I did have those before and was still getting errors. Maybe it’s cause I removed the lambda?

That is probably the reason.