# Meaning of partial derivative in gradient descent

I haven't quite understood the correct meaning of what it means to take the partial derivative of a cost function with respect to the parameters, say theta. Suppose these parameters include 2 arrays of dimensions axb and cxd.

When we do stochastic gradient descent, then what will be the partial derivative of J wrt theta (let's call it x)? Mathematically this is a symbolic expression. So when I program SGD, what should be the term x.

What happens if J is a scalar, and what happens if J is a matrix? If in any case it is a matrix, what will be its dimensions?

Imagine you're standing outside on a large field, which is sloping, and curved in some manner. Maybe there's a hill, or a local low point somewhere.

Face north, draw a line going due north, and measure (with surveying tools presumably) the slope of the ground where you're standing along that line.

Now face east, and do the same thing in that direction.

Those slopes are the two partial derivatives. If the ground near where you're standing is fairly close to planar (i.e. not too curved) then those two slopes (partial derivatives) tell you which direction is most rapidly going uphill and which direction is most rapidly going downhill.

When we do stochastic gradient descent, then what will be the partial derivative of J wrt theta (let's call it x)? Mathematically this is a symbolic expression. So when I program SGD, what should be the term x.

I think the first thing you need to understand is ordinary gradient descent. Then try to work out what SGD does that is different (which is roughly just that its cost function is composed of a sum over observations of some differentiable function, or a sum of differentiable functions - one for each observation)

What you write in a program depends on $J$. You'll have to be more specific. There's some general details here if that helps focus your question.

Can you also be more specific about the definition of $J$? (Is it the same as $Q$ in the linked article, or is it different?)

What happens if J is a scalar,

J is supposed to be a scalar!

In general, $\theta$ has several components, $\theta=(\theta_1,\theta_2,\ldots,\theta_d)$.

$\frac{\partial J}{\partial \theta_i}$ is a scalar, but $(\frac{\partial J}{\partial \theta_1},\frac{\partial J}{\partial \theta_2},\ldots,\frac{\partial J}{\partial \theta_d})$ is a vector.

what happens if J is a matrix?

In what situation is your cost a matrix?