When creating a post, please add:
- Week 2
- I manually calculate
dj_dw
wrt w1 , I found that there is nothing to adderr
When creating a post, please add:
dj_dw
wrt w1 , I found that there is nothing to add err
I’m pretty sure you did use the same method when w was a scalar.
@TMosh is right that the fundamental idea of calculating the gradient is the same whether w is a scalar (single-variable) or a vector (multivariable). The difference is in the number of features you’re dealing with.
Here’s how it would look,
\text{err} = (w \cdot X[i] + b) - y[i] ,
in the single-variable case,
\frac{\partial J}{\partial w} = \frac{1}{m} \sum_{i=1}^{m} \text{err} \cdot X[i] ,
and the multivariable case,
\frac{\partial J}{\partial w_j}= \frac{1}{m} \sum_{i=1}^{m} \text{err} \cdot X[i,j] .