Training Neural Networks
- 99Unfamiliar
- 0Learning
- 0Familiar
- 0Mastered
- spaceFlip card
- KI knew it
- DI didn't know it
- ←Previous card
- →Next card
What are the main parts of a neural network training setup?
Input data x passes through parameterized layers to produce a prediction, which is compared with ground truth y to calculate a loss.
Or swipe the card
99 cards
What are the main parts of a neural network training setup?
Input data x passes through parameterized layers to produce a prediction, which is compared with ground truth y to calculate a loss.
What does it mean for a neural network to learn its parameters?
Training adjusts the parameter values so the model’s predictions become closer to the ground truth on available data.
What is the objective when training a model with parameters θ?
Find parameters θ∗ that minimize a cost function over the available data.
How are loss and cost distinguished in the lecture?
Loss refers to an error measure over data points; cost can refer to the overall aggregation of those losses. The terms are sometimes used loosely.
What does the cost function J(θ) represent in the training setup?
It represents the aggregate objective, such as the sum of individual losses over the training dataset.
What information about J(θ) can be used for optimization?
Its value can be evaluated for a given θ, and its gradient can be evaluated to indicate how the cost changes with the parameters.
What is the Hessian, and how commonly is it used in neural-network training?
The Hessian contains second-order derivatives of the cost. It is usually not calculated in practice; training commonly relies on first-order gradients.
What does the gradient indicate when optimizing a cost function?
It gives the direction of steepest increase locally; to reduce the cost, gradient descent steps in the opposite direction.
What is the role of a learning rate in gradient descent?
The learning rate η controls the size of each parameter update.
Write the basic gradient-descent parameter update.
θk+1=θk−η∇θJ(θk)
Why might training stop even when the model has not reached a known global optimum?
Training may stop when progress plateaus, often monitored using a validation set; the global optimum is generally not guaranteed.
What is a batch in stochastic gradient descent?
A batch is a subset of the training data used to estimate the gradient for an update.
What does batch size 1 mean, and what can be a drawback?
The parameters are updated after each individual example. This can make updates computationally inefficient.
What does a batch size equal to the full dataset produce?
Standard gradient descent, using the gradient over the entire dataset for each update.
Why is using the full dataset for every gradient update often impractical?
Large datasets can make full-dataset gradient calculations too slow or too demanding for available memory and computation.
Why can stochastic-gradient estimates differ from the full-dataset gradient?
A batch is only a sample of the data, so its gradient may be noisy or unrepresentative of the overall gradient.
How can class imbalance affect stochastic-gradient updates?
Some categories may be absent from several batches and then appear, causing abrupt shifts in the estimated gradient and unstable updates.
What are two advantages of stochastic gradient descent?
It can be faster than computing gradients over the full dataset, and its noise can act as an implicit regularizer that may help escape local minima.
What are two disadvantages of stochastic gradient descent?
Its gradient estimates can have high variance, and its updates can be unstable.
What is momentum in gradient descent?
Momentum biases the current update toward the direction of previous updates, carrying information about past movement.
What does the momentum hyperparameter control?
The momentum coefficient, often denoted α, controls the strength of the contribution from past updates.
How can an appropriate amount of momentum help optimization?
It can move parameters toward a minimum faster by reinforcing progress in a consistent direction.
What can happen if momentum is too large?
Updates can overshoot the minimum and oscillate around it, slowing optimization.
What is Adam in relation to momentum and optimization?
Adam is a commonly used optimizer that incorporates a form of momentum.
What is an evolution strategy for minimizing loss?
It samples small perturbations around current parameter values and moves toward perturbations that produce lower loss.
How can evolution strategies help when gradient-based optimization struggles?
Sampling perturbed parameter values can reveal lower-loss directions even in regions where gradients provide little useful signal.
What is gradient clipping?
A method that limits gradients above a chosen threshold by scaling them back, preventing excessively large updates.
How can gradient clipping help with a steep or pointy loss landscape?
It limits how far a parameter update can move, reducing overshooting and oscillation caused by large gradients.
What are three properties that can make a loss or optimization function easier to optimize?
Being everywhere continuous, everywhere differentiable, and everywhere smooth can make optimization easier, though these properties are not all required.
What characterizes a convex loss landscape with a single minimum?
There is one minimum, gradients point toward it, and the gradient decreases toward zero as the minimum is approached.
Why can a non-convex loss landscape make optimization difficult?
It can contain multiple local minima, so the result may depend on initialization and need not be the global minimum.
What is a local minimum, and how does it differ from a global minimum?
A local minimum is lower than nearby points; a global minimum is the lowest point across the entire landscape.
What is a vanishing gradient?
A gradient that becomes very small, causing progress to be slow and potentially allowing batch noise to dominate the learning signal.
Why is a completely flat loss landscape difficult to optimize?
Its gradient is zero everywhere, so it provides no signal about how to reduce the loss.
What is an exploding gradient?
A gradient that becomes extremely large, potentially approaching infinity near a minimum and causing unstable updates or overshooting.
Why can multiple local minima make the random seed matter?
Different initial parameter values can lead optimization to different minima, resulting in different model performance.
How can comparing performance across random seeds reveal information about a model?
Large variation across seeds suggests that the optimization outcome may be sensitive to initialization or to an unstable loss landscape.
Does having a gradient defined in PyTorch guarantee that a function is easy to optimize?
No. Autograd can provide gradients for many functions, but a zero, vanishing, exploding, or otherwise uninformative gradient can still make optimization difficult.
How can PyTorch handle functions that are traditionally considered non-differentiable?
Autograd can calculate gradients using defined or approximate derivatives, such as directional derivatives around discontinuities.
Is every differentiable activation function necessarily monotonic?
No. Non-monotonic activation functions exist, though they are not commonly used; the relative importance of smoothness and monotonicity is not settled.
How are neural-network architectures commonly represented as computation graphs?
As directed graphs whose nodes represent functional transformations, such as layers, and whose edges carry information between them.
What does it mean for a computation graph to be directed?
Information flows in a specified direction along each edge.
What does it mean for a computation graph to be acyclic?
The graph has no loops or cycles.
What is a directed acyclic graph (DAG) in deep learning?
A directed computation graph without cycles, used to represent functional operations and information flow in a model.
How can a multilayer perceptron be represented as a computation graph?
As a sequence of nodes for linear layers and activation functions, carrying the input through hidden representations to an output.
What happens during the forward pass through a computation graph?
Inputs and parameters are passed through the graph’s operations to produce outputs and, ultimately, a loss.
What is the general form of a forward computation for one layer?
A layer takes an input and parameters, applies a functional transformation, and returns an output.
What is the purpose of backpropagation in a computation graph?
It propagates loss gradients backward through the graph so that gradients can be calculated for model parameters.
Why does backpropagation make gradient calculation more efficient?
It reuses shared derivative terms instead of separately recomputing them for each parameter.
What information may need to be retained from the forward pass for backpropagation?
Intermediate activations or representations, which are needed to calculate gradients efficiently during the backward pass.
What shape is the derivative of a scalar-valued function y=f(x) when x is an n×1 vector?
A row vector of size 1×n, containing the partial derivative of y with respect to each component of x.
What is the Jacobian shape when x has size n×1 and vector output y has size m×1?
The Jacobian has size m×n, with each entry giving a partial derivative of an output component with respect to an input component.
What shape does the derivative have when a scalar y depends on a matrix input X of size n×m?
It has the same matrix size, n×m, with entries corresponding to the partial derivatives with respect to elements of X.
What is the chain rule for h(x)=f(g(x))?
dxdh=dgdfdxdg
If x has size n, an intermediate vector u has size p, and output z has size m, what are the shapes in the chain-rule product for ∂z/∂x?
∂z/∂u has size m×p, and ∂u/∂x has size p×n. Their product has size m×n.
What gradient information is tracked for a generic layer during backpropagation?
The derivative of the layer’s outputs with respect to its inputs, and the gradient of the cost with respect to the layer’s activations.
How does backpropagation propagate an input gradient through a layer?
The input gradient is computed from the output gradient multiplied by the derivative of that layer’s outputs with respect to its inputs.
What does the derivative of a layer’s outputs with respect to its inputs describe?
It describes how the layer’s outputs change in response to changes in its inputs.
What are the three broad stages of neural-network training described in the lecture?
Run a forward pass, propagate loss gradients backward, and update parameters; then repeat.
Why can the gradient of a batch cost be computed from individual-example gradients?
Differentiation distributes over a sum, so the gradient of the average batch cost is the average of the individual cost gradients.
What is the general purpose of parameter gradients?
They indicate how changing each parameter affects the cost and therefore provide directions for parameter updates.
How does backpropagation through a chain reuse calculations for different layers?
Gradients from later parts of the network are reused as they are propagated backward, avoiding repeated calculation of shared chain-rule terms.
What is the backward-pass counterpart to sending data forward through the network?
The backward pass sends the loss signal and gradients from outputs toward earlier layers and their parameters.
What is the forward equation for a linear layer with weight matrix W and input vector x?
y=Wx
For a linear layer, how is the input gradient related to the output gradient?
It is obtained by multiplying the output gradient by the layer’s weights, with multiplication order depending on the row- or column-vector convention.
For a linear layer with y=Wx, what is the derivative of output component yi with respect to input component xj?
∂xj∂yi=Wij
How is the weight gradient for a linear layer related to its input and output gradient?
It is formed from the input and the output gradient; in the column-vector convention, it is their outer product.
What is the parameter update rule after calculating a weight gradient?
Move the weights opposite the cost gradient, scaled by the learning rate: Wk+1=Wk−η∇WJ.
What sequence of operations defines the example multilayer perceptron?
A linear layer, an activation such as ReLU, another linear layer, and a loss comparing the output with ground truth.
How does the backward pass through a linear layer relate to its forward pass?
It uses the same kind of linear operation, with the weight matrix transposed under the column-vector gradient convention.
How is a ReLU layer handled during the backward pass?
Its forward activations determine a gate that passes gradients for active components and masks gradients for components in ReLU’s zero region.
Why must ReLU activations be retained for the backward pass?
The backward pass needs to know which components were active so it can gate or mask their gradients correctly.
Is the backward operation through ReLU simply another application of ReLU?
No. It applies a gate based on the forward activations to determine which gradient components should pass through.
What does a first-order gradient approximation represent geometrically?
It approximates the local loss landscape with a plane; gradient-based movement follows that planar approximation.
What is a ReLU activation, and what smoothness properties does it have?
ReLU is an activation function that is continuous and differentiable almost everywhere, but it is not smooth at its kink.
What is the definition of the Gaussian error linear unit (GELU) described in the lecture?
GELU(x)=xΦ(x) where Φ is the cumulative distribution function of the Gaussian distribution.
What smoothness properties of GELU were highlighted?
It is everywhere continuous, everywhere differentiable, and everywhere smooth.
Does the lecture claim that GELU is always better than ReLU?
No. It notes a trend toward activations with continuity, differentiability, and smoothness, but does not claim that GELU is always better or that an optimal activation is known.
What two operations extend backpropagation from chains to arbitrary DAGs?
Merging and branching.
How is a gradient handled when separate paths merge?
Each path receives the gradient components corresponding to its own input variables.
How is a gradient propagated backward through a branching operation that duplicates or splits information?
The gradients from the different branches are summed and sent back through the shared input.
How does parameter sharing create a branching structure in backpropagation?
A shared parameter affects multiple uses of a component, so gradients from those uses must be combined by summing them.
What kinds of model structures make DAG backpropagation useful?
Models with shared or split weights, branches that later merge, concatenated components, or multiple objectives.
What is the relationship between backpropagation through an MLP and through a general DAG?
An MLP is a chain-shaped DAG; general DAGs use the same backpropagation principles plus operations for merging and branching.
What does differential programming mean in the context of deep learning?
It is a programming approach in which differentiable model components are composed and optimized using gradients.
What role do libraries such as PyTorch and JAX play in differential programming?
They provide tools for efficiently defining computations and calculating gradients through them.
Why are deep networks well suited to compositional programming?
They can be assembled from reusable functional blocks, and their differentiable components can be optimized together.
Must every component in a machine-learning system be learned by backpropagation?
No. A system can combine learned components with parts explicitly programmed by humans, such as preprocessing steps.
How can human-designed components affect a learned system?
They constrain the system. Such constraints can be useful, but they can also limit performance if the hand-designed choices are suboptimal.
What is an example of a preprocessing choice that may be programmed rather than learned?
Normalization values for natural images can be set explicitly during preprocessing.
What does the Software 2.0 perspective emphasize?
Instead of explicitly specifying every behavior, define a space of possible systems and optimize within that space to find one suited to the problem.
What is an embedding or representation in a neural network?
A lower-dimensional representation of a complex, often high-dimensional input, produced by a trained network such as an encoder.
What is feature visualization used to investigate?
It can optimize an input to reveal what a trained model or a particular neuron responds to.
What is DeepDream an example of?
A technique that modifies inputs to reveal patterns or features that a trained model responds to, producing visually emphasized or dreamlike results.
How can a model be optimized with respect to its input rather than its parameters?
Hold model parameters fixed and adjust the input in the direction that changes a chosen output or objective as desired.
What is the difference between optimizing parameters and optimizing inputs?
Parameter optimization adjusts model weights to change the cost; input optimization adjusts the data supplied to a fixed model to change a chosen output or objective.
Why can optimizing class probabilities after softmax be less stable than optimizing logits before softmax?
Increasing a class probability can be achieved by making alternatives less likely, whereas optimizing the pre-softmax logits was described as tending to be more stable.
How can a text encoder and image encoder be used together for image generation from text?
A text prompt and generated image can be compared in a shared embedding space; optimizing the generator’s input can produce an image aligned with the prompt.
When fixed neural-network modules are composed, what can still be optimized?
An input or other chosen variable can be optimized through the fixed modules, provided gradients can be propagated to that variable.

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