Neural Network Gradients
- 53Unfamiliar
- 0Learning
- 0Familiar
- 0Mastered
- spaceFlip card
- KI knew it
- DI didn't know it
- ←Previous card
- →Next card
Why is finding the effect of an individual weight challenging in a complex neural network?
A weight may be buried in a sequence of layers and nonlinear operations, so its effect on the final loss depends on the entire compound function.
Or swipe the card
53 cards
Why is finding the effect of an individual weight challenging in a complex neural network?
A weight may be buried in a sequence of layers and nonlinear operations, so its effect on the final loss depends on the entire compound function.
How does a finite-difference method approximate the derivative of a function?
It estimates the derivative using [f(x+δ)−f(x)]/δ for a small, nonzero δ, instead of taking the limit as δ approaches zero.
What assumptions does a numerical gradient approximation require?
The function must be defined at both x and x+δ, and its behavior between those points should be reasonably approximated by the change measured across them.
What are the main advantages of numerical gradients?
They are straightforward to understand and implement, widely applicable, and impose few restrictions on the functions being differentiated.
Why is computing numerical gradients impractical for a large neural network?
Each weight must be changed individually and the entire network evaluated to measure the effect. Repeating this for many weights is extremely slow.
When are analytic gradients preferable to numerical gradients?
When they are feasible to derive, analytic gradients provide direct expressions that can be evaluated efficiently.
Why can deriving analytic gradients by hand be problematic for large compound functions?
The algebra becomes difficult and error-prone; a small mistake can invalidate gradients throughout the model.
What earlier models were examples of methods for which gradients or subgradients could be calculated relatively simply?
Linear SVMs, logistic regression, and lasso.
State the chain rule using intermediate variable u.
dy/dx=(dy/du)(du/dx).
How does the chain rule apply to the composition f(g(x))?
Its derivative is f′(g(x))g′(x): evaluate f′ at the output of g, then multiply by the derivative of g at x.
How does the chain rule extend to a sequence of three functions, f(g(h(x)))?
The derivative is f′(g(h(x)))g′(h(x))h′(x), with each local derivative evaluated at the input it receives.
In a computational graph, what do nodes and edges represent?
Nodes represent operations, while edges represent the flow of data between operations.
How does data flow through a graph for the composition g(f(x))?
x enters f, the output f(x) flows into g, and the graph outputs g(f(x)).
How are local derivatives combined to obtain the derivative of a function composition?
Multiply the local derivatives along the path through the graph, evaluating each derivative at its corresponding input.
In what direction are gradients conventionally propagated through a computational graph?
Backward, from the graph's output toward its inputs, even though multiplication of the local gradients is commutative.
How can a nested sequence of operations be represented using intermediate variables?
For example, write b=f(a), then c=g(b), then d=h(c); each operation's output becomes the next operation's input.
For the graph that applies sine and then exponential to x, what is the overall derivative?
The output is exp(sinx), and its derivative is cos(x)exp(sinx).
What sequence of operations produces the sigmoid function from input x?
Negate x, exponentiate it, add one, then take the reciprocal: 1/(1+e−x).
What are the local derivatives of the four operations used to construct the sigmoid?
Negation has derivative −1; exponentiation has derivative equal to its output; adding one has derivative 1; and taking a reciprocal has derivative −1/u2 with respect to its input u.
What derivative results from applying the chain rule to the sigmoid's four-operation sequence?
The derivative is e−x/(1+e−x)2.
Why can chain-rule multiplication be grouped into pairs when computing gradients?
Multiplication is associative, so the local gradients can be multiplied pairwise backward, producing the overall derivative and intermediate gradients along the way.
For the sine-then-exponential function at x=2, what are the approximate output and derivative?
sin(2)≈0.91, so exp(sin(2))≈2.48. The derivative is cos(2)exp(sin(2))≈−1.04.
For the sigmoid built from four operations at input x=1.5, what is the approximate output?
The intermediate values are −1.5, e−1.5≈0.22, and 1+e−1.5≈1.22; the reciprocal gives an output of about 0.82.
For that four-operation sigmoid at x=1.5, what is the approximate overall derivative?
Multiplying the local derivatives backward gives an overall derivative of about 0.15.
For the function σ(xw), what are its gradients with respect to x and w?
If σ′ denotes the sigmoid derivative, then ∂σ(xw)/∂x=wσ′(xw) and ∂σ(xw)/∂w=xσ′(xw).
For σ(xw) with x=−1.2 and w=0.3, what are the approximate output and gradients?
xw=−0.36 and σ(xw)≈0.41. The sigmoid gradient at −0.36 is about 0.24, giving ∂/∂x≈0.07 and ∂/∂w≈−0.29.
Why can gradient calculations use numerical values at each stage rather than carrying full symbolic expressions?
For a particular input and parameter setting, the gradient's numeric value is what is needed to update the model; its full symbolic expression is unnecessary.
What information does a self-contained computational node need to calculate its local gradient?
It needs its own inputs and outputs, plus the local derivative rule for its operation.
How does a node use a downstream gradient to calculate gradients for its own inputs?
It combines the gradient received from downstream with its local derivative, then propagates the resulting input gradients farther backward.
Why does a node not need to know the full structure of the rest of the network?
It only needs its local inputs, outputs, and derivative rule, along with the downstream gradient it receives.
What are the two ingredients needed at each step to propagate a gradient backward?
The operation's local gradient and the gradient arriving from downstream.
How can the boundary of a computational node be chosen?
Node boundaries are flexible: an operation can be broken into simple arithmetic steps or a compound function with a known derivative can be treated as one operation.
What shape does a gradient generally have when differentiating with respect to a vector or matrix?
It has the same shape as the vector or matrix being differentiated with respect to, with partial derivatives aligned to the corresponding elements.
For the scalar inner product z=x⋅w, what are the gradients with respect to the two input vectors?
∇xz=w and ∇wz=x.
In a linear layer, why are gradients with respect to both the input vector and the weight vector useful?
The input gradient is passed backward to upstream nodes, while the weight gradient is used to update the layer's weights.
What is the gradient of an elementwise function applied independently to each vector element?
It is a vector containing the scalar derivative evaluated separately at each corresponding input element.
Why does the softmax function generally require a Jacobian?
It maps a vector to a vector, and each output element depends on all input elements, so its derivatives involve the full Jacobian.
Why can softmax and cross-entropy be bundled into one layer?
Combining them simplifies the gradient, avoiding the need to pass around the many extraneous elements of the softmax Jacobian.
What shape should the gradient have when a layer's weights form a matrix?
The gradient with respect to the weights should be a matrix of the same shape, with a gradient for every weight element.
How can gradients be handled for matrix-valued data in batch or mini-batch processing?
One may pass the full data-matrix gradient or reduce across examples and pass a gradient vector, such as the sum or mean.
Why is the mean gradient often used across a batch instead of the sum?
It is generally more stable and makes gradients more comparable across different batch sizes.
What manages the overall network structure when individual layers are self-contained?
A data structure or class tracks the network and manages communication between layers, either through a traversal function or its own methods.
What happens during the forward pass of a neural network?
Data is propagated from the inputs through the network to its output, following an order in which every node's inputs are available before the node is evaluated.
What is calculated at the end of the forward pass?
The final network output is used to calculate the loss.
What happens during the backward pass?
Starting from the loss, gradients are propagated backward through the network, with each layer combining downstream gradients with its own local derivatives.
When are all network gradients known?
After the backward pass has propagated gradients through the network to its inputs.
What is the distinction between backpropagation and optimization?
Backpropagation calculates gradients; optimization uses those gradients to update model parameters.
What is the repeated training cycle for a neural network?
Run a forward pass, calculate the loss, run a backward pass, update weights using an optimizer, and repeat until a stopping criterion is reached.
Are neural-network loss functions generally convex when the network has hidden layers?
No. Networks with hidden layers are almost always nonconvex. Simple networks without hidden layers can represent logistic or softmax regression, which have convex losses.
What optimization risk can arise from a nonconvex neural-network loss?
Optimization may become stuck in a local minimum rather than reaching a global minimum.
What factors affect how serious local minima are in neural-network optimization?
Their significance depends on the data, network structure, and task being optimized.
What does the term “bad local minimum” refer to?
A local minimum that is a poor approximation of the true global minimum.
What does the described evidence suggest about local minima in some deep-learning applications, such as computer vision?
Although local minima exist, they may not be bad: a local minimum can still be a reasonable approximation of the global minimum.

Ask anything
We've read this whole study set, so questions about it get the best answers.