AI Computer Institute
Expert-curated CS & AI curriculum aligned to CBSE standards. A bharath.ai initiative. About Us

Grade 11 AI & Computer Science Practice Questions — Set 7

20 questions from the Grade 11 bank, each with its answer and a full explanation. Set 7 of 11 · 221 questions in this grade.

Reading is revision; testing is practice. Take the same questions as a timed quiz →

Question 121 · Conv2D Parameters · hard

Analyze a Conv2D layer with in_channels=3, out_channels=9, and kernel_size=3×3. Using the formula O×(I×K²+1), what is the total number of learnable parameters?

  1. Parameters = 243, computed by omitting the bias term entirely: 9×(3×3×3) = 243
  2. Parameters = 252, because each of 9 output filters has I×K²=27 weights plus 1 bias: 9×(3×3×3+1) = 252
  3. Parameters = 9, counting only one bias value per output channel while ignoring the kernel weights
  4. Parameters = 27, computed as I×K²=3×3×3 for a single filter without multiplying by the 9 output channels

Answer: B. Parameters = 252, because each of 9 output filters has I×K²=27 weights plus 1 bias: 9×(3×3×3+1) = 252

ExplanationConv2D learnable parameters include both weights and biases. Each of the 9 output filters has a kernel of size 3×3×3 (27 weights) plus 1 bias term, giving 9×(3×3×3+1) = 9×28 = 252 parameters. For comparison, a Conv2D(3, 64, 3) layer in a ResNet has 64×(3×3×3+1) = 1,792 parameters, showing how the output channel count directly scales the total parameter count.

Question 122 · GRU Parameters · hard

Analyze GRU (Gated Recurrent Unit): hidden_size=183, input_size=46. Calculate total parameters, compare with LSTM (4 gates), and evaluate the gate structure Given these specific input parameters, analyze the computational behavior step by step, predict the output values, and evaluate the algorithmic complexity?

  1. GRU has more parameters than LSTM, since 3×(183×(183+46)+183) exceeds 4×(183×(183+46)+183)
  2. Parameters = 8418, only input-to-hidden, computed as 46×183 while ignoring the hidden-to-hidden weights, biases, and the other two GRU gates
  3. Parameters = 4×(183×(183+46)+183) = 168360, applying LSTM's 4-gate formula instead of GRU's 3-gate structure
  4. Parameters = 3×(183×(183+46)+183) = 126270 (3 gates: reset, update, candidate); LSTM has 4×params because it has 4 gates; GRU is more parameter-efficient

Answer: D. Parameters = 3×(183×(183+46)+183) = 126270 (3 gates: reset, update, candidate); LSTM has 4×params because it has 4 gates; GRU is more parameter-efficient

ExplanationGRU has 3 gates (reset r, update z, candidate h'), each with parameters h×(h+x)+h. Total: 3×(183×(183+46)+183) = 126270. LSTM has 4 gates (input, forget, output, candidate), requiring 4×params = 168360. GRU is more parameter-efficient and computationally faster while often matching LSTM performance. Both RNNs address vanishing gradients through gating mechanisms. GRUs are preferred when computational resources are limited; LSTMs are preferred for complex long-range dependencies.

Question 123 · Conv2D Parameters · hard

Analyze a Conv2D layer with in_channels=1, out_channels=10, and kernel_size=4×4. Using the formula Parameters = O×(I×K²+1), what is the total number of learnable parameters?

  1. Parameters = 160, computed as 10×(1×4×4) without including the bias term for each output filter
  2. Parameters = 170, because each of 10 output filters has I×K²=16 weights plus 1 bias: 10×(1×4×4+1) = 170
  3. Parameters = 10, counting only one bias term per output filter and ignoring the kernel weights entirely
  4. Parameters = 16, counting the kernel weights of a single output filter but not multiplying across all 10 filters

Answer: B. Parameters = 170, because each of 10 output filters has I×K²=16 weights plus 1 bias: 10×(1×4×4+1) = 170

ExplanationConv2D learnable parameters include both weights and biases. Each of the 10 output filters has a kernel of size 1×4×4, giving 1×4×4 = 16 weights, plus 1 bias term per filter, for 17 parameters per filter. Multiplying across all 10 output filters gives 10×(1×4×4+1) = 10×17 = 170 total learnable parameters.

Question 124 · Conv2D Parameters · hard

A Conv2D layer has in_channels=2, out_channels=8, and kernel_size=4×4, with bias included in every filter. Using the formula O×(I×K²+1), what is the total number of learnable parameters?

  1. 256, because the bias term is left out of the count: 8×(2×4×4) = 256, which omits the required +1 per filter.
  2. 264, because each of the 8 output filters has I×K²=32 weights plus 1 bias: 8×(2×4×4+1) = 264.
  3. 258, from incorrectly swapping in_channels and out_channels in the formula: 2×(8×4×4+1) = 2×129 = 258.
  4. 72, from using kernel_size as 4 instead of squaring it to 16: 8×(2×4+1) = 8×9 = 72.

Answer: B. 264, because each of the 8 output filters has I×K²=32 weights plus 1 bias: 8×(2×4×4+1) = 264.

ExplanationEach of the 8 output filters convolves over all 2 input channels with a 4×4 kernel, giving I×K² = 2×4×4 = 32 weights per filter, plus 1 bias term per filter. Applying the formula O×(I×K²+1) = 8×(2×4×4+1) = 8×33 = 264 total learnable parameters. Omitting the bias term undercounts to 256, swapping in_channels with out_channels gives 258, and failing to square the kernel size gives 72 — each a different way of misapplying the formula rather than the correct full expansion.

Question 125 · Conv2D Parameters · hard

A Conv2D layer has in_channels=4, out_channels=8, and kernel_size=4×4. Using the formula O×(I×K²+1), calculate the total number of learnable parameters and the memory required to store them as 32-bit floats?

  1. Parameters = 512, since 8×(4×4×4) = 512 without accounting for the bias term, using 2,048 bytes of memory as float32 values
  2. Parameters = 520, because each of the 8 output filters has I×K²+1 = 4×4×4+1 = 65 weights: 8×65 = 520 parameters, requiring 2,080 bytes (≈2.03 KB) as float32 values
  3. Parameters = 8, one per output channel only, ignoring the kernel weights entirely, requiring just 32 bytes of memory as float32 values
  4. Parameters = 64, counting only a single filter's I×K² weights without multiplying by the 8 output channels, requiring 256 bytes of memory as float32 values

Answer: B. Parameters = 520, because each of the 8 output filters has I×K²+1 = 4×4×4+1 = 65 weights: 8×65 = 520 parameters, requiring 2,080 bytes (≈2.03 KB) as float32 values

ExplanationConv2D learnable parameters include both weights and biases. Each of the 8 output filters has a kernel of shape 4×4×4 (in_channels × kernel_height × kernel_width), contributing I×K²=4×4×4=64 weights, plus 1 bias term, for 65 parameters per filter. Applying the formula O×(I×K²+1) = 8×(64+1) = 8×65 = 520 total learnable parameters. Storing each parameter as a 32-bit float requires 4 bytes, so total memory = 520×4 = 2,080 bytes, or about 2.03 KB. For comparison, a Conv2D(3, 64, 3) layer in a typical ResNet has 64×(3×3×3+1) = 1,792 parameters. Parameter and memory calculations like this matter directly for estimating a model's storage footprint and deployment feasibility on memory-constrained devices.

Question 126 · Conv2D Parameters · hard

A Conv2D layer has in_channels=2, out_channels=10, and kernel_size=3×3. Using the formula O×(I×K²+1), what is the total number of learnable parameters in this layer?

  1. Parameters = 180, omitting the bias term: 10×(2×3×3) = 180 weights with no bias added
  2. Parameters = 190, because each of 10 output filters has I×K²=18 weights plus 1 bias: 10×(2×3×3+1) = 190
  3. Parameters = 10, treating the count as equal to the number of output filters while ignoring the kernel weights and bias entirely
  4. Parameters = 18, computed as I×K²=2×3×3 for a single filter, without multiplying by the 10 output filters or adding any bias

Answer: B. Parameters = 190, because each of 10 output filters has I×K²=18 weights plus 1 bias: 10×(2×3×3+1) = 190

ExplanationConv2D learnable parameters consist of weights and biases. Each of the 10 output filters convolves across all 2 input channels using a 3×3 kernel, giving 2×3×3 = 18 weights per filter, plus 1 bias term per filter, for 19 parameters per filter. Total parameters = 10×(2×3×3+1) = 10×19 = 190.

Question 127 · Conv2D Parameters · hard

A Conv2D layer has in_channels=4, out_channels=11, and kernel_size=4×4. Using the formula O×(I×K²+1), what is the total number of learnable parameters, including biases?

  1. 64 parameters, equal to only the weights of a single output filter, since I×K² = 4×4×4 = 64
  2. 704 parameters, equal to 11×(4×4×4) = 704 weights when the bias terms are excluded from the count
  3. 11 parameters, equal to only the bias terms, with the weight count left out entirely
  4. 715 parameters, because each of 11 output filters has I×K²=64 weights plus 1 bias: 11×(4×4×4+1) = 715

Answer: D. 715 parameters, because each of 11 output filters has I×K²=64 weights plus 1 bias: 11×(4×4×4+1) = 715

ExplanationConv2D learnable parameters include both weights and biases. Each of the 11 output filters has a kernel spanning all 4 input channels, so its weight count is I×K² = 4×4×4 = 64, plus 1 bias term per filter. Total: 11×(64+1) = 11×65 = 715 parameters. For comparison, a Conv2D(3, 64, 3) layer in a ResNet uses the same formula: 64×(3×3×3+1) = 1,792 parameters.

Question 128 · Conv2D Parameters · hard

A CNN sequential model stacks two Conv2D layers with bias enabled: the first has in_channels=3, out_channels=32, kernel_size=3×3, and the second takes the first layer's output as its input, with out_channels=64, kernel_size=3×3. Using the standard formula Parameters = out_channels × (in_channels × kernel_height × kernel_width + 1), what is the total number of learnable parameters across both Conv2D layers combined?

  1. The combined total is 19,392 parameters, since the first layer contributes 896 (32×(3×3×3+1)) and the second contributes 18,496 (64×(32×3×3+1))
  2. Only 19,296 parameters are learnable in total, because dropping the bias term in each layer gives 864 + 18,432
  3. Just 18,496 parameters exist across the model, since the second layer's output alone determines the parameter count once the first layer's contribution is disregarded
  4. The total comes to 2,688 parameters, treating both layers as if each independently receives the original 3-channel input, giving 896 + 1,792

Answer: A. The combined total is 19,392 parameters, since the first layer contributes 896 (32×(3×3×3+1)) and the second contributes 18,496 (64×(32×3×3+1))

ExplanationEach Conv2D layer's learnable parameters equal out_channels × (in_channels × kernel_height × kernel_width + 1), where the '+1' accounts for one bias term per output filter, and in_channels must match the number of channels actually feeding into that layer — for the second layer, that's the first layer's 32 output channels, not the original 3-channel input. For the first layer: 32 × (3×3×3 + 1) = 32×28 = 896. For the second layer, whose input is now 32 channels: 64 × (32×3×3 + 1) = 64×289 = 18,496. Summing both layers gives 896 + 18,496 = 19,392 total learnable parameters. Dropping the bias term undercounts each layer by exactly its out_channels — 32 and 64 respectively — yielding 864 + 18,432 = 19,296 instead. Counting only the second layer's parameters ignores the first layer entirely, giving just 18,496. And reusing the original 3-channel input for the second layer's in_channels instead of chaining from the previous layer's 32 output channels collapses that layer to 64×(3×3×3+1) = 1,792, producing a total of 896 + 1,792 = 2,688.

Question 129 · Conv2D Parameters · hard

Analyze this Conv2D layer: in_channels=3, out_channels=13, kernel_size=5×5. Using the formula O×(I×K²+1), what is the total number of learnable parameters?

  1. Parameters = 975, since bias is omitted: 13 filters × (3×5×5) weights = 13×75 = 975
  2. Parameters = 988, because each of 13 output filters has I×K²=75 weights plus 1 bias: 13×(3×5×5+1) = 988
  3. Parameters = 208, if kernel area is mistaken for kernel width: 13×(3×5+1) = 13×16 = 208
  4. Parameters = 75, per output filter, since I×K² = 3×5×5 = 75 before multiplying by the 13 output channels

Answer: B. Parameters = 988, because each of 13 output filters has I×K²=75 weights plus 1 bias: 13×(3×5×5+1) = 988

ExplanationConv2D learnable parameters include weights and biases: each of the 13 output filters has a kernel of size 3×5×5 (75 weights) plus 1 bias term. Total: 13×(3×5×5+1) = 13×76 = 988 parameters.

Question 130 · CNN Architecture and Parameter Counting · hard

You have a convolutional neural network (CNN) layer with input dimensions 32x32x3 (height x width x channels), using 16 filters of kernel size 5x5, stride=1, and padding=0. Calculate the output spatial dimensions, the output depth, and the total number of trainable parameters (weights + biases) in this convolutional layer?

  1. Output: 28x28x16, Parameters: 1,216 — output=(32-5)/1+1=28, params=16*(5*5*3+1)=16*76=1,216
  2. Output: 32x32x16, Parameters: 1,200 — same spatial size with padding, params=16*5*5*3=1,200
  3. Output: 28x28x16, Parameters: 400 — params=16*5*5=400 because filters don't span channels
  4. Output: 28x28x3, Parameters: 1,216 — the depth stays 3 because input has 3 channels

Answer: A. Output: 28x28x16, Parameters: 1,216 — output=(32-5)/1+1=28, params=16*(5*5*3+1)=16*76=1,216

ExplanationOutput spatial size: (W - F + 2P) / S + 1 = (32 - 5 + 0) / 1 + 1 = 28. Output depth = number of filters = 16. So output shape is 28x28x16. Parameters per filter: F*F*C_in + 1 (bias) = 5*5*3 + 1 = 76. Each filter has a 5x5 kernel for EACH of the 3 input channels, plus 1 bias. Total: 16 filters * 76 = 1,216 parameters. Common mistakes: forgetting that each filter spans ALL input channels (option C), forgetting the bias term (option B), or thinking output depth matches input depth (option D).

Question 131 · Backpropagation Through ReLU · hard

During backpropagation through a ReLU activation, the forward pass input was x = [-2, 3, 0, -1, 5] and the incoming gradient from the next layer is dL/dy = [0.5, -0.3, 0.1, 0.4, -0.2]. What is dL/dx?

  1. [0, -0.3, 0, 0, -0.2] — ReLU gradient is 0 where x<=0 and 1 where x>0, so gradient passes through only for positive inputs
  2. [0.5, -0.3, 0.1, 0.4, -0.2] — the gradient passes through unchanged regardless of the input
  3. [-1, 0.9, 0, -0.4, 1.0] — the gradient is multiplied by x instead of the ReLU derivative
  4. [0, -0.3, 0.1, 0, -0.2] — ReLU gradient is 0 where x<0 and 1 where x>=0

Answer: A. [0, -0.3, 0, 0, -0.2] — ReLU gradient is 0 where x<=0 and 1 where x>0, so gradient passes through only for positive inputs

ExplanationReLU(x) = max(0, x). Its derivative: dReLU/dx = 1 if x > 0, 0 if x <= 0. By chain rule: dL/dx = dL/dy * dReLU/dx. Element-wise: x[0]=-2 (<=0): dL/dx[0] = 0.5 * 0 = 0. x[1]=3 (>0): dL/dx[1] = -0.3 * 1 = -0.3. x[2]=0 (<=0): dL/dx[2] = 0.1 * 0 = 0 (ReLU is typically defined with derivative 0 at exactly 0). x[3]=-1 (<=0): dL/dx[3] = 0.4 * 0 = 0. x[4]=5 (>0): dL/dx[4] = -0.2 * 1 = -0.2. Result: [0, -0.3, 0, 0, -0.2]. ReLU acts as a gradient gate — it kills gradients for non-positive inputs (the "dying ReLU" problem).

Question 132 · SGD with Momentum · hard

You train a model with SGD using momentum=0.9. At step t, the gradient is g_t = 4.0 and the previous velocity was v_{t-1} = 2.0. With learning rate alpha=0.01, what is the new velocity v_t and the parameter update delta_w?

  1. v_t = 5.8, delta_w = -0.058 — v_t = 0.9*2.0 + 4.0 = 5.8, delta_w = -0.01*5.8 = -0.058
  2. v_t = 4.0, delta_w = -0.04 — momentum is ignored, only the current gradient matters
  3. v_t = 3.6, delta_w = -0.036 — v_t = 0.9*4.0 = 3.6, previous velocity is discarded
  4. v_t = 6.0, delta_w = -0.06 — v_t = 2.0 + 4.0 = 6.0, momentum factor is not applied

Answer: A. v_t = 5.8, delta_w = -0.058 — v_t = 0.9*2.0 + 4.0 = 5.8, delta_w = -0.01*5.8 = -0.058

ExplanationSGD with momentum update rules: v_t = beta * v_{t-1} + g_t, then w = w - alpha * v_t. With beta=0.9: v_t = 0.9 * 2.0 + 4.0 = 1.8 + 4.0 = 5.8. delta_w = -alpha * v_t = -0.01 * 5.8 = -0.058. The velocity v_t is an exponential moving average of past gradients. The momentum term (0.9 * 2.0 = 1.8) carries forward 90% of the previous velocity, accumulating gradient history. This helps SGD accelerate through consistent gradient directions and dampen oscillations. This produces a larger update because momentum accumulates past gradient information. Without momentum, delta_w would be just -0.01 * 4.0 = -0.04.

Question 133 · Dropout Regularization · hard

You apply dropout with p=0.5 during training to a hidden layer output [4, 8, 2, 6]. The dropout mask is [1, 0, 1, 0] (1=keep, 0=drop). What is the layer output during training, and what scaling is applied during inference?

  1. Training: [8, 0, 4, 0] (kept values scaled by 1/p=2), Inference: use raw values with no dropout and no scaling
  2. Training: [4, 0, 2, 0] (just zero out dropped units, no scaling), Inference: multiply all by 0.5
  3. Training: [2, 0, 1, 0] (multiply kept values by p=0.5), Inference: use raw values
  4. Training: [4, 8, 2, 6] (dropout has no effect on output values), Inference: same values

Answer: A. Training: [8, 0, 4, 0] (kept values scaled by 1/p=2), Inference: use raw values with no dropout and no scaling

ExplanationWith inverted dropout (the standard implementation): during training, dropped units are set to 0 and KEPT units are scaled by 1/(1-p) = 1/0.5 = 2 to maintain the expected value. So: [4*1*2, 8*0*2, 2*1*2, 6*0*2] = [8, 0, 4, 0]. During inference, NO dropout is applied and NO scaling is needed — the inverted scaling during training already compensates. This is why inverted dropout is preferred: inference code doesn't need modification. Alternative (non-inverted) dropout would keep values unscaled during training ([4, 0, 2, 0]) but must multiply ALL outputs by (1-p)=0.5 during inference. Both produce the same expected output.

Question 134 · Binary Cross-Entropy Loss · hard

You compute the binary cross-entropy loss for a batch of 4 samples. True labels: [1, 0, 1, 1]. Model predictions (after sigmoid): [0.9, 0.3, 0.8, 0.6]. Using ln(0.9)=-0.105, ln(0.7)=-0.357, ln(0.8)=-0.223, ln(0.6)=-0.511, ln(0.4)=-0.916, what is the average loss?

  1. 0.299 — L = -[ln(0.9) + ln(0.7) + ln(0.8) + ln(0.6)]/4 = -[-0.105 + -0.357 + -0.223 + -0.511]/4 = 1.196/4 = 0.299
  2. 0.150 — only count losses for positive labels (y=1), divide by 4
  3. 1.196 — sum of all losses without averaging
  4. 0.350 — average of the sigmoid outputs subtracted from 1: (0.1+0.7+0.2+0.4)/4 = 1.4/4 = 0.350

Answer: A. 0.299 — L = -[ln(0.9) + ln(0.7) + ln(0.8) + ln(0.6)]/4 = -[-0.105 + -0.357 + -0.223 + -0.511]/4 = 1.196/4 = 0.299

ExplanationBCE for each sample: L_i = -(y_i*ln(p_i) + (1-y_i)*ln(1-p_i)). Sample 1 (y=1, p=0.9): -(1*ln(0.9) + 0*ln(0.1)) = -ln(0.9) = 0.105. Sample 2 (y=0, p=0.3): -(0*ln(0.3) + 1*ln(0.7)) = -ln(0.7) = 0.357. Sample 3 (y=1, p=0.8): -ln(0.8) = 0.223. Sample 4 (y=1, p=0.6): -ln(0.6) = 0.511. Sum = 0.105 + 0.357 + 0.223 + 0.511 = 1.196. Average = 1.196/4 = 0.299. Note: for y=0, we use ln(1-p), not ln(p). Sample 2 has p=0.3, so 1-p=0.7, and -ln(0.7)=0.357 penalizes the model for predicting 30% for a negative sample.

Question 135 · Neural Network Parameter Counting · hard

A fully-connected neural network has the following architecture: Input layer with 784 neurons (representing 28x28 MNIST pixels) → Dense hidden layer with 256 neurons → Dense hidden layer with 128 neurons → Dense output layer with 10 neurons for digit classes 0-9. What is the total number of trainable parameters, including both weights and biases, across all 3 dense layers?

  1. 235,146 — (784*256+256) + (256*128+128) + (128*10+10) = 200,960 + 32,896 + 1,290 = 235,146
  2. 234,752 — (784*256) + (256*128) + (128*10) = 200,704 + 32,768 + 1,280, no biases
  3. 1,178 — just the number of neurons: 784+256+128+10
  4. 256,901 — (784*256*128*10) compressed by factor of 1000

Answer: A. 235,146 — (784*256+256) + (256*128+128) + (128*10+10) = 200,960 + 32,896 + 1,290 = 235,146

ExplanationEach Dense layer has weights (W) and biases (b). Layer 1 (784→256): W = 784*256 = 200,704 weights + 256 biases = 200,960. Layer 2 (256→128): W = 256*128 = 32,768 weights + 128 biases = 32,896. Layer 3 (128→10): W = 128*10 = 1,280 weights + 10 biases = 1,290. Total = 200,960 + 32,896 + 1,290 = 235,146. The majority (85.5%) of parameters are in the first layer because it connects the high-dimensional input (784 = 28x28 MNIST pixels) to the first hidden layer. This is why modern architectures use convolutions instead of dense layers for image inputs.

Question 136 · Batch Normalization · hard

In batch normalization, you normalize activations x = [2, 4, 6, 8] across the batch. With epsilon=0, what are the normalized values x_hat before the learnable scale (gamma) and shift (beta)?

  1. [-1.342, -0.447, 0.447, 1.342] — mean=5, std=sqrt(5)=2.236, x_hat = (x-mean)/std
  2. [0.1, 0.2, 0.3, 0.4] — divide each by the sum: x_i / sum(x)
  3. [-3, -1, 1, 3] — subtract the mean (5) from each element
  4. [0.25, 0.5, 0.75, 1.0] — min-max normalization to [0,1]

Answer: A. [-1.342, -0.447, 0.447, 1.342] — mean=5, std=sqrt(5)=2.236, x_hat = (x-mean)/std

ExplanationBatchNorm computes: x_hat = (x - mean) / sqrt(variance + epsilon). Mean = (2+4+6+8)/4 = 20/4 = 5. Variance = ((2-5)^2 + (4-5)^2 + (6-5)^2 + (8-5)^2)/4 = (9+1+1+9)/4 = 20/4 = 5. Std = sqrt(5) = 2.236. With epsilon=0: x_hat[0] = (2-5)/2.236 = -3/2.236 = -1.342. x_hat[1] = (4-5)/2.236 = -1/2.236 = -0.447. x_hat[2] = (6-5)/2.236 = 1/2.236 = 0.447. x_hat[3] = (8-5)/2.236 = 3/2.236 = 1.342. The result has mean=0 and variance=1, which stabilizes training by preventing internal covariate shift.

Question 137 · Max Pooling · hard

You apply a 2×2 max pooling filter with stride=1 to this 3×3 feature map: [[2, 8, 4], [5, 1, 9], [3, 7, 6]] Since the stride is smaller than the pooling window, consecutive windows overlap as the filter slides across the map. What is the resulting output?

  1. [[8, 9], [7, 9]] — the max of each overlapping 2x2 window as the stride-1 filter slides one row/column at a time
  2. [[4, 5.5], [4, 5.75]] — the average of each 2x2 window rather than the maximum
  3. [[8, 7], [9, 9]] — the max of each window but with the output rows and columns transposed
  4. [[8, 9], [7, 6]] — the max of each window assuming stride=2 with edge-padding instead of the specified stride=1

Answer: A. [[8, 9], [7, 9]] — the max of each overlapping 2x2 window as the stride-1 filter slides one row/column at a time

ExplanationWith a 2x2 window and stride=1 on a 3x3 map, the output size is (3-2)/1 + 1 = 2, so the output is 2x2 and consecutive windows overlap by one row and one column. The top-left window (rows 0-1, cols 0-1) covers {2,8,5,1}, max = 8. The top-right window (rows 0-1, cols 1-2) covers {8,4,1,9}, max = 9. The bottom-left window (rows 1-2, cols 0-1) covers {5,1,3,7}, max = 7. The bottom-right window (rows 1-2, cols 1-2) covers {1,9,7,6}, max = 9. So the output is [[8, 9], [7, 9]]. Because the stride (1) is smaller than the kernel size (2), the windows overlap, so a single high-activation cell — here the 9 at row 1, col 2 — can be the maximum of more than one output cell (it drives both the top-right and bottom-right outputs). This is different from non-overlapping pooling (stride = kernel size), where each input cell contributes to exactly one output cell.

Question 138 · Attention Mechanism Fundamentals · hard

In the attention mechanism, you have Query q=[1,0], Key k=[0,1], and Value v=[3,7]. The attention weight is computed as softmax(q·k / sqrt(d_k)) where d_k=2. What is the attention output for this single query-key pair (assuming only one key)?

  1. [3, 7] — with only one key, softmax of any single score is 1.0, so output = 1.0 * v = [3, 7]
  2. [0, 0] — q·k = 0, so the attention weight is 0 and the output is zero
  3. [1.5, 3.5] — the output is v scaled by the raw dot product q·k/sqrt(2) = 0
  4. [3, 7] multiplied by 0.5 = [1.5, 3.5] — softmax outputs 0.5 for a single element

Answer: A. [3, 7] — with only one key, softmax of any single score is 1.0, so output = 1.0 * v = [3, 7]

ExplanationStep 1: Compute dot product q·k = 1*0 + 0*1 = 0. Step 2: Scale by sqrt(d_k) = sqrt(2): score = 0/sqrt(2) = 0. Step 3: Apply softmax. With only ONE key, softmax([0]) = [e^0 / e^0] = [1.0]. Softmax of any single value always equals 1.0, regardless of the value. Step 4: Weighted sum: output = 1.0 * [3, 7] = [3, 7]. The key insight: even though q and k are orthogonal (dot product = 0), with only one key available, all attention goes to that key. The dot product would matter if there were MULTIPLE keys to distribute attention across — then higher-scoring keys would receive more weight.

Question 139 · Fully Connected Layer Parameters · hard

A fully connected layer has input size 256 and output size 128 with a bias term. How many trainable parameters does this layer have, and what is the shape of the weight matrix? Compute the total and explain why each dimension contributes to the parameter count?

  1. Weight matrix shape: (256, 128) with 256 × 128 = 32,768 weights + 128 biases = 32,896 total parameters
  2. Weight matrix shape: (128, 256) with 128 × 256 = 32,768 weights + 256 biases = 33,024 total; bias matches input size
  3. Total = 256 + 128 = 384 parameters; each neuron contributes one parameter
  4. Total = 256 × 128 = 32,768 parameters; fully connected layers do not use bias terms

Answer: A. Weight matrix shape: (256, 128) with 256 × 128 = 32,768 weights + 128 biases = 32,896 total parameters

ExplanationA FC layer from input dim 256 to output dim 128 has a weight matrix W of shape (256, 128) — one weight per (input, output) pair = 256×128 = 32,768 weights. The bias vector has one entry per output neuron = 128 biases. Total = 32,768 + 128 = 32,896. Option B swaps the bias count to match input size, which is wrong.

Question 140 · ReLU Activation and Backpropagation · hard

You apply ReLU activation to the vector [-3, 0, 2, -1, 5]. Then you compute the derivative (for backprop) at each position. What are the outputs and derivatives? Analyze the computation step by step and determine the exact numerical answer?

  1. Outputs: [0, 0, 2, 0, 5]. Derivatives: [0, 0, 1, 0, 1] — ReLU outputs max(0, x) and derivative is 1 for x > 0, 0 for x < 0 (undefined at 0, typically set to 0)
  2. Outputs: [-3, 0, 2, -1, 5]. Derivatives: [1, 1, 1, 1, 1] — ReLU passes all values through and has derivative 1 everywhere
  3. Outputs: [0, 0, 2, 0, 5]. Derivatives: [0, 0, 2, 0, 5] — the derivative of ReLU equals the output value
  4. Outputs: [0.05, 0.5, 0.88, 0.27, 0.99]. Derivatives vary — this describes sigmoid, not ReLU

Answer: A. Outputs: [0, 0, 2, 0, 5]. Derivatives: [0, 0, 1, 0, 1] — ReLU outputs max(0, x) and derivative is 1 for x > 0, 0 for x < 0 (undefined at 0, typically set to 0)

ExplanationReLU(x) = max(0, x). Apply elementwise: max(0,-3)=0, max(0,0)=0, max(0,2)=2, max(0,-1)=0, max(0,5)=5. Derivative: d/dx ReLU(x) = 1 if x>0, 0 if x<0. At x=0 it is technically undefined but conventionally set to 0. So derivatives: [0, 0, 1, 0, 1]. The "dead neuron" problem occurs when neurons consistently get x<0, making gradients permanently zero.
← Set 6Set 8 →