For the first notebook, I am not getting the expected cost

This is the expected output

#### Expected output

```
The cost after training is 0.67094970.
The resulting vector of weights is [4.1e-07, 0.00035658, 7.309e-05]
```

and this is what I am getting

The cost after training is 0.71624400.

The resulting vector of weights is [-7.3e-07, -0.00026687, -0.00025438]

I played around with the learning rate, but to no avail. I think it is messing with the rest of my questions.

Please let me know if you need any more information to help you help me!

Thank you,

Sam

#week1

Hi, Samuel.

Welcome to the course! It’s a little hard to know what to say just based on the answers being wrong. There are a number of formulas that you are translating into code. I assume you’ve gone back over them and made sure that 1) you understand what the math formula says and 2) that your code accurately translates what the formula says.

You are worrying me a bit by saying you “played around with the learning rate”: that is just a parameter value that is given to you by the invocation of the function. There is no “playing around” required: the only question is how you use it in the formulas that are shown. It should appear only in the “update the weights” step. You don’t use a hard-coded value: you use the variable `alpha`

that was passed to you, right?

If you have been over the code carefully and nothing I said above triggers any more thoughts for investigation, then there are other ways we can proceed here by looking at the code. But we can’t do that in a public thread.

Please let me know if what I’ve said above sheds any light and if not, we’ll go to “plan B”.

Regards,

Paul

Thanks Paul!

I will re-examine the code and see if I made any further errors and keep you updated!

Hi sorry for joining this party late

my python is a bit rusty and i m wondering where my mistake could be as im getting this output

The cost after training is 0.34617179.

The resulting vector of weights is [4.1e-07, 0.00035658, 7.309e-05]

#### Expected output

```
The cost after training is 0.67094970.
The resulting vector of weights is [4.1e-07, 0.00035658, 7.309e-05]
....
the next cell (66) i get :
Wrong output for the loss function. Check how you are implementing the matrix multiplications.
Expected: 6.5044107216556135.
Got: 6.497046647278686.
6 Tests passed
2 Tests failed
i m wondering if anybody else encountered similar issue ? i used usual np.dot np.ones, X.T ( numpy) . i m not sure but the type of error reminds me rounding issues ??
sorry im getting old
```

Sorry, but the difference between 0.34xxxx and 0.67xxxx is not a rounding error, even if it is compounded. In 64 bit floating point the resolution is about 10^{-16}. In 32 bit floating point it’s more like 10^{-7} in the mantissa.

There must be some way in which your code does not accurately implement what the math formulas are telling you to do. If that “hint” is not enough to get you there, then maybe it’s time examine your code. We are not supposed to do that in the public forum, but there are private ways to communicate using “DMs” (direct messages). Let me know if you need to go that route and I will message you about how to do it.

Hi, Samuel.

Sorry, I meant to get back and check in with you. Did you figure out what was wrong with your code? If not, then we should do the DM code sharing that I just mentioned to Chris.