The vector of all partial derivatives — direction of steepest ascent
The gradient is what every optimizer actually uses. When you call loss.backward() in PyTorch, it computes the gradient of the loss with respect to every parameter. The gradient vector is the complete answer to "which direction makes the loss increase the fastest?" — and you walk in the opposite direction to minimize it.
Think of the gradient as a compass for a hilly landscape with millions of dimensions. It points uphill — in the direction of steepest increase. Flip it and you get the direction of steepest descent. Each component tells you the slope in one parameter's direction.
The gradient always points perpendicular to contour lines (lines of equal loss). To descend most efficiently, follow the negative gradient.
For a function f(w₁, w₂, ..., wₙ) with n parameters, the gradient is a vector of all partial derivatives:
The gradient has the same shape as the parameter vector — one number per parameter. For a network with 10 million weights, the gradient is a 10-million-dimensional vector.
For logistic regression with sigmoid output σ(z) and binary cross-entropy loss:
Beautifully simple: the gradient is just how wrong your prediction is. If σ(z) = 0.9 and y = 0, gradient = 0.9 — large, because you were very wrong. This is why cross-entropy + sigmoid is the standard for binary classification.