Training Neural Networks
- 98Unfamiliar
- 0Learning
- 0Familiar
- 0Mastered
In supervised neural-network training, what roles do the input x and ground-truth target y play?
98 questions
- 1
In supervised neural-network training, what roles do the input x and ground-truth target y play?
Model answer
The input x is fed to the network, and the ground-truth target y is the value the model is trained to predict.
Explanation
For example, an image may be the input and its visual category the target.
- 2
What are the layers of a neural network, and what is learned about them during training?
Model answer
Layers are functional components that transform data as it passes through the network. Their associated parameters are adjusted during training.
Explanation
The lecture describes a network as a chain of blocks or layers, each with parameters.
- 3
How is a training loss used to assess a model’s prediction?
Model answer
The loss measures the difference between the model’s prediction and the ground-truth target.
Explanation
Training uses this measure to guide parameter updates.
- 4
What does it mean to say that a neural network’s parameters are learned?
Model answer
Their numerical values are adjusted using data so that the model’s loss becomes smaller or otherwise closer to an optimum.
Explanation
Learning is described as changing parameter values in numerical space based on available data.
- 5
How is the overall cost J related to individual training losses in the lecture’s setup?
Model answer
The cost is the sum of the individual losses over the training dataset.
Explanation
The objective is to find parameters that minimize this aggregate cost.
- 6
What is the goal of training in terms of model parameters?
Model answer
Find a parameter setting heta∗ that minimizes the cost J(heta) over the available training data.
Explanation
The lecture frames training as an optimization problem over the model’s parameters.
- 7
What information about J(heta) can be evaluated for a given parameter setting?
Model answer
The cost itself and its gradient can be evaluated; a Hessian can also be calculated for second-order optimization.
Explanation
The gradient gives first-order information, while the Hessian represents second-order information.
- 8
Why is first-order optimization more commonly emphasized in practice than second-order optimization in this discussion?
Model answer
The practical focus is usually on the gradient, a first-order approximation, rather than calculating the Hessian.
Explanation
The lecture notes that Hessian-based optimization is not commonly performed in practice here.
- 9
How do the terms “loss” and “cost” differ in the lecture’s usage?
Model answer
A loss can refer to the error for individual data points, while cost can refer to an aggregate such as the total loss over a dataset. The terms are sometimes used loosely.
Explanation
The speaker notes that the distinction is somewhat semantic in the discussion.
- 10
What is a common indication that training may be finished, as mentioned in the lecture?
Model answer
Training may be stopped when performance on a validation set has plateaued.
Explanation
A validation-set plateau is given as an example of a stopping signal.
- 11
In gradient descent, what direction is used to update parameters when minimizing a cost?
Model answer
Parameters are moved opposite the gradient, which points in the direction of greatest increase in cost.
Explanation
Moving against the gradient aims to decrease the objective.
- 12
Write the basic gradient-descent update for parameters hetak with learning rate [0m[0m\eta.
Model answer
[0m[0m\theta_{k+1} = \theta_k - \eta [0m[0m\nabla J(\theta_k).
Explanation
The learning rate scales a step opposite the gradient at the current parameters.
- 13
What does the learning rate [0m[0m\eta control in a gradient-descent update?
Model answer
It controls the size of the step taken in the gradient direction.
Explanation
A larger or smaller learning rate changes how far parameters move at each update.
- 14
What is a batch in stochastic gradient descent (SGD)?
Model answer
A batch is a subset of the dataset used to calculate a gradient for an update.
Explanation
SGD uses a subset instead of calculating the gradient over the entire dataset each time.
- 15
What does a batch size of 1 mean, and what is one potential drawback?
Model answer
The parameters are updated after each individual example. This can make updates computationally inefficient or noisy.
Explanation
The lecture contrasts this with larger batches that average information across examples.
- 16
How does SGD with a batch containing the entire dataset relate to standard gradient descent?
Model answer
It is standard gradient descent because each update uses the gradient over the full dataset.
Explanation
A full-dataset batch removes the subset approximation used by SGD.
- 17
Why is calculating a gradient over an entire large dataset often impractical?
Model answer
It can require too much time and computation, and the full dataset may not fit in GPU memory.
Explanation
The lecture highlights the increasing scale of modern datasets as a challenge.
- 18
Why can a minibatch gradient differ from the gradient over the entire dataset?
Model answer
A subset may not represent the full data distribution, so its gradient can be noisy or point in a different direction.
Explanation
SGD treats the batch gradient as an approximation to the total gradient, not a guaranteed match.
- 19
How can class imbalance affect the stability of SGD updates?
Model answer
If some categories are absent for several batches and then appear, their examples can sharply shift the gradient, making updates less stable.
Explanation
The lecture connects this instability to how uniformly the categories are distributed.
- 20
What are two advantages of stochastic gradient descent described in the lecture?
Model answer
It can be faster than full-dataset gradient descent and can approximate the total gradient using small samples. Its noise can also act as an implicit regularizer.
Explanation
The noise may help the optimizer move out of some local minima.
- 21
What are two disadvantages of SGD described in the lecture?
Model answer
Its gradients can have high variance, and its updates can be unstable, particularly when the training data are unbalanced.
Explanation
A batch gradient may differ substantially from the full-data gradient.
- 22
What is momentum in gradient descent intended to do?
Model answer
It biases a parameter update to continue in the direction of previous updates.
Explanation
The idea is analogous to a moving object gaining speed as it rolls downhill.
- 23
What role does the momentum coefficient [0m[0m\alpha play?
Model answer
It controls the strength of the momentum contribution and is a hyperparameter.
Explanation
The coefficient determines how strongly past movement affects the current step.
- 24
How can momentum help optimization, and what can happen if it is too strong?
Model answer
Moderate momentum can reach a minimum faster, while excessive momentum can overshoot it and cause oscillations, slowing optimization.
Explanation
The effect depends on the strength of the momentum term.
- 25
What optimizer is given as a popular example of a method using momentum?
Model answer
Adam is given as a commonly used optimizer with momentum.
Explanation
The lecture identifies Adam as a familiar example.
- 26
Why might gradient descent fail to find the global minimum of a non-convex loss landscape?
Model answer
The landscape can contain multiple local minima, and the optimizer may converge to one that is not global.
Explanation
The outcome can depend on the starting parameters.
- 27
What makes a simple convex loss landscape comparatively easy to optimize?
Model answer
It has a single minimum, gradients point toward it, and the gradient smoothly approaches zero near it.
Explanation
These properties give a clear route toward the minimum from different starting points.
- 28
Why can multiple local minima make optimization difficult?
Model answer
The optimizer may settle in a local minimum, and the one it reaches can depend on its initialization.
Explanation
A local minimum need not be the global minimum.
- 29
What is a vanishing gradient, and why does it hinder learning?
Model answer
It is a gradient that becomes very small, so progress can be extremely slow and batch noise may dominate the useful signal.
Explanation
Small gradients provide little information about how to improve the parameters.
- 30
Why is a function with zero gradient everywhere difficult to optimize by gradient descent?
Model answer
It supplies no gradient signal to guide parameter updates toward a lower-loss region.
Explanation
Even if a framework can calculate the gradient, that gradient may still be zero.
- 31
What is an exploding gradient, and how can it affect optimization?
Model answer
It is a gradient that becomes extremely large, causing unstable updates that can overshoot the minimum.
Explanation
A steep gradient near a minimum can make it difficult to land on that minimum.
- 32
Why can initialization matter when optimizing a landscape with multiple minima?
Model answer
Different starting points can lead the optimizer to different local minima and therefore different results.
Explanation
Trying multiple random seeds can reveal variation in model performance.
- 33
What can variation in performance across random seeds indicate?
Model answer
It can provide evidence about how unstable or sensitive the optimization landscape is to initialization.
Explanation
Large performance variation suggests that different starts lead to substantially different outcomes.
- 34
Does PyTorch’s ability to calculate a gradient for a function guarantee that the function will be easy to optimize? Explain.
Model answer
No. A gradient may be calculable but unhelpful, such as when it is zero, vanishing, or otherwise difficult to use for reaching a minimum.
Explanation
Differentiability in a framework is distinct from having a useful optimization landscape.
- 35
How does the lecture use the flowing-water analogy to think about a loss landscape?
Model answer
If water flowing from different starting points reaches the same low point, that suggests the landscape guides optimization toward that minimum.
Explanation
The analogy gives an intuition for whether descent leads to a minimum from different locations.
- 36
Why can a flat region make optimization difficult even if it is differentiable?
Model answer
Its gradient provides little or no signal about which direction would reduce the loss.
Explanation
Differentiability alone does not ensure useful gradients.
- 37
What three properties of loss-related functions are described as potentially making optimization easier?
Model answer
The properties are being everywhere continuous, everywhere differentiable, and everywhere smooth.
Explanation
The lecture presents these as trends that may help optimization, not as proven requirements.
- 38
How does ReLU relate to continuity, differentiability, and smoothness?
Model answer
ReLU is everywhere continuous and almost everywhere differentiable, but it is not everywhere smooth because it has a kink.
Explanation
Its behavior at the kink distinguishes differentiability from smoothness.
- 39
How does GeLU relate to continuity, differentiability, and smoothness in the lecture?
Model answer
GeLU is described as everywhere continuous, everywhere differentiable, and everywhere smooth.
Explanation
It is introduced as a smooth alternative that has seen increased use.
- 40
What is the Gaussian cumulative distribution function’s role in the stated GeLU form?
Model answer
The GeLU form multiplies its input by the Gaussian cumulative distribution function evaluated at that input.
Explanation
The lecture describes GeLU as the parameter times [0m[0m\phi of the parameter, with [0m[0m\phi denoting that cumulative distribution function.
- 41
Does the lecture claim that GeLU is always better than ReLU?
Model answer
No. It describes a trend toward smooth functions, but says there is no settled theoretical guarantee that GeLU or any particular property is always optimal.
Explanation
The best choice can depend on the problem and remains an open practical question in the discussion.
- 42
What are evolution strategies, and how do they choose a direction in parameter space?
Model answer
They are gradient-like methods that sample small perturbations around current parameters and move toward perturbations with lower loss.
Explanation
They seek locally loss-minimizing directions without relying only on the ordinary gradient direction.
- 43
How can perturbations in an evolution strategy help with a difficult loss landscape?
Model answer
Sampling nearby parameter values can reveal a lower-loss direction even when the current location has an unhelpful gradient signal.
Explanation
The lecture illustrates perturbations helping move from a non-minimal situation to a better value.
- 44
What does gradient clipping do when a gradient exceeds a chosen maximum?
Model answer
It scales the gradient back so it does not exceed the specified maximum magnitude.
Explanation
Clipping limits how far a model can move in a single direction.
- 45
How can gradient clipping reduce instability?
Model answer
By limiting excessively large updates, it can reduce overshooting and oscillation in a steep or peaky loss landscape.
Explanation
It acts as a cap on the gradient-driven parameter change.
- 46
Is a non-monotonic activation function necessarily unusable according to the lecture?
Model answer
No. Non-monotonic activation functions exist, although the lecture says they are not often widely used and that the trade-offs remain unsettled.
Explanation
The discussion does not establish monotonicity as a required property.
- 47
Must a loss function always have nonnegative values?
Model answer
No. Whether loss values can be negative depends on how the loss is defined.
Explanation
The lecture explicitly notes that loss functions can have negative values.
- 48
What is a computation graph?
Model answer
It is a graph of functional transformations, with each transformation represented as a node and connections indicating how outputs feed into later computations.
Explanation
Combining the transformations allows the graph to perform a larger computation.
- 49
What do “directed” and “acyclic” mean in a directed acyclic graph (DAG)?
Model answer
Directed means information flows in one direction along an edge; acyclic means the graph has no loops or cycles.
Explanation
Deep-learning computation graphs are commonly represented as DAGs.
- 50
How can a multilayer perceptron be represented as a computation graph?
Model answer
Its input passes through a linear layer, an activation function, and further layers, with each operation represented as a node and its output feeding the next node.
Explanation
An MLP is a simple chain-shaped example of a computation graph.
- 51
What information is used in a forward pass through a layer, and what does it produce?
Model answer
A layer takes an input and its parameters, applies its functional transformation, and produces an output.
Explanation
In a multilayer model, each output becomes the next component’s input.
- 52
What is a Jacobian when a vector-valued output depends on a vector input?
Model answer
It is the matrix of partial derivatives of output components with respect to input components.
Explanation
If the output has size m and the input has size n, the Jacobian has size m by n.
- 53
What is the shape of the derivative of a scalar output with respect to an n-component column-vector input, using the lecture’s convention?
Model answer
It is a row vector of size 1 by n.
Explanation
Each element is the partial derivative with respect to one input component.
- 54
What is the shape of the derivative of a scalar output with respect to a matrix input of size n by m, using the lecture’s convention?
Model answer
It is a matrix of size m by n, the transpose of the input’s shape.
Explanation
Each component corresponds to the partial derivative with respect to an input-matrix component.
- 55
State the chain rule for z=f(u) and u=g(x) in terms of derivatives.
Model answer
[0m[0m\frac{\partial z}{\partial x} = \frac{\partial z}{\partial u}\frac{\partial u}{\partial x}.
Explanation
The derivative through a composition is the product of the derivatives of its component transformations.
- 56
If x has size n, u has size p, and z has size m, what are the sizes of [0m[0m\frac{\partial z}{\partial u} and [0m[0m\frac{\partial u}{\partial x}?
Model answer
Their sizes are m by p and p by n, respectively.
Explanation
Their matrix product has size m by n, matching the derivative of z with respect to x.
- 57
Why does backpropagation avoid separately recomputing every derivative from the output to every parameter?
Model answer
Different parameter derivatives share intermediate chain-rule terms, so backpropagation computes and reuses those terms.
Explanation
Reusing shared calculations makes gradient computation practical for large models.
- 58
What information flows during the forward pass and during the backward pass?
Model answer
The forward pass sends inputs through the model to produce outputs and a loss; the backward pass sends gradients from the loss back through the model.
Explanation
The backward signal is used to determine parameter updates.
- 59
In the generic-layer description, what does L represent?
Model answer
L is the gradient of the layer outputs with respect to the layer inputs.
Explanation
It describes how changes in the input affect the layer’s output.
- 60
In the generic-layer description, what does g represent?
Model answer
g is the gradient of the cost with respect to the layer’s activations.
Explanation
It carries information about how the cost changes with the layer’s values.
- 61
How are the input gradient and output gradient related when backpropagating through a layer?
Model answer
The input gradient is computed by multiplying the output gradient by the layer’s derivative L, with the exact order determined by the vector convention.
Explanation
This recurrence propagates the error signal toward earlier layers.
- 62
How does backpropagation use layer derivatives to determine a parameter update direction?
Model answer
It combines the gradient arriving at a layer with the layer’s derivatives with respect to its parameters to compute how those parameters affect the cost.
Explanation
The resulting gradient indicates how to change each parameter to reduce the cost.
- 63
What are the three broad stages of the neural-network training algorithm described in the lecture?
Model answer
Perform a forward pass, propagate loss derivatives backward, then update the parameters and repeat.
Explanation
Repeating these stages trains the model over batches of data.
- 64
Why must a layer’s intermediate activations generally be retained for backpropagation?
Model answer
They are needed to efficiently calculate derivatives during the backward pass, including gradients through activation functions.
Explanation
The forward pass may not need to keep every earlier representation, but the backward pass does.
- 65
How is the batch gradient of an average cost related to the gradients of individual examples?
Model answer
It is the average of the per-example cost gradients.
Explanation
Differentiation can be moved inside the sum used to aggregate the example costs.
- 66
For a linear layer with weight matrix W and input vector x, what is the forward-pass output?
Model answer
y=Wx.
Explanation
The linear layer applies its weight matrix to the input vector.
- 67
For the linear layer y=Wx, how is the gradient propagated back to the input?
Model answer
It is obtained by multiplying the output gradient by the layer’s weights, with transposition depending on whether gradients are represented as rows or columns.
Explanation
In the column-vector convention, the backward multiplication uses WT.
- 68
For a linear layer, what is the derivative of output component yi with respect to weight Wij?
Model answer
It is the input component xj.
Explanation
Changing that weight changes the ith output in proportion to the corresponding input.
- 69
What is the basic form of the weight gradient for a linear layer?
Model answer
It is formed from the input and the output gradient; in column-vector notation it is the outer product of the output gradient and input.
Explanation
Each weight’s gradient combines the relevant output-gradient component with its input component.
- 70
How are forward and backward computations for a linear layer related?
Model answer
Both use multiplication by the weight matrix; the backward computation uses the transposed weight matrix under the column-vector convention.
Explanation
This is a convenient structural similarity between the two passes.
- 71
How is the backward operation through a ReLU represented for a particular forward pass?
Model answer
It is represented by a gating operation that passes gradients for active components and masks gradients for components in ReLU’s zero region.
Explanation
The gate depends on the activations observed during the forward pass.
- 72
Why does backpropagation through a ReLU need information from the forward pass?
Model answer
It needs to know which components were active and which were set to zero so it can gate the corresponding gradients.
Explanation
Those activation values must be retained or otherwise available during backpropagation.
- 73
Why can the backward calculation be viewed as linear even when the network contains nonlinear activations?
Model answer
Backpropagation uses local derivatives, such as the ReLU gate, and propagates gradients using linear operations; the first-order approximation is linear locally.
Explanation
This does not mean the full network’s loss function is globally linear.
- 74
Why is the forward pass not fully symmetric with the backward pass in memory use?
Model answer
Backpropagation usually needs intermediate forward activations to compute gradients, so they must be retained even though the forward computation itself can proceed without keeping all earlier values.
Explanation
The stored representations support efficient derivative calculations.
- 75
How can bias terms be treated in the layer derivations presented in the lecture?
Model answer
They can be included in practice, even though some illustrative derivations omit them for simplicity.
Explanation
The simplified examples focus on the core matrix operations.
- 76
What two graph operations are sufficient to extend chain-based backpropagation to arbitrary DAGs?
Model answer
Merging and branching.
Explanation
These operations account for paths that combine or split in a general computation graph.
- 77
When a computation graph merges two paths, how should gradients be routed backward?
Model answer
Each path receives the gradient corresponding to the input variables that contributed along that path.
Explanation
The gradient must be matched to the correct merged input components.
- 78
When a computation graph branches into multiple paths, how are gradients propagated back to the shared input?
Model answer
The gradients from the branches are summed and sent back through the shared input.
Explanation
Each branch contributes to how the shared input affects the overall cost.
- 79
How does concatenation affect the backward pass through a merge?
Model answer
The gradient is separated so each incoming path receives the components corresponding to its own input.
Explanation
A merge may be concatenation or another operation, so gradient routing depends on the relevant input components.
- 80
How does parameter sharing create a branching structure for gradient computation?
Model answer
A shared parameter is used in multiple parts of the model, so its gradient contributions from those uses are combined, typically by summing them.
Explanation
The shared parameter receives gradient information from every branch in which it appears.
- 81
Why can backpropagation for an MLP be applied to a more general DAG?
Model answer
A general DAG can be handled by adding gradient rules for merges and branches to the chain-based backpropagation operations.
Explanation
The underlying method remains the same while accounting for multiple paths.
- 82
What is differential programming in relation to deep-learning frameworks?
Model answer
It is a programming approach that represents computations as differentiable components and uses gradients to optimize parts of the system.
Explanation
Frameworks such as PyTorch, TensorFlow, and JAX support this style of computation.
- 83
What two properties of deep networks help make them suitable for differential programming?
Model answer
They are designed to be differentiable and are compositional, allowing systems to be built from reusable components.
Explanation
The lecture likens composing components to block-based programming.
- 84
In a modular model, must every component be learned by backpropagation?
Model answer
No. Some components can be explicitly programmed or fixed, while others have learned parameters updated by backpropagation.
Explanation
For example, a parser might be fixed while a neural-network component is trained.
- 85
How does the neural-module example distinguish a parser from a CNN?
Model answer
The parser may be a standard, non-learned component, while the CNN may have parameters updated using training data.
Explanation
A system can combine fixed tools and trainable modules.
- 86
What is the central idea of “Software 2.0” as described in the lecture?
Model answer
Instead of specifying every behavior directly, define a space of possible systems and optimize within that space to find one suited to the task.
Explanation
The learned system is shaped by data and an optimization objective.
- 87
How can hand-programmed constraints help or hinder a learned system?
Model answer
They can provide useful structure, but they can also restrict the system in ways that are less effective than learning from data.
Explanation
The lecture contrasts feature engineering with larger models learned more end-to-end.
- 88
Why is the choice of cost function important in differential programming?
Model answer
The cost defines the objective being optimized, so it influences which system or parameter values are considered optimal.
Explanation
The desired behavior must be represented through the chosen objective.
- 89
Besides model parameters, what kinds of quantities can be optimized with respect to a scalar cost?
Model answer
If the computation is differentiable, inputs or other nodes and edges in the computation can also be optimized with respect to the cost.
Explanation
Optimization need not be restricted to learned weights.
- 90
What is the difference between optimizing model parameters and optimizing model inputs?
Model answer
Parameter optimization changes the model’s weights to change the cost, whereas input optimization changes the input while holding the model parameters fixed.
Explanation
Both can be viewed as changing a quantity to affect a scalar objective.
- 91
Why can optimizing class probabilities after a softmax be less stable than optimizing class logits before it?
Model answer
Increasing a class’s softmax probability can be achieved by making alternatives unlikely rather than making the chosen class itself strongly likely; optimizing logits can be more stable.
Explanation
The lecture contrasts the behavior of objectives before and after softmax.
- 92
How can input optimization be used to visualize what a trained model associates with a class?
Model answer
Optimize an input image to increase the model’s output for that class, revealing an image that the model regards as class-like.
Explanation
The lecture gives maximizing a model’s cat output as an example.
- 93
How can activation maximization be used to probe a model’s internal representations?
Model answer
Optimize an input to maximize a selected neuron’s activation at a particular layer, revealing patterns that neuron responds to.
Explanation
This can provide an intuition for what a layer or neuron detects.
- 94
What is the connection between activation maximization and DeepDream described in the lecture?
Model answer
Both use optimization of inputs or representations to amplify patterns a model responds to, producing visualizations of what the model “sees” or “dreams.”
Explanation
DeepDream is presented as an example of probing model responses through optimization.
- 95
What does it mean for text and images to be close in a shared embedding space, as in CLIP?
Model answer
Their learned representations are near one another when the text and image are semantically related.
Explanation
CLIP uses text and image encoders that project both modalities into a joint representation space.
- 96
How can a fixed CLIP model and a fixed image generator be used to create an image from text?
Model answer
Optimize the generator’s input so the generated image is close in CLIP’s embedding space to the representation of the text prompt.
Explanation
The encoders and generator can remain fixed while the input to the generator is optimized.
- 97
What does the term “embedding” or “representation” mean in the lecture’s explanation?
Model answer
It is a lower-dimensional representation of complex input data, such as an image, produced by a trained neural network.
Explanation
An encoder maps high-dimensional inputs into a compact vector representation.
- 98
How does modularity allow previously trained components to be reused?
Model answer
A trained component can be kept fixed and plugged into a new system, while other components or inputs are optimized around it.
Explanation
Components learned in one setting can be composed with other modules in a new task.

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