Hey guys! So i’ve been learning, and prepare before taking the quiz itself. So, i’ve calculate for the w, X, b, Y to see if it’s correct that it can make the w and b better. But i think that i calculate it wrong and it always happen all the time like when i get the negative slope, the w is in the condition where it’s positive. What i mean is that i get negative slope even if the w is largely positive, or is that how it supposed to work? I calculate it in manually, where i set the w, X, b, and Y value. Is there anybody that can help me to calculate the step to make w and b better and the example like the example below? Sorry if my english is bad.

Here is the Example (Tell me if this formula is wrong, it would help me.):

w = …

X = …

b = …

Y = …

a = …

Z = w.TX + b

A = g(Z)

dZ = A - Y

dw = 1/m * X * dZ.T

db = 1/m * sum(dZ)

w := w - a * dw

b := b - a * db

It looks like you are using elementwise multiply in a couple of places where you should be using dot product style matrix multiply. E.g. the formula for dw in mathematical terms is this:

dw = \displaystyle \frac {1}{m} X \cdot (A - Y)^T

Here’s a thread about the notational conventions that Prof Ng uses for matrix multiplication.

Oh, ok thanks! Now, i have a request for you, and if you decline it, it is okay. Can you do this calculation for me? Because i just want to know the example and wanted to see what mistake i was involved in.

If you mean to write the code for you, that would be against the rules. When you submit any of the assignments, you are supposed to be submitting your own work.

If you mean showing the output values with a given set of inputs, I could do that. But the better thing is for you to just do the Logistic Regression Assignment. In the notebook, they give you test cases with output, so you can check your code.

Oh i meant the given input with the output. I didn’t meant for the code. Sorry for the misunderstanding. And i haven’t do the assignment and the quiz and haven’t finished watching lectures. I’m just curious about the calculation. But it’s fine if you could do showing the output values with given set of inputs. It would definitely helped me!

You’ll see all that when you do the assignment, but I can pull a few examples from there if you want to get a head start on that:

```
w = np.array([[1.], [2]])
b = 1.5
X = np.array([[1., -2., -1.], [3., 0.5, -3.2]])
Y = np.array([[1, 1, 0]])
grads, cost = propagate(w, b, X, Y)
print(f"cost = {cost}")
```

So that block of code defines the input values and then runs forward and backward propagation and prints the various output values:

```
A = [[0.99979657 0.62245933 0.00273196]]
dw = [[ 0.25071532]
[-0.06604096]]
db = -0.1250040450043965
cost = 0.15900537707692405
```

So you can see that there are two input features and 3 input samples, because X is 2 x 3.

Okay, Thanks for your help!

Oh, and one more thing. Can you tell me what value is positive slope and negative slope? Thanks for your help again!

I think that was already answered on another thread. Rashmi gave you the link to this post, but please also read my later replies on that thread.