MauryaHub PYQ Practice

Deep Learning · End Term · Sep 2025 · AN

Deep Learning · End Term · Sep 2025 AN

← 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.

16 / 16 published solutions

Question 2 MCQ · 3.0 marks

What is a co-occurrence matrix in the context of Natural Language Processing?
6406536034645.
A matrix representing similarity scores between documents
6406536034646.
A matrix where rows and columns represent words, and each cell indicates how frequently two words appear together in a context
6406536034647.
A matrix that stores only the most frequent word in each document
6406536034648.
A neural network used to compute word embeddings directly

Published solution

**1. Define co-occurrence:** Two words co-occur when they appear within a chosen context, such as a fixed window or a document. A word–context matrix records how often each vocabulary word appears near each context word. **2. Interpret one entry:** Xᵢⱼ is a count or weighted count for word i with context j. Similar row patterns can later be used to learn distributional representations, but the count matrix itself is not a neural network. **Answer: B — A matrix where rows and columns represent words, and each cell indicates .** A: **Incorrect:** Document similarity is a different matrix whose axes are documents rather than word–context pairs. B: **Correct:** It correctly identifies the word axes and the meaning of each co-occurrence count. C: **Incorrect:** The matrix records pairwise context statistics, not just one most-frequent word. D: **Incorrect:** It is a data representation that can feed a model or factorization, not a network by itself.

Report a correction for Q2

Question 3 MCQ · 3.0 marks

Which of the following is not true about multi-head cross attention?
6406536034649.
Keys and values are taken from the encoder outputs
6406536034650.
Queries come from the decoder outputs
6406536034651.
All heads attend to identical features due to shared projection matrices
6406536034652.
Each head learns to attend to different representation subspaces

Published solution

**1. Identify the two information sources:** In encoder–decoder cross-attention, decoder hidden representations supply queries, while encoder representations supply keys and values. The decoder asks which source positions are relevant to its current generation state. **2. Explain multiple heads:** Head i learns its own projections WᵢQ,WᵢK,WᵢV. Its output is attention(QWᵢQ,KWᵢK,VWᵢV), allowing different learned feature subspaces. **3. Select the false statement:** The heads do not have to use identical projections or attend to identical features. Therefore C is the statement that is not true. **Answer: C — the claim that all heads use shared projections and identical features is false.** A: **Incorrect:** This statement is true for standard encoder–decoder cross-attention, so do not select it. B: **Incorrect:** This statement is true when decoder outputs means decoder-side hidden representations. C: **Correct:** Select this false statement: standard heads use distinct learned projection sets, not mandatory shared identical ones. D: **Incorrect:** This describes the intended distinct-subspace mechanism, so it is not the false option.

Report a correction for Q3

Question 4 MCQ · 3.0 marks

Consider the masked self-attention mechanism in the decoder of the Transformer architecture. Let
Source diagram or notation
be the **additive mask matrix** applied to the scaled dot-product scores (logits) before the softmax operation. If the sequence length is
Source diagram or notation
, what is the summation of all the diagonal elements of
Source diagram or notation
(i.e.,
Source diagram or notation
)?
6406536034653.Source diagram or notation
6406536034654.Source diagram or notation
6406536034655.
0
6406536034656.Source diagram or notation
6406536034657.
Indeterminate

Published solution

**1. Write the additive causal mask:** For query position i and key position j, \[M_{ij}=\begin{cases}0,&j\le i,\\-\infty,&j>i.\end{cases}\] Adding −∞ before softmax makes a future-position weight zero. **2. Check the diagonal:** Every diagonal entry corresponds to j=i, so attending to the current position is allowed and Mᵢᵢ=0. **3. Sum the entries:** There are t diagonal positions, each zero. Hence \(\sum_{i=1}^tM_{ii}=0\). The forbidden future positions lie strictly above the diagonal. **Answer: C — 0.** A: **Incorrect:** Negative infinity occurs above the diagonal, not on the allowed diagonal. B: **Incorrect:** The diagonal does not contain positive infinities. C: **Correct:** All allowed diagonal entries of an additive mask are zero. D: **Incorrect:** A diagonal sum t would describe ones, not zeros in an additive mask. E: **Incorrect:** The explicitly defined mask convention makes the sum determinate.

Report a correction for Q4

