The cost function calculated by my code is nearly the same as the expected output. But the test function throws an assertion error (seen in image).
Is this issue with np.isclose function?
The cost function calculated by my code is nearly the same as the expected output. But the test function throws an assertion error (seen in image).
Is this issue with np.isclose function?
Notice that your 0.692xxxx value differs from the “expected value”. An error in the 3rd decimal place is not a rounding error: it is a real error. My guess is that this means you just used the code they gave you as the complete solution. It was not intended as that, which they actually said in the instructions. Please compare your code to the math formula for the cost shown in the instructions and then ask yourself two questions:
Note that the “isclose” case is comparing 0.544xxx to 0x.764xxx.
Thanks for the feedback. I had a typo in my cost function which reduced the value of the cost. But the value would not have been so close if I had just used the given code as the complete solution
Glad to hear that you found the problem! You might be surprised about the value that you get from using just the sample code that they give you. Here’s what it is:
cost = 0.6926858869721941
It is very unfortunate that they happened to choose the test cases in such a way that the answer you get with partial code looks so close. It is different from the answer you show, though, so I believe your statement that your mistake was different. But you can see now why I jumped to that conclusion when I saw the 0.692xxxx.