MauryaHub PYQ Practice

Introduction to Deep Learning and Generative AI · Quiz 2 · May 2026

Introduction to Deep Learning and Generative AI · Quiz 2 · May 2026

← Course papers · Start practice / exam

Questions and published explanations below are available without starting a test. Some questions may not have a published solution yet.

20 / 20 published solutions

Question 2 MCQ · 2.0 marks

Consider the following code snippet:
Source diagram or notation
Based on the standard normalization technique for a single-channel **grayscale** image dataset like FashionMNIST, which of the following correctly fills in blank **(A)**?
6406537086691.Source diagram or notation
6406537086692.Source diagram or notation
6406537086693.Source diagram or notation
6406537086694.Source diagram or notation

Published solution

**1. Identify the data:** FashionMNIST contains grayscale images, so each image has one channel. ToTensor converts its pixels to floating-point values, normally between 0 and 1. **2. Apply channel-wise normalization:** For a pixel value \(x\), normalization uses \[z=\frac{x-\mu}{\sigma}.\] Here the supplied dataset mean is \(\mu=0.2860\), and the standard deviation is \(\sigma=0.3530\). **3. Supply one value per channel:** Use transforms.Normalize(mean=(0.2860,), std=(0.3530,)). The trailing comma makes each argument a one-element tuple. For example, a pixel equal to the mean becomes 0 after normalization. **Answer: A.** A: **Correct:** One-element mean and standard-deviation tuples match the one grayscale channel. B: **Incorrect:** This uses scalar values rather than the documented per-channel sequences requested by the question; some implementations may broadcast scalars, but the standard channel-wise form is A. C: **Incorrect:** Three mean and standard-deviation entries describe three channels, whereas FashionMNIST has one. D: **Incorrect:** Scale is not the mean-and-standard-deviation normalization operation.

Report a correction for Q2

Question 3 MCQ · 2.0 marks

Suppose during training **Epoch 1** D(real)=0.90 D(fake)=0.10 Later **Epoch 20** D(real)=0.999 D(fake)=0.0001 What problem is most likely? (Here, D(x) represents Discriminator's output on image x)
6406537086703.
Discriminator has become too strong, leading to vanishing gradients for the generator.
6406537086704.
Mode collapse has definitely occurred.
6406537086705.
Generator has perfectly learned the data distribution.
6406537086706.
The discriminator will stop updating permanently.

Published solution

**1. Interpret the scores:** D(real) is the discriminator's estimated probability that a real sample is real; D(fake) is the same estimate for a generated sample. By epoch 20, the discriminator almost perfectly separates the two. **2. Identify the imbalance:** D(real)=0.999 and D(fake)=0.0001 indicate that the discriminator is winning too easily. With the original saturating generator objective, an almost perfect discriminator can provide a very small useful gradient to the generator. **3. Distinguish other failures:** These two scores alone do not show whether generated images repeat a few patterns, so they cannot prove mode collapse. A successful generator would instead make real and fake samples difficult to distinguish. The vanishing-gradient concern is especially associated with the original saturating GAN loss; modern loss choices can reduce it. **Answer: A.** A: **Correct:** The nearly perfect separation is evidence of an overpowering discriminator and the associated risk of weak generator gradients. B: **Incorrect:** Mode collapse means little diversity in generated samples; discriminator scores alone do not establish it. C: **Incorrect:** Matching the data distribution would prevent such reliable separation. D: **Incorrect:** Nothing in the scores permanently disables discriminator updates.

Report a correction for Q3

Question 4 MCQ · 2.0 marks

Let D(x) denote the discriminator's output. Which of the following represents the most desirable discriminator output during stable GAN training?
6406537086707.
D(real) = 0.9, D(fake) = 0.1
6406537086708.
D(real) = 0.8, D(fake) = 0.2
6406537086709.
D(real) = 1.0, D(fake) = 0.0
6406537086710.
D(real) = 0.5, D(fake) = 0.5

Published solution

**1. Recall the GAN goal:** The generator should make samples whose distribution matches that of real samples. **2. Evaluate the ideal discriminator:** With equally likely real and generated samples, the optimal discriminator is \[D^*(x)=\frac{p_{data}(x)}{p_{data}(x)+p_g(x)}.\] When \(p_g=p_{data}\), this equals \(1/2\). **3. Interpret the result:** D(real)=D(fake)=0.5 represents uncertainty between the two classes at the desired balanced equilibrium. A constant 0.5 output by an untrained or broken discriminator alone would not prove success, but it is the intended equilibrium among these choices. **Answer: D.** A: **Incorrect:** The discriminator still separates real and fake very strongly. B: **Incorrect:** This still represents substantial separation. C: **Incorrect:** Perfect discrimination is the opposite of the desired indistinguishable distributions. D: **Correct:** At the balanced ideal equilibrium, neither class can be distinguished better than chance.

Report a correction for Q4

Question 5 MCQ · 2.0 marks

What is the output of the following code snippet?
Source diagram or notation
6406537086717.Source diagram or notation
6406537086718.Source diagram or notation
6406537086719.Source diagram or notation
6406537086720.Source diagram or notation

Published solution

**1. Understand clamp:** torch.clamp(grads, min=-5.0, max=2.0) replaces values below -5 by -5 and values above 2 by 2. Values inside the interval are unchanged. **2. Check every entry:** The input is [5.0, -5.0, 0.0, 2.0, 5.0]. Its entries become 2.0, -5.0, 0.0, 2.0 and 2.0 respectively. **3. Read the output:** The resulting values are [2.0, -5.0, 0.0, 2.0, 2.0]. This is element-wise clipping, not normalization or gradient computation. **Answer: D.** A: **Incorrect:** The two entries equal to 5 must be clipped to 2. B: **Incorrect:** Zero must remain zero, and the final 5 must be clipped. C: **Incorrect:** The final entry still incorrectly retains 5. D: **Correct:** Every entry lies in the specified interval after the correct clipping operation.

Report a correction for Q5

Question 6 MCQ · 2.0 marks

Truncated BPTT with window
Source diagram or notation
is used on a long sequence. Which statement is correct?
6406537086721.
The hidden state is reset every
Source diagram or notation
steps, so the model's forward memory cannot exceed
Source diagram or notation
steps.
6406537086722.
The forward pass propagates the hidden state through the entire sequence; only the backward pass is cut off after
Source diagram or notation
steps.
6406537086723.
Truncation eliminates the vanishing-gradient problem entirely, because gradients no longer traverse long products.
6406537086724.
Truncation increases memory usage because the whole computation graph must be retained.

Published solution

**1. Separate forward memory from backward history:** An RNN computes \(h_t=f(W_xx_t+W_hh_{t-1}+b)\). Thus the carried hidden state can contain information accumulated before the current training window. **2. Explain truncation:** Truncated backpropagation through time detaches the computational graph after a chosen window of \(\tau\) steps. The numerical hidden state can be carried forward, but gradients do not pass through the detached earlier history. **3. State the consequence:** The backward dependency is limited to the window; the forward state need not be reset. This saves graph storage but does not guarantee that all gradient problems disappear. **Answer: B.** A: **Incorrect:** Detaching a graph and resetting the numerical hidden state are different operations. B: **Correct:** The hidden state continues forward while the gradient history is truncated. C: **Incorrect:** Gradients may still shrink within a window; truncation is not a complete cure. D: **Incorrect:** Old graphs can be released, so truncation normally reduces memory requirements.

Report a correction for Q6

Question 7 MCQ · 2.0 marks

Consider the following implementation of a RNN:
Source diagram or notation
What is the output of the print statements?
6406537086725.Source diagram or notation
6406537086726.Source diagram or notation
6406537086727.Source diagram or notation
6406537086728.Source diagram or notation

Published solution

**1. Read the input dimensions:** x has shape (4,6,8). With batch_first=True these mean batch size 4, sequence length 6 and input features 8. **2. Determine the sequence output:** The RNN has hidden_size=16, so each of the six time steps produces a 16-dimensional hidden vector for each item. The output shape is (4,6,16). **3. Determine the final hidden state:** For one unidirectional layer, h has shape (num_layers,batch,hidden_size)=(1,4,16). batch_first affects the sequence tensors, not this hidden-state convention. **Answer: A.** A: **Correct:** The output is torch.Size([4,6,16]) and the final hidden state is torch.Size([1,4,16]). B: **Incorrect:** The input explicitly uses batch_first=True, so batch and sequence axes are not exchanged. C: **Incorrect:** The output feature dimension is hidden_size=16, not input_size=8. D: **Incorrect:** The sequence output contains one vector per time step, so its time dimension is not removed.

Report a correction for Q7

Question 8 MCQ · 2.0 marks

Which of the following options is correct regarding the standard encoder-decoder architecture?
6406537086729.
During training, we feed the decoder's prediction from the previous step as input for the current step to stabilize learning.
6406537086730.
We first train the encoder completely, and then using the context vector from the fully trained encoder, we train the decoder.
6406537086731.
When working with batches of varying lengths, the loss function calculates gradients for padding tokens to ensure uniform batch updates.
6406537086732.
None of these

Published solution

**1. Training inputs:** Standard teacher forcing supplies the previous ground-truth target token to the decoder during training. Feeding its own previous prediction is typical during inference, or under a different training strategy such as scheduled sampling. **2. Joint learning:** The encoder and decoder are usually trained together through the same sequence loss. Gradients flow through the decoder and context representation into the encoder. **3. Padding:** Padding is an artificial device for batching unequal lengths. Padded target positions should be masked or ignored in the loss rather than treated as meaningful training targets. **Answer: D.** A: **Incorrect:** This describes prediction feedback rather than standard teacher forcing. B: **Incorrect:** The standard architecture is trained jointly, not necessarily in two separately completed stages. C: **Incorrect:** Padding targets are normally excluded from the loss. D: **Correct:** All three proposed descriptions are incorrect for the standard training procedure.

Report a correction for Q8

Question 9 MCQ · 3.0 marks

Suppose you are optimizing a model in a region where the slope (gradient) is perfectly flat and constant. Standard Gradient Descent (GD) takes a fixed step based on the learning rate
Source diagram or notation
, moving by a distance of
Source diagram or notation
at every iteration where
Source diagram or notation
is the gradient. Classical Momentum builds up "speed" over time using these rules: • **Velocity update:**
Source diagram or notation
• **Position update:**
Source diagram or notation
Because of the decay factor
Source diagram or notation
, the momentum step size will continuously converge toward a steady-state "terminal velocity". In this limiting steady state (where the velocity becomes completely constant), how many times larger is the Momentum step compared to the standard GD step?
6406537086695.Source diagram or notation
(unchanged)
6406537086696.Source diagram or notation
6406537086697.Source diagram or notation
6406537086698.Source diagram or notation

Published solution

**1. Write the given recurrence:** With a constant gradient \(g\), momentum uses \(v_t=\beta v_{t-1}+g\) and \(x_{t+1}=x_t-\eta v_t\), where \(0<\beta<1\). **2. Solve for terminal velocity:** At steady state, \(v_t=v_{t-1}=v\). Therefore \[v=\beta v+g\quad\Rightarrow\quad (1-\beta)v=g\quad\Rightarrow\quad v=\frac{g}{1-\beta}.\] **3. Compare step magnitudes:** Ordinary GD moves by \(\eta |g|\), while momentum approaches \(\eta |g|/(1-\beta)\). For a nonzero constant gradient, their ratio is \(1/(1-\beta)\). For example, \(\beta=0.9\) gives a factor of 10. Here 'flat and constant' must mean a constant slope; if g were exactly zero both steps would be zero and their ratio would be undefined. **Answer: B.** A: **Incorrect:** This ignores accumulation of the repeated gradient. B: **Correct:** Solving the fixed-point recurrence gives exactly this multiplier. C: **Incorrect:** This is the reciprocal of the required multiplier. D: **Incorrect:** Beta controls decay, not the complete accumulated multiplier.

Report a correction for Q9

Question 10 MCQ · 3.0 marks

Let
Source diagram or notation
be a continuous function defined on an interval
Source diagram or notation
. Suppose there exist three distinct points
Source diagram or notation
in
Source diagram or notation
such that
Source diagram or notation
Suppose also there exist three distinct points
Source diagram or notation
in the same interval
Source diagram or notation
such that
Source diagram or notation
Which of the following statements must be true?
6406537086699.Source diagram or notation
is both convex and concave on
Source diagram or notation
.
6406537086700.Source diagram or notation
is affine (a straight line) on
Source diagram or notation
.
6406537086701.Source diagram or notation
is neither convex nor concave on
Source diagram or notation
.
6406537086702.Source diagram or notation
violates Jensen's inequality for every pair of points in
Source diagram or notation
.

Published solution

**1. Recognize a weighted chord:** Since \(x_1<x_2<x_3\), write \(x_2=\lambda x_1+(1-\lambda)x_3\), where \(\lambda=(x_3-x_2)/(x_3-x_1)\) lies between 0 and 1. **2. Test convexity:** A convex function must satisfy \(f(x_2)\leq\lambda f(x_1)+(1-\lambda)f(x_3)\). The first displayed strict inequality is in the opposite direction, so f is not convex on the interval. **3. Test concavity:** A concave function must lie on or above every chord. The second triple gives a point strictly below its chord, so f is not concave either. One counterexample is enough to disprove each global property; the inequalities need not fail for every pair. **Answer: C.** A: **Incorrect:** Both global properties are contradicted by the displayed inequalities. B: **Incorrect:** An affine function lies exactly on every chord, whereas these inequalities are strict. C: **Correct:** The first triple disproves convexity and the second disproves concavity. D: **Incorrect:** The information supplies particular violations, not a violation for every pair.

Report a correction for Q10

Question 11 MCQ · 3.0 marks

A GAN is trained on images preprocessed using the following PyTorch transformation:
Source diagram or notation
Which of the following activation functions are most suitable for the final layers of the Generator and Discriminator, respectively?
6406537086711.
Tanh, Sigmoid
6406537086712.
Sigmoid, Tanh
6406537086713.
ReLU, Sigmoid
6406537086714.
Tanh, Tanh
6406537086715.
Sigmoid, Sigmoid
6406537086716.
ReLU, ReLU

Published solution

**1. Find the target image range:** ToTensor gives values in [0,1]. Normalize((0.5,),(0.5,)) applies \((x-0.5)/0.5=2x-1\), mapping the range to [-1,1]. **2. Choose the generator output:** Tanh produces values between -1 and 1, matching the normalized image range and allowing both negative and positive pixel values. **3. Choose the discriminator output:** A standard probability-based GAN discriminator uses sigmoid to produce a real/fake probability between 0 and 1. A logits-based loss may incorporate sigmoid internally, but among the listed activation pairs the intended answer is Tanh, Sigmoid. **Answer: A.** A: **Correct:** Tanh matches the image scale and sigmoid matches a probability output. B: **Incorrect:** The generator cannot cover negative normalized pixel values with sigmoid, while tanh is not a probability range. C: **Incorrect:** ReLU excludes negative values and is unbounded above. D: **Incorrect:** The discriminator probability should not be allowed to become negative. E: **Incorrect:** Sigmoid restricts generated pixels to [0,1], missing the negative half of the target range. F: **Incorrect:** ReLU is unsuitable for both the centered image range and a bounded probability.

Report a correction for Q11

Question 12 MSQ · 2.0 marks

Select the correct statements from the following:
6406537086733.
If the sequence length doubles while all model hyperparameters remain unchanged, the number of trainable parameters in the RNN also doubles.
6406537086734.
The hidden state at time step
Source diagram or notation
depends on both the current input
Source diagram or notation
and the hidden state from the previous time step
Source diagram or notation
.
6406537086735.
The same input-to-hidden and hidden-to-hidden weight matrices are reused at every time step, regardless of the sequence length.
6406537086736.
An RNN can process sequences of arbitrary length only if the input size changes with the sequence length.

Published solution

**1. Recall the recurrent update:** A basic RNN uses \(h_t=\phi(W_{xh}x_t+W_{hh}h_{t-1}+b)\). Current input and previous hidden state jointly determine the new hidden state. **2. Explain parameter sharing:** The same matrices and biases are used at every time step. A longer input repeats the computation more times but does not create new copies of the trainable parameters. **3. Distinguish dimensions:** Sequence length counts time steps. Input size counts features per step. An RNN can process a different number of steps while keeping this feature size fixed. **Answer: B, C.** A: **Incorrect:** Longer sequences increase computation, not the number of shared trainable weights. B: **Correct:** Both terms appear explicitly in the recurrent update. C: **Correct:** Sharing these matrices across time is a defining feature of the RNN. D: **Incorrect:** The per-step feature size does not need to change when the number of steps changes.

Report a correction for Q12

Question 13 MSQ · 2.0 marks

Which of the following increase(s) the output size?
6406537086745.
Increasing kernel size
6406537086746.
Increasing padding
6406537086747.
Increasing stride

Published solution

**1. Write the convolution-size formula:** For one spatial dimension, dilation 1 and ordinary convolution, \[O=\left\lfloor\frac{N+2P-K}{S}\right\rfloor+1,\] where N is input size, P is padding, K is kernel size and S is stride. **2. Vary one quantity at a time:** Increasing padding enlarges the numerator, allowing more output locations. Increasing the kernel uses more input per location and reduces available positions. Increasing stride samples positions less frequently and generally reduces output size. **3. Account for rounding:** The floor can make a small change leave the size unchanged, but padding is the listed parameter whose increase can enlarge the ordinary convolution output. **Answer: B.** A: **Incorrect:** A larger ordinary-convolution kernel generally reduces output size when the other quantities are fixed. B: **Correct:** Extra padding adds border positions and can increase the number of valid kernel placements. C: **Incorrect:** A larger stride generally reduces the number of sampled output locations.

Report a correction for Q13

Question 14 MSQ · 2.0 marks

Select all statements that are TRUE.
6406537086758.
A twice-differentiable function
Source diagram or notation
is convex if and only if its Hessian is positive semidefinite at every point of its (convex) domain.
6406537086759.
The intersection of two convex sets is convex, but the union of two convex sets need not be.
6406537086760.
If every local minimum of a function is also a global minimum, the function must be convex.
6406537086761.
For a convex differentiable
Source diagram or notation
, every stationary point (
Source diagram or notation
) is a global minimizer.
6406537086762.
The function
Source diagram or notation
provides a counterexample to the claim "every stationary point is a minimum."

Published solution

**1. Use the Hessian test:** For a twice-differentiable function on the usual open convex domain, convexity is equivalent to \(z^T\nabla^2 f(x)z\geq0\) for every x and direction z. This is positive semidefiniteness of the Hessian. **2. Test set operations:** If two points belong to both convex sets, their connecting segment belongs to both sets; hence their intersection is convex. A union can fail: the union of two separated intervals has a gap. **3. Use the first-order inequality:** For differentiable convex f, \(f(y)\geq f(x)+\nabla f(x)^T(y-x)\). At a stationary point the gradient is zero, giving \(f(y)\geq f(x)\) for every y. **4. Avoid false converses:** Having no nonglobal local minima does not imply convexity; \(x^3\) on the real line has no local minima yet is not convex on the whole line. Also, \(g(x)=\cos(\pi x)\) has g'(0)=0 and g''(0)=-\pi^2<0, so x=0 is a stationary maximum. **Answer: A, B, D, E.** A: **Correct:** The positive-semidefinite Hessian test characterizes smooth convex functions under the standard domain assumptions. B: **Correct:** Intersection preserves every connecting segment, whereas a union need not. C: **Incorrect:** The property about local minima is not sufficient to prove convexity. D: **Correct:** At a zero gradient, the convex first-order inequality proves global minimality. E: **Correct:** Cosine has stationary maxima as well as minima; x=0 is a concrete counterexample.

Report a correction for Q14

Question 15 MSQ · 4.0 marks

A standard LSTM layer with a hidden dimension of
Source diagram or notation
processes a sequence. At time step
Source diagram or notation
, the network computes the forget gate
Source diagram or notation
, the input gate
Source diagram or notation
, and the candidate cell state
Source diagram or notation
. Assuming standard activation functions (used in standard LSTM) and infinite-precision arithmetic, which of the following combinations of intermediate vectors are mathematically possible? Select all that apply.
6406537086737.Source diagram or notation
Source diagram or notation
Source diagram or notation
6406537086738.Source diagram or notation
Source diagram or notation
Source diagram or notation
6406537086739.Source diagram or notation
Source diagram or notation
Source diagram or notation
6406537086740.Source diagram or notation
Source diagram or notation
Source diagram or notation

Published solution

**1. Identify activation ranges:** In a standard LSTM, the forget and input gates use sigmoid, so every component is strictly between 0 and 1 for a finite preactivation. The candidate cell uses tanh, so every component is strictly between -1 and 1. The question specifies infinite precision, so numerical saturation cannot justify values outside these ranges. **2. Check dimensions:** The hidden dimension is 3; every displayed gate and candidate vector has three entries. **3. Check each candidate:** A and C satisfy all component-wise range restrictions. B has a forget-gate component 1.05. D has input-gate component -0.05 and candidate-cell component -1.20. These violate their activation ranges. **Answer: A, C.** A: **Correct:** All forget/input entries lie in (0,1), and all candidate entries lie in (-1,1). B: **Incorrect:** The forget-gate value 1.05 cannot be produced by sigmoid. C: **Correct:** All entries satisfy the appropriate strict activation ranges. D: **Incorrect:** A sigmoid gate cannot be negative, and tanh cannot produce -1.20.

Report a correction for Q15

Question 16 MSQ · 3.0 marks

Consider an input
Source diagram or notation
and weights
Source diagram or notation
passing through a single neuron with an activation function. (Assume no bias) Which of the following cases would produce the output as zero?
6406537086741.
The dot product of
Source diagram or notation
and
Source diagram or notation
is zero and the activation function is sigmoid
6406537086742.Source diagram or notation
is a zero vector and the activation function is Relu
6406537086743.Source diagram or notation
is a zero vector and the activation function is Relu
6406537086744.Source diagram or notation
is a zero vector,
Source diagram or notation
is a vector sampled from a Gaussian Distribution and the activation function is tanh.

Published solution

**1. Compute the preactivation:** With no bias, the neuron receives \(z=W^TX\). If either vector is zero, every product in the dot product is zero and therefore z=0. **2. Evaluate the activations at zero:** \[\sigma(0)=\frac{1}{1+e^0}=\frac12,\qquad \operatorname{ReLU}(0)=\max(0,0)=0,\qquad \tanh(0)=0.\] **3. Apply the cases:** A zero dot product does not make sigmoid zero. Zero weights or zero inputs followed by ReLU do give zero. Zero weights followed by tanh also give zero, regardless of a Gaussian-distributed input. **Answer: B, C, D.** A: **Incorrect:** Sigmoid at zero is one-half, not zero. B: **Correct:** Zero weights make the dot product zero, and ReLU(0)=0. C: **Correct:** Zero inputs make the dot product zero, and ReLU(0)=0. D: **Correct:** Zero weights make the Gaussian input irrelevant; tanh(0)=0.

Report a correction for Q16

Question 17 MSQ · 3.0 marks

Which of the following code snippets correctly flatten the image given in the code below?
Source diagram or notation
6406537086748.Source diagram or notation
6406537086749.Source diagram or notation
6406537086750.Source diagram or notation
6406537086751.Source diagram or notation
6406537086752.Source diagram or notation

Published solution

**1. Count the elements:** The image tensor has shape (3,128,128), so it contains \(3\times128\times128=49,152\) entries. **2. Explain flattening:** Flattening preserves all entries while replacing the three dimensions by one dimension of length 49,152. image.flatten(), image.reshape(-1), and image.view(-1) all achieve this for the contiguous tensor created here. The -1 asks PyTorch to infer the required length. **3. Distinguish dimension insertion/removal:** unsqueeze(0) inserts a new size-one dimension, producing (1,3,128,128). squeeze(0) cannot remove the first dimension because its size is 3; the tensor remains three-dimensional. **Answer: A, B, C.** A: **Correct:** flatten combines all dimensions into a single dimension. B: **Correct:** reshape(-1) infers a one-dimensional shape containing all elements. C: **Correct:** view(-1) is valid for this contiguous tensor and gives the same flattened shape. D: **Incorrect:** unsqueeze adds an axis; it does not flatten existing axes. E: **Incorrect:** squeeze cannot remove an axis of size 3 and does not flatten the tensor.

Report a correction for Q17

Question 18 MSQ · 3.0 marks

Select **all** statements that are TRUE regarding the mechanics of Adagrad and RMSProp.
6406537086753.
Assuming a constant base learning rate, Adagrad's squared-gradient accumulator only grows (or stays the same), meaning a parameter's effective learning rate can never increase over time.
6406537086754.
In RMSProp, a parameter's effective learning rate can actually increase again if it starts receiving much smaller gradients than it did previously.
6406537086755.
For sparse features (which rarely receive non-zero gradients), Adagrad forces the effective learning rate to decay much more slowly compared to frequently updated dense features.
6406537086756.
Over a very long training run, RMSProp's accumulator eventually converges to the total sum of all squared gradients seen during training.
6406537086757.
Changing Adagrad's infinite cumulative sum into an exponentially decaying average is exactly the modification that creates RMSProp and solves the vanishing learning rate problem.

Published solution

**1. Adagrad:** For a coordinate, its accumulator is \(G_t=G_{t-1}+g_t^2\). Its effective step coefficient is \(\eta/(\sqrt{G_t}+\epsilon)\). Because each squared gradient is nonnegative, G cannot decrease, and this coefficient cannot increase when the base rate is fixed. **2. Sparse features:** A rarely updated coordinate receives fewer nonzero additions to G. Its learning-rate coefficient therefore tends to decay more slowly than that of a frequently updated coordinate. **3. RMSProp:** Replace the cumulative sum by \(V_t=\rho V_{t-1}+(1-\rho)g_t^2\), with \(0<\rho<1\). Older contributions decay. If new gradients become smaller, V can fall and the effective coefficient can rise again. It is an exponentially weighted average, not the total historical sum. This addresses Adagrad's continually shrinking coefficient; it does not guarantee successful optimization in every problem. **Answer: A, B, C, E.** A: **Correct:** The cumulative sum of nonnegative squares cannot decrease. B: **Correct:** Smaller recent squared gradients can lower the moving average and raise the effective coefficient. C: **Correct:** Sparse coordinates accumulate squared-gradient history less often. D: **Incorrect:** RMSProp discounts old contributions rather than accumulating their full sum forever. E: **Correct:** Using a decaying average instead of the cumulative sum is the central RMSProp change.

Report a correction for Q18

Question 19 NAT · 3.0 marks

Calculate the total number of parameters in the RNN implemented in the following code:
Source diagram or notation

Published solution

**1. Identify the layer dimensions:** The RNN has input_size=12, hidden_size=32, num_layers=3 and bias=False. It is unidirectional. **2. First layer:** Its input-to-hidden matrix has \(32\times12=384\) weights. Its hidden-to-hidden matrix has \(32\times32=1,024\) weights. Total: \(384+1,024=1,408\). **3. Second and third layers:** Each receives 32 features from the preceding layer. Each therefore has \(32\times32+32\times32=2,048\) weights. Together they contribute \(2\times2,048=4,096\). **4. Add the layers:** \(1,408+4,096=5,504\). Biases contribute zero because bias=False. Sequence length and batch size do not multiply the number of shared parameters. **Answer: 5504.**

Report a correction for Q19

Question 20 NAT · 3.0 marks

A single LSTM layer has input (embedding) dimension
Source diagram or notation
and hidden dimension
Source diagram or notation
. Its three gates (forget, input, output) and its candidate cell state all operate on the concatenation
Source diagram or notation
. Counting all weights and biases (ignore the embedding table and any output layer), how many trainable parameters does the layer have?

Published solution

**1. Count one gate's inputs:** Each gate receives the current input of dimension d=100 and previous hidden state of dimension m=128. The concatenated vector therefore has \(100+128=228\) entries. **2. Count one gate/candidate block:** A block produces 128 values, requiring \(128\times228=29,184\) weights and 128 biases. Thus one block has \(29,184+128=29,312\) parameters. **3. Count all four blocks:** The forget, input and output gates plus candidate cell use independent parameter blocks. Therefore \[N=4m(d+m+1)=4\times128\times(100+128+1)=4\times29,312=117,248.\] This counts one bias per output unit per block, as specified by the concatenated affine-map formulation. A library implementation storing two separate bias vectors per block would have a different raw parameter count. **Answer: 117248.**

Report a correction for Q20

Question 21 NAT · 2.0 marks

Consider a Language Model which completes a sentence by generating the next words one by one following the given rule:
Source diagram or notation
For the given sentence: 'Mumbai is a beautiful coastal city' If the vocabulary size is 20, how many conditional probabilities are computed in total while generating the remaining words of the sentence? Assume "Mumbai" is already given as input.

Published solution

**1. Count the words to generate:** The sentence has six words: Mumbai / is / a / beautiful / coastal / city. Mumbai is already supplied, so five words remain. **2. Interpret the vocabulary:** At each generation step, the model computes a conditional distribution over all 20 vocabulary words. Conditioning on the preceding two words changes the inputs to that distribution, not its number of entries. **3. Multiply the counts:** Five steps, each with 20 conditional probabilities, give \(5\times20=100\). We do not multiply by \(20^5\): the model generates one successive path, rather than explicitly evaluating every possible five-word continuation. No extra end-of-sentence step is requested. **Answer: 100.**

Report a correction for Q21