Question 5 MCQ · 3.0 marks

Consider an input of
Source diagram or notation
grayscale images. Two neural network architectures are proposed: • **Model A:** The input is flattened into a 64-dimensional vector, followed by a fully-connected layer with 10 neurons **with bias**. • **Model B:** A sequence of convolution layers **without bias**: – **Conv1:** 8 filters of size 3×3, stride = 1, no padding. – **Conv2:** 10 filters of size 3×3, stride = 2, padding = 1. The output is passed through a 3×3 average pooling layer. Let
Source diagram or notation
and
Source diagram or notation
denote the total number of learnable parameters in **Model A** and **Model B** respectively. Which of the following relationships is correct?
6406536034658.Source diagram or notation
6406536034659.Source diagram or notation
6406536034660.Source diagram or notation
6406536034661.
Cannot be determined

Published solution

**1. Count Model A:** Flattening the 8×8 grayscale input gives 64 features. A 10-neuron dense layer with biases has \[P_A=(64+1)10=650.\] **2. Count Model B:** Conv1 has 8 filters, each 3×3×1, giving 9×1×8=72 weights. Conv2 receives eight channels and has ten 3×3 filters, giving 9×8×10=720. With no biases, total \(P_B=72+720=792\). **3. Exclude nontrainable operations and compare:** Average pooling has no learned weights. Stride and padding change output dimensions but not the filter counts. Therefore 650<792 and P_A<P_B. **Answer: C — P_A<P_B: 650<792.** A: **Incorrect:** 650 is smaller than 792, not larger. B: **Incorrect:** The two counts are 650 and 792, so they are unequal. C: **Correct:** The convolutional model has 142 more parameters in this particular architecture. D: **Incorrect:** All kernel sizes, channel counts, neuron counts and bias conventions are supplied.

Report a correction for Q5

Question 6 MCQ · 3.0 marks

Regarding the specific gating mechanisms used to control information flow and gradients in LSTMs and GRUs, which statement is correct?
6406536034662.
GRUs use a three-gate architecture (Input, Forget, Output) similar to LSTMs but remove the cell state
6406536034663.
LSTMs couple the input and forget gates into a single 'update' gate, whereas GRUs keep them separate.
6406536034664.
GRUs simplify the architecture by combining the forget and input gates into a single 'update' gate and merging the cell state and hidden state.
6406536034665.
Both LSTMs and GRUs require a separate 'reset' gate to handle the exploding gradient problem explicitly.

Published solution

**1. Recall the LSTM states and gates:** A standard LSTM carries a cell state cₜ and a hidden output hₜ. Separate input, forget and output gates control writing, retaining and exposing cell information. **2. Contrast the GRU:** A standard GRU uses one hidden state rather than a separate cell state. Its update gate balances old state retention against a candidate state, while a reset gate controls how previous state enters the candidate. **3. Match the simplification:** C describes the usual conceptual coupling of write/forget behavior into the GRU update gate and the merged state representation. This is a comparison of architectures, not a claim that every gate directly prevents exploding gradients. **Answer: C — GRUs simplify the architecture by combining the forget and input gates into a .** A: **Incorrect:** The standard GRU uses update and reset gates, not the LSTM’s three named gates. B: **Incorrect:** It reverses the usual architecture comparison. C: **Correct:** It correctly describes the GRU’s coupled update/retention behavior and single state. D: **Incorrect:** A standard LSTM has no separate reset gate, and gradient explosion is not explicitly eliminated by such a gate.

Report a correction for Q6

Question 7 MCQ · 3.0 marks

You are training a neural network with an initial learning rate (
Source diagram or notation
) of 0.1. The training setup involves a batch size of 64, resulting in 100 mini-batch updates per epoch. You utilize a "Step Decay" schedule where the learning rate is halved (multiplied by 0.5) after every 150 mini-batch updates. What will be the learning rate at the completion of the second epoch?
6406536034666.
0.1
6406536034667.
0.05
6406536034668.
0.025
6406536034669.
0.0125

Published solution

**1. Count optimizer updates:** Two epochs at 100 mini-batch updates per epoch give 200 updates. Batch size 64 determines how many examples each update uses, not the number of decay events. **2. Count completed decay intervals:** With a factor-0.5 decay every 150 updates, \(k=\lfloor200/150\rfloor=1\) interval has completed. **3. Apply the schedule:** \[\eta=\eta_0(0.5)^k=0.1(0.5)=0.05.\] The second reduction occurs only after 300 updates. **Answer: B — 0.05.** A: **Incorrect:** It ignores the decay at update 150. B: **Correct:** Exactly one halving has occurred by update 200. C: **Incorrect:** It would require two completed 150-update intervals. D: **Incorrect:** It would require three completed decay intervals.

Report a correction for Q7

Question 8 MSQ · 3.0 marks

Why is the sigmoid activation function often preferred over the step activation function in neural networks?
6406536034670.
The sigmoid is differentiable, allowing gradient-based optimization methods like backpropagation.
6406536034671.
The step function is non-differentiable and does not support learning through gradient descent.
6406536034672.
The sigmoid function completely avoids vanishing gradient problems.
6406536034673.
The step function outputs values in the range (0,1), whereas the sigmoid outputs only discrete values {0,1}.

Published solution

**1. Compare local derivatives:** The logistic sigmoid is smooth with derivative \(\sigma\prime(z)=\sigma(z)(1-\sigma(z))\). A step has derivative zero away from its jump and is nondifferentiable at the jump. **2. Connect this to learning:** Backpropagation needs useful derivatives to tell how a small weight change affects the loss. The sigmoid provides such a local signal; the exact step does not support ordinary derivative-based training of its parameters. **3. Check the limitations and ranges:** Sigmoid outputs lie strictly between 0 and 1 for finite inputs, while a step returns 0 or 1. Sigmoid derivatives can still become very small in the tails, so differentiability does not eliminate vanishing gradients. **Answer: A, B — The sigmoid is differentiable, allowing gradient-based optimization methods ; The step function is non-differentiable and does not support learning through .** A: **Correct:** Its smooth derivative makes ordinary gradient-based optimization possible. B: **Correct:** The exact step has a discontinuity and zero derivatives elsewhere, preventing useful ordinary gradient training. C: **Incorrect:** Sigmoid can saturate and contribute to vanishing gradients. D: **Incorrect:** It reverses the two functions’ continuous and discrete output ranges.

Report a correction for Q8

Question 9 MSQ · 3.0 marks

Consider the sigmoid activation function defined as:
Source diagram or notation
Assume that the weight
Source diagram or notation
is a positive quantity (
Source diagram or notation
). Select all the correct statements regarding the parameters
Source diagram or notation
and
Source diagram or notation
:
6406536034674.
Increasing the value of
Source diagram or notation
shifts the sigmoid function to the left (towards negative infinity).
6406536034675.
Increasing the value of
Source diagram or notation
shifts the sigmoid function to the right (towards positive infinity).
6406536034676.
Increasing the value of
Source diagram or notation
increases the slope of the sigmoid function.
6406536034677.
Increasing the value of
Source diagram or notation
decreases the slope of the sigmoid function.

Published solution

**1. Locate the midpoint:** For \(f(x)=1/(1+e^{-(wx+b)})\), the output equals 1/2 when wx+b=0, so \(x_{mid}=-b/w\). With w>0 fixed, increasing b moves this midpoint left. **2. Quantify steepness:** Differentiating gives \(f\prime(x)=w f(x)(1-f(x))\). Its maximum occurs at the midpoint and equals w/4. Increasing positive w therefore makes the transition steeper. **3. Apply the interpretations:** The correct effects are a left shift for increasing b and increased transition steepness for increasing w. **Answer: A, C — increasing b shifts left; increasing w steepens the transition.** **Convention note:** Slope here means the sigmoid transition’s steepness or maximum slope. At a particular fixed x deep in a tail, increasing w need not increase that point’s derivative. A: **Correct:** For fixed positive w, −b/w decreases as b increases, moving the curve left. B: **Incorrect:** The midpoint moves left rather than right when b increases. C: **Correct:** The maximum transition slope is w/4 and rises with w. D: **Incorrect:** A larger positive w increases transition steepness rather than decreasing it.

Report a correction for Q9

Question 10 NAT · 4.0 marks

Consider a simplified Image Captioning model with the following architecture: **1. Encoder (CNN):** • **Input:** A grayscale image (1 channel). • **Convolution Layer:** 2 filters, kernel size
Source diagram or notation
, stride
Source diagram or notation
, padding
Source diagram or notation
(ignore bias). • **Pooling:** Global Average Pooling (output is a vector of size equal to the number of filters). **2. Decoder (RNN):** • **Initial hidden state:** The output vector from the Encoder is fed directly into the RNN as initial hidden state
Source diagram or notation
. • **Input:** Assume input
Source diagram or notation
vector dimension as
Source diagram or notation
. • **RNN Layer:** A standard Vanilla RNN cell. The recurrence formula is:
Source diagram or notation
• **Output Layer:** A fully connected softmax layer mapping the final hidden state to a vocabulary of size
Source diagram or notation
(bias enabled). Calculate the **total** number of trainable parameters in this entire architecture. (Note: Exclude bias parameters for the CNN Encoder, but include them for the RNN and Output layers.)

Published solution

**1. Count the encoder filters:** The grayscale input has one channel. Two 3×3 filters without bias have \(3\cdot3\cdot1\cdot2=18\) weights. Global average pooling adds no parameters and outputs a two-component vector. **2. Infer the decoder hidden size:** Because the pooled vector is fed directly into s₀, the RNN hidden size is h=2. With input dimension d=4, its input matrix U has 2×4=8 weights, recurrent matrix W has 2×2=4, and bias b has 2, totaling 14. **3. Add vocabulary projection:** Vocabulary size is 3, so the output layer has 3×2=6 weights plus 3 biases, totaling 9. **4. Sum:** \[P_{total}=18+14+9=41.\] No separate learned initialization projection is specified or needed because the dimensions already match. **Answer: 41.**

Report a correction for Q10

Question 11 NAT · 2.0 marks

You are given a simplified Continuous Bag-of-Words (CBOW) model designed to predict a missing word represented as **???** in the sentence given below based on its context. The sentence is: **red green ??? are colors** Vocabulary = {0 : are , 1 : blue , 2 : colors , 3 : green , 4 : pink , 5 : red , 6 : white, 7 : yellow } Use the one-hot vector representation of each word in the sentence, represented in the matrix below of size
Source diagram or notation
, where each column corresponds to the one-hot vector of size V=8 of a word.
Source diagram or notation
The model's weight matrices are given below: **Context Weight Matrix (**
Source diagram or notation
**):**
Source diagram or notation
**Word Matrix (**
Source diagram or notation
**):**
Source diagram or notation
For a one hot representation (
Source diagram or notation
) of a word , the context embedding is given by :
Source diagram or notation
The combined context representation
Source diagram or notation
is obtained by summing the embeddings of all context words in a window of size d:
Source diagram or notation
Based on the above data, answer the given subquestions.
What is the combined context representation
Source diagram or notation
of the missing word represented as "**???**" for a window of size
Source diagram or notation
(
Source diagram or notation
tokens from both the sides). Sum all the values in
Source diagram or notation
and provide the answer correct up to two decimal places.

Published solution

**1. Build the summed context:** The two tokens on each side are red, green, are and colors, with indices 5,3,0,2. Their context columns are (1,2),(−0.5,−1),(−2,−4),(−1,−2). The specified CBOW operation sums rather than averages them, yielding \[h=(1-0.5-2-1,\;2-1-4-2)^T=(-2.5,-5)^T.\] **2. Sum the representation’s coordinates:** The question asks for the sum of h, not the output logits. Thus \(h_1+h_2=-2.5-5=-7.50\). Averaging the four context vectors would change this result and is not the supplied rule. **Answer: -7.50.**

Report a correction for Q11

Question 12 NAT · 2.0 marks

You are given a simplified Continuous Bag-of-Words (CBOW) model designed to predict a missing word represented as **???** in the sentence given below based on its context. The sentence is: **red green ??? are colors** Vocabulary = {0 : are , 1 : blue , 2 : colors , 3 : green , 4 : pink , 5 : red , 6 : white, 7 : yellow } Use the one-hot vector representation of each word in the sentence, represented in the matrix below of size
Source diagram or notation
, where each column corresponds to the one-hot vector of size V=8 of a word.
Source diagram or notation
The model's weight matrices are given below: **Context Weight Matrix (**
Source diagram or notation
**):**
Source diagram or notation
**Word Matrix (**
Source diagram or notation
**):**
Source diagram or notation
For a one hot representation (
Source diagram or notation
) of a word , the context embedding is given by :
Source diagram or notation
The combined context representation
Source diagram or notation
is obtained by summing the embeddings of all context words in a window of size d:
Source diagram or notation
Based on the above data, answer the given subquestions.
Identify the word in the vocabulary with the highest predicted probability for the missing word (???), and provide its corresponding **integer index (key)** from the vocabulary list as your final answer.

Published solution

**1. Build the summed context:** The two tokens on each side are red, green, are and colors, with indices 5,3,0,2. Their context columns are (1,2),(−0.5,−1),(−2,−4),(−1,−2). The specified CBOW operation sums rather than averages them, yielding \[h=(1-0.5-2-1,\;2-1-4-2)^T=(-2.5,-5)^T.\] **2. Compute each word score:** Dotting the rows of W_word with h gives \[z=(0,-7.5,7.5,13.75,11.25,-2.5,17.5,2.5)^T.\] For example, white uses (−1,−3), giving (−1)(−2.5)+(−3)(−5)=17.5. **3. Choose the highest-probability word:** Softmax preserves the order of these scores. The maximum is 17.5 at index 6, white, so the requested integer answer is 6. **Answer: 6.**

Report a correction for Q12

Question 13 NAT · 2.0 marks

You are given a simplified Continuous Bag-of-Words (CBOW) model designed to predict a missing word represented as **???** in the sentence given below based on its context. The sentence is: **red green ??? are colors** Vocabulary = {0 : are , 1 : blue , 2 : colors , 3 : green , 4 : pink , 5 : red , 6 : white, 7 : yellow } Use the one-hot vector representation of each word in the sentence, represented in the matrix below of size
Source diagram or notation
, where each column corresponds to the one-hot vector of size V=8 of a word.
Source diagram or notation
The model's weight matrices are given below: **Context Weight Matrix (**
Source diagram or notation
**):**
Source diagram or notation
**Word Matrix (**
Source diagram or notation
**):**
Source diagram or notation
For a one hot representation (
Source diagram or notation
) of a word , the context embedding is given by :
Source diagram or notation
The combined context representation
Source diagram or notation
is obtained by summing the embeddings of all context words in a window of size d:
Source diagram or notation
Based on the above data, answer the given subquestions.
In this setup, during backpropagation with cross-entropy loss, how many total weights (combining both
Source diagram or notation
and
Source diagram or notation
) are updated in a single iteration? Assume that any one word from the vocabulary can be the correct output.

Published solution

**1. Build the summed context:** The two tokens on each side are red, green, are and colors, with indices 5,3,0,2. Their context columns are (1,2),(−0.5,−1),(−2,−4),(−1,−2). The specified CBOW operation sums rather than averages them, yielding \[h=(1-0.5-2-1,\;2-1-4-2)^T=(-2.5,-5)^T.\] **2. Count affected context parameters:** Four distinct one-hot context words select four columns of the 2×8 context matrix. Each selected column has two weights, giving 4×2=8 context weights reached by backpropagation. **3. Count full-softmax output parameters:** The 8×2 word matrix participates for all eight classes under cross-entropy, not only for the target word. Both hidden coordinates are nonzero, so all 16 output weights are involved. **4. Add distinct weights:** \[8+16=24.\] Unselected context columns have zero data gradient in this iteration. **Answer: 24.** **Convention note:** This counts weights receiving data-gradient updates for the stated full-softmax CBOW step, excluding extra mechanisms such as weight decay or negative sampling.

Report a correction for Q13

Question 14 MCQ · 1.0 marks

Given the following simple Recurrent Neural Network (RNN), which is unrolled for two timesteps. The network's forward propagation is defined by the following equations:
Source diagram or notation
Source diagram or notation
Where the hidden activation
Source diagram or notation
is the sigmoid function, and the output activation
Source diagram or notation
is a softmax function. The network's parameters (
Source diagram or notation
) are shared across all timesteps.
Source diagram or notation
The initial hidden state
Source diagram or notation
, the input sequence (
Source diagram or notation
), the network parameters, and the target sequence (
Source diagram or notation
) are given in the table below. Note that for this simple network, all variables are scalars.
Source diagram or notation
Based on the above data, answer the given subquestions.
Compute the output
Source diagram or notation
at the first timestep (
Source diagram or notation
). Choose the closest option from below
6406536034682.Source diagram or notation
6406536034683.Source diagram or notation
6406536034684.Source diagram or notation
6406536034685.Source diagram or notation

Published solution

**1. Compute the first hidden state:** With s₀=0,x₁=1,U=0.5,W=0.2, \(a_1=Ux_1+Ws_0=0.5\) and \(s_1=\sigma(0.5)=0.622459331\). The output table gives V=(1,−1)ᵀ, so logits are (s₁,−s₁). **2. Compute the first output distribution:** \[o_1=\operatorname{softmax}(s_1,-s_1)\approx(0.776419,0.223581)^T.\] Equivalently its first probability is σ(2s₁). **Answer: A — o₁≈(0.78,0.22)ᵀ.** **Convention note:** Although the prose says all variables are scalars, the table explicitly supplies a two-entry V and two-class targets. Use that table: hidden states are scalar and output probabilities are two-dimensional. A: **Correct:** It is the closest listed distribution to (0.7764,0.2236). B: **Incorrect:** It is closer to the second-time-step output than to o₁. C: **Incorrect:** It does not match softmax of the first hidden-state logits. D: **Incorrect:** It incorrectly gives the negative-logit class the larger probability.

Report a correction for Q14

Question 15 MCQ · 1.0 marks

Given the following simple Recurrent Neural Network (RNN), which is unrolled for two timesteps. The network's forward propagation is defined by the following equations:
Source diagram or notation
Source diagram or notation
Where the hidden activation
Source diagram or notation
is the sigmoid function, and the output activation
Source diagram or notation
is a softmax function. The network's parameters (
Source diagram or notation
) are shared across all timesteps.
Source diagram or notation
The initial hidden state
Source diagram or notation
, the input sequence (
Source diagram or notation
), the network parameters, and the target sequence (
Source diagram or notation
) are given in the table below. Note that for this simple network, all variables are scalars.
Source diagram or notation
Based on the above data, answer the given subquestions.
Compute the output
Source diagram or notation
at the second timestep (
Source diagram or notation
). Choose the closest option from below
6406536034686.Source diagram or notation
6406536034687.Source diagram or notation
6406536034688.Source diagram or notation
6406536034689.Source diagram or notation

Published solution

**1. Compute the first hidden state:** With s₀=0,x₁=1,U=0.5,W=0.2, \(a_1=Ux_1+Ws_0=0.5\) and \(s_1=\sigma(0.5)=0.622459331\). The output table gives V=(1,−1)ᵀ, so logits are (s₁,−s₁). **2. Compute the first output distribution:** \[o_1=\operatorname{softmax}(s_1,-s_1)\approx(0.776419,0.223581)^T.\] Equivalently its first probability is σ(2s₁). **3. Propagate the second input:** For x₂=2, \(a_2=0.5(2)+0.2(0.622459331)=1.124491866\), so \(s_2=\sigma(a_2)=0.754820961\). The output is \[o_2=\operatorname{softmax}(s_2,-s_2)\approx(0.819008,0.180992)^T.\] **Answer: C — o₂≈(0.82,0.18)ᵀ.** **Convention note:** Use the two-class output vector V supplied in the table despite the prose’s scalar shorthand. A: **Incorrect:** It repeats the first output and ignores the second input and recurrent contribution. B: **Incorrect:** Its entries do not sum to one and are not a valid softmax distribution. C: **Correct:** It is the closest option to the computed second-time-step probabilities. D: **Incorrect:** It reverses the preference for the positive-logit class.

Report a correction for Q15

Question 16 NAT · 1.0 marks

Given the following simple Recurrent Neural Network (RNN), which is unrolled for two timesteps. The network's forward propagation is defined by the following equations:
Source diagram or notation
Source diagram or notation
Where the hidden activation
Source diagram or notation
is the sigmoid function, and the output activation
Source diagram or notation
is a softmax function. The network's parameters (
Source diagram or notation
) are shared across all timesteps.
Source diagram or notation
The initial hidden state
Source diagram or notation
, the input sequence (
Source diagram or notation
), the network parameters, and the target sequence (
Source diagram or notation
) are given in the table below. Note that for this simple network, all variables are scalars.
Source diagram or notation
Based on the above data, answer the given subquestions.
Assume this network is used for email spam detection. Compute the cross entropy loss
Source diagram or notation
at the final time step (
Source diagram or notation
). Provide the answer correct to two decimal places.

Published solution

**1. Compute the first hidden state:** With s₀=0,x₁=1,U=0.5,W=0.2, \(a_1=Ux_1+Ws_0=0.5\) and \(s_1=\sigma(0.5)=0.622459331\). The output table gives V=(1,−1)ᵀ, so logits are (s₁,−s₁). **2. Compute the first output distribution:** \[o_1=\operatorname{softmax}(s_1,-s_1)\approx(0.776419,0.223581)^T.\] Equivalently its first probability is σ(2s₁). **3. Propagate the second input:** For x₂=2, \(a_2=0.5(2)+0.2(0.622459331)=1.124491866\), so \(s_2=\sigma(a_2)=0.754820961\). The output is \[o_2=\operatorname{softmax}(s_2,-s_2)\approx(0.819008,0.180992)^T.\] **4. Apply target cross-entropy:** The final target is y₂=(0,1)ᵀ. For \(L=-\sum_ky_k\ln o_k\), only its second entry contributes: \[L_2=-\ln(0.1809918665)=1.709303185\ldots\approx1.71.\] Natural logarithms are used, and only the requested final-time-step loss is included. **Answer: 1.71.**

Report a correction for Q16

Question 17 NAT · 3.0 marks

Given the following simple Recurrent Neural Network (RNN), which is unrolled for two timesteps. The network's forward propagation is defined by the following equations:
Source diagram or notation
Source diagram or notation
Where the hidden activation
Source diagram or notation
is the sigmoid function, and the output activation
Source diagram or notation
is a softmax function. The network's parameters (
Source diagram or notation
) are shared across all timesteps.
Source diagram or notation
The initial hidden state
Source diagram or notation
, the input sequence (
Source diagram or notation
), the network parameters, and the target sequence (
Source diagram or notation
) are given in the table below. Note that for this simple network, all variables are scalars.
Source diagram or notation
Based on the above data, answer the given subquestions.
Using the loss used in previous question update the recurrent weight
Source diagram or notation
once using gradient descent and Backpropagation Through Time (BPTT). Use a learning rate of
Source diagram or notation
and the total loss computed previously. Provide the updated weight
Source diagram or notation
correct to two decimal places.

Published solution

**1. Compute the first hidden state:** With s₀=0,x₁=1,U=0.5,W=0.2, \(a_1=Ux_1+Ws_0=0.5\) and \(s_1=\sigma(0.5)=0.622459331\). The output table gives V=(1,−1)ᵀ, so logits are (s₁,−s₁). **2. Compute the first output distribution:** \[o_1=\operatorname{softmax}(s_1,-s_1)\approx(0.776419,0.223581)^T.\] Equivalently its first probability is σ(2s₁). **3. Propagate the second input:** For x₂=2, \(a_2=0.5(2)+0.2(0.622459331)=1.124491866\), so \(s_2=\sigma(a_2)=0.754820961\). The output is \[o_2=\operatorname{softmax}(s_2,-s_2)\approx(0.819008,0.180992)^T.\] **4. Backpropagate the final loss to s₂:** With y₂=(0,1), the softmax-logit gradient is o₂−y₂=(p,−p), where p=0.819008134. Multiplying by Vᵀ=(1,−1) gives \(\partial L_2/\partial s_2=2p=1.638016267\). **5. Include recurrence through shared W:** \[\frac{ds_2}{dW}=s_2(1-s_2)\left(s_1+W\frac{ds_1}{dW}\right).\] Here \(ds_1/dW=s_1(1-s_1)s_0=0\) because s₀=0. Thus \(\partial L_2/\partial W=(2p)s_2(1-s_2)s_1=0.188693301\). **6. Update once:** With η=0.1, \[W_{new}=0.2-0.1(0.188693301)=0.181130670\approx0.18.\] **Answer: 0.18.** **Convention note:** The previous subquestion requests the final-time loss. If a first-time loss were also summed, its W derivative is zero in this particular example because s₀=0, so the same W update results.

Report a correction for Q17