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 11

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

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

Question 201 · Contrastive Learning: Learning from Similarities · hard

In a SimCLR-style contrastive learning pipeline, a training batch contains N = 128 images. Each image passes through two independent random augmentations, producing two correlated views per image, so a single training step embeds 2N = 256 vectors in total. The NT-Xent (InfoNCE) loss for a given anchor embedding is computed as a softmax over every other embedding produced in that step: exactly one of them, the anchor's other augmented view, is treated as the positive, and every remaining embedding in the batch is treated as a negative. For a single anchor embedding, how many negative samples does the NT-Xent loss use in this setup?

  1. 254 negative samples, since 2N − 2 excludes both the anchor's own embedding and its one positive partner from the 2N embeddings produced that step.
  2. 255 negative samples, since 2N − 1 excludes only the anchor's own embedding, so the positive partner is also counted as a negative alongside the rest.
  3. 127 negative samples, since N − 1 counts negatives only from the other original images' first-view embeddings, leaving out every second-augmentation embedding entirely.
  4. 256 negative samples, since 2N counts every embedding produced in that training step, including the anchor's own embedding, as a negative.

Answer: A. 254 negative samples, since 2N − 2 excludes both the anchor's own embedding and its one positive partner from the 2N embeddings produced that step.

ExplanationSimCLR's NT-Xent loss embeds all 2N augmented views together and, for each anchor, computes a softmax over the remaining 2N − 1 embeddings from that step — the anchor's own vector is never compared against itself. Exactly one of those 2N − 1 embeddings, the anchor's other augmented view, is the positive; every remaining embedding is a negative, giving 2N − 2 negatives overall. With N = 128 this works out to 2(128) − 2 = 254, matching the choice that excludes both the anchor's own embedding and its one positive partner from the 2N embeddings produced that step. Excluding only the anchor's own embedding and leaving the positive partner folded in with the negatives, as the 255-count choice does, would corrupt the loss, because InfoNCE's numerator depends on the positive being kept separate from the denominator's negative sum. Assuming negatives come only from the other original images' first-view embeddings, as the 127-count choice does, ignores that SimCLR draws negatives from both augmented views across the entire batch, not just one view. And treating every embedding produced that step as a negative, as the 256-count choice does, is impossible since an anchor's own embedding is excluded from the similarity computation entirely.

Question 202 · VAE: Reparameterization Trick · hard

A VAE encoder outputs mean mu=2.0 and log-variance logvar=-1.386 (so sigma≈0.5) for a single latent dimension, given input x. To sample z during training in a way that still allows gradients to flow back to the encoder's parameters, the REPARAMETERIZATION TRICK computes z = mu + sigma * epsilon, where epsilon is drawn from a standard normal N(0,1). Why can't you just sample z directly from N(mu, sigma^2) instead?

  1. You can — directly sampling from N(mu, sigma^2) and using the reparameterization trick are mathematically and practically identical in every way
  2. Directly sampling z ~ N(mu, sigma^2) treats the sampling operation as a black box with no defined derivative with respect to mu and sigma — gradients cannot flow backward through a random sampling step during backpropagation; the reparameterization trick isolates ALL the randomness into epsilon (a fixed external random draw), making z a DETERMINISTIC, differentiable function of mu and sigma, so standard backpropagation can compute d(loss)/d(mu) and d(loss)/d(sigma) normally
  3. Direct sampling is impossible because Python cannot generate normally-distributed random numbers
  4. The reparameterization trick is only used at inference time, never during training

Answer: B. Directly sampling z ~ N(mu, sigma^2) treats the sampling operation as a black box with no defined derivative with respect to mu and sigma — gradients cannot flow backward through a random sampling step during backpropagation; the reparameterization trick isolates ALL the randomness into epsilon (a fixed external random draw), making z a DETERMINISTIC, differentiable function of mu and sigma, so standard backpropagation can compute d(loss)/d(mu) and d(loss)/d(sigma) normally

ExplanationTraining a VAE with gradient descent requires computing gradients of the loss with respect to the encoder's output parameters, mu and sigma. If z is sampled directly as z ~ N(mu, sigma^2), the sampling operation itself has no meaningful derivative — you cannot ask 'how would this specific random draw change if mu shifted slightly', because a fresh random sample doesn't shift smoothly and predictably with its parameters. The reparameterization trick sidesteps this by rewriting the SAME distribution as z = mu + sigma*epsilon, where epsilon ~ N(0,1) is sampled independently of mu and sigma (its randomness is now external and fixed for that step). Now z is a plain, fully differentiable arithmetic function of mu and sigma (given a fixed epsilon draw), so ordinary backpropagation computes dz/dmu=1 and dz/dsigma=epsilon cleanly, letting gradients flow all the way back through z into the encoder's parameters — exactly as needed to train the encoder end-to-end via standard gradient descent.

Question 203 · VAE: Posterior Collapse Diagnosis · hard

During VAE training, a particular latent dimension's KL divergence term stays extremely close to zero throughout training, no matter how long training continues. What does this specifically indicate about that dimension when you analyze it, and what training technique is commonly used to prevent it?

  1. It indicates the dimension is working perfectly and carrying maximal information about the input
  2. It indicates POSTERIOR COLLAPSE for that dimension — the encoder's posterior q(z|x) for that dimension has become indistinguishable from the prior N(0,1) (mu≈0, sigma≈1), meaning the encoder has stopped encoding any input-specific information into that dimension, and the decoder has learned to reconstruct outputs without relying on it; KL annealing (starting the KL term's weight at 0 and gradually increasing it during training) is a common fix, letting the model first learn to use the latent space for reconstruction before the KL penalty pressures dimensions toward the prior
  3. It indicates the model has already achieved a perfect reconstruction loss of zero
  4. It indicates a bug in the code that will always cause training to crash immediately

Answer: B. It indicates POSTERIOR COLLAPSE for that dimension — the encoder's posterior q(z|x) for that dimension has become indistinguishable from the prior N(0,1) (mu≈0, sigma≈1), meaning the encoder has stopped encoding any input-specific information into that dimension, and the decoder has learned to reconstruct outputs without relying on it; KL annealing (starting the KL term's weight at 0 and gradually increasing it during training) is a common fix, letting the model first learn to use the latent space for reconstruction before the KL penalty pressures dimensions toward the prior

ExplanationThe KL divergence term in a VAE's loss measures how far the encoder's learned posterior distribution for a given input is from the prior N(0,1) — near-zero KL for a specific dimension means that dimension's posterior has essentially become identical to the prior REGARDLESS of the input, meaning the encoder has stopped putting any input-specific (useful) information into that dimension at all; the decoder has effectively learned to ignore it (a phenomenon called posterior collapse), because a powerful decoder found it cheaper to reconstruct without paying that dimension's KL cost. This tends to happen when a powerful decoder can achieve low reconstruction loss largely on its own, making the 'cost' of using additional latent dimensions (each contributing to the KL penalty) not worth paying for the marginal reconstruction benefit. KL annealing — starting the KL term's weight near 0 so the model first learns to genuinely USE the latent space to reconstruct well, then gradually ramping the KL weight up to its full value — is a standard mitigation, alongside related techniques like 'free bits' that only penalize a dimension's KL once it exceeds a small threshold.

Question 204 · VAE vs GAN: Applied Tradeoffs · medium

Both VAEs and GANs can generate new images. A team building a face-generation tool needs (a) SHARP, photorealistic outputs and (b) the ability to compute a meaningful likelihood/reconstruction score for any given image. Which model type better satisfies EACH requirement, and why is there a genuine tradeoff?

  1. GANs satisfy both requirements equally well, with no tradeoff of any kind
  2. GANs typically produce SHARPER, more photorealistic images (their adversarial training directly optimizes for 'does this fool a discriminator', pushing toward crisp realism) but have no natural way to compute a likelihood/reconstruction score for a given input image; VAEs directly optimize a reconstruction-based loss and naturally provide an encoder that CAN score how well a given image fits the model, but their pixel-wise reconstruction objective tends to produce comparatively blurrier outputs, since averaging over plausible reconstructions favors smooth, safe pixel values over sharp, confident details
  3. VAEs always produce sharper images than GANs in every case
  4. This is not a real tradeoff — both approaches are functionally identical in practice

Answer: B. GANs typically produce SHARPER, more photorealistic images (their adversarial training directly optimizes for 'does this fool a discriminator', pushing toward crisp realism) but have no natural way to compute a likelihood/reconstruction score for a given input image; VAEs directly optimize a reconstruction-based loss and naturally provide an encoder that CAN score how well a given image fits the model, but their pixel-wise reconstruction objective tends to produce comparatively blurrier outputs, since averaging over plausible reconstructions favors smooth, safe pixel values over sharp, confident details

ExplanationThis tradeoff stems directly from what each model is trained to optimize. A GAN's generator is trained adversarially, purely to fool a discriminator into believing its outputs are real — there is no pixel-wise reconstruction loss pulling outputs toward a blurry 'average' of plausible images, so GANs tend to commit confidently to sharp, high-frequency details, at the cost of training instability and no built-in way to ask 'how likely is this specific real image under my model' (there's no encoder or explicit likelihood in a standard GAN). A VAE's decoder is trained via a reconstruction loss (like pixel-wise MSE) plus a KL regularization term — this objective, applied under genuine uncertainty about the exact right pixel values, mathematically favors predicting the AVERAGE of several plausible outputs rather than committing sharply to one, which is a well-documented cause of VAEs' characteristically blurrier samples; but the same architecture naturally provides both an encoder (letting you compute how well any real image fits, via its reconstruction error) and a principled probabilistic framework. Choosing between them is a genuine tradeoff based on which property (sharpness vs. scorability) matters more for the specific application.

Question 205 · Scaled Dot-Product Attention Computation · hard

In scaled dot-product attention, a query vector Q=(1,2) is compared against three key vectors: K_A=(1,0), K_B=(0,1), K_C=(1,1), with d_k=2. After computing raw dot-product scores, scaling by 1/sqrt(d_k), and applying softmax, which key receives the HIGHEST attention weight, and approximately what is it?

  1. Key A receives the highest weight, at approximately 0.576
  2. Key C receives the highest weight, at approximately 0.576 — raw scores are Q·K_A=1, Q·K_B=2, Q·K_C=3; scaled by 1/sqrt(2)≈0.707 gives approximately 0.707, 1.414, 2.121; applying softmax to these three scaled scores gives approximately [0.14, 0.284, 0.576], so Key C (the key most aligned with the query in BOTH dimensions) dominates the attention distribution
  3. All three keys receive exactly equal attention weight of 0.333 each, since softmax always equalizes its inputs
  4. Key B receives the highest weight, since it is closest to the query in raw Euclidean distance

Answer: B. Key C receives the highest weight, at approximately 0.576 — raw scores are Q·K_A=1, Q·K_B=2, Q·K_C=3; scaled by 1/sqrt(2)≈0.707 gives approximately 0.707, 1.414, 2.121; applying softmax to these three scaled scores gives approximately [0.14, 0.284, 0.576], so Key C (the key most aligned with the query in BOTH dimensions) dominates the attention distribution

ExplanationAttention scores start as raw dot products between the query and each key: Q·K_A = (1)(1)+(2)(0) = 1; Q·K_B = (1)(0)+(2)(1) = 2; Q·K_C = (1)(1)+(2)(1) = 3. Scaling each by 1/sqrt(d_k) = 1/sqrt(2) ≈ 0.7071 gives approximately 0.7071, 1.4142, and 2.1213 respectively. Applying softmax (exponentiate each, then normalize by the sum): exp(0.7071)≈2.028, exp(1.4142)≈4.113, exp(2.1213)≈8.342, summing to ≈14.483; dividing each by that sum gives approximately [0.140, 0.284, 0.576]. Key C dominates the attention distribution at roughly 57.6%, because it has the highest raw alignment with the query in both dimensions simultaneously (Q=(1,2) shares both a nonzero first component with K_A/K_C and a nonzero second component with K_B/K_C, but only K_C matches on BOTH). This worked example is exactly the mechanism scaled up (with learned Q/K/V projection matrices) inside every transformer's self-attention layer.

Question 206 · Multi-Head Attention: Parameter Count · hard

A standard multi-head attention layer with d_model=512 uses 8 attention heads, so each head operates with d_k=d_model/8=64. Compare the TOTAL number of learnable parameters in the Q, K, V, and output projection matrices for this 8-head setup versus a hypothetical SINGLE-head setup using the full d_model=512 as its d_k. Which has more parameters?

  1. The 8-head setup has 8 times as many parameters as the single-head setup, since it has 8 separate heads
  2. They have the IDENTICAL total parameter count — in the standard formulation, the Q, K, V, and output projections are each still full d_model x d_model matrices regardless of how many heads split that dimension internally; multi-head attention doesn't add parameters compared to a single large head, it instead reshapes the SAME total parameter budget into multiple smaller, independently-learned representation subspaces, which is the actual source of its expressive advantage, not extra capacity
  3. The single-head setup has 8 times as many parameters, since it processes the full dimension at once
  4. Parameter count cannot be determined without knowing the batch size

Answer: B. They have the IDENTICAL total parameter count — in the standard formulation, the Q, K, V, and output projections are each still full d_model x d_model matrices regardless of how many heads split that dimension internally; multi-head attention doesn't add parameters compared to a single large head, it instead reshapes the SAME total parameter budget into multiple smaller, independently-learned representation subspaces, which is the actual source of its expressive advantage, not extra capacity

ExplanationA common misconception is that multi-head attention must use MORE parameters than single-head attention, since it has multiple heads. In the standard transformer formulation, this isn't the case: the Q, K, V, and output projection matrices are each sized d_model x d_model REGARDLESS of how many heads the computation is split into — splitting into 8 heads of d_k=64 each just means each head operates on a 64-dimensional SLICE of the same overall d_model=512-dimensional projected space, with all 8 slices concatenated back together before the final output projection. The total parameter count (4 x d_model^2, for Q/K/V/output) is IDENTICAL whether you use 1 head of size 512 or 8 heads of size 64 each. What multi-head attention actually buys you, at the SAME parameter budget, is the ability to learn several DIFFERENT attention patterns in parallel — different heads empirically specialize in different kinds of relationships (e.g., syntactic dependencies vs. positional proximity) — rather than being forced into one single, averaged attention pattern that a single large head would compute.

Question 207 · GAN: Mode Collapse · medium

In the original GAN framework, the generator G and discriminator D are trained via a minimax game: G tries to fool D, D tries to correctly distinguish real from generated images. What is MODE COLLAPSE, and why can it occur despite this adversarial setup?

  1. Mode collapse means the discriminator's accuracy drops to exactly 50%, which is actually the desired outcome at convergence
  2. Mode collapse occurs when the generator finds a small number of outputs (or even just ONE) that reliably fool the current discriminator, and then keeps producing ONLY those outputs repeatedly, ignoring the true diversity of the real data distribution — this can happen because the generator's objective only rewards 'fooling D right now', with no explicit pressure to cover the full variety of the real data, so if a narrow set of outputs consistently fools D, the generator has no incentive to explore beyond them
  3. Mode collapse is a training bug that only occurs due to incorrect learning rate settings, never as an inherent risk of the adversarial objective itself
  4. Mode collapse means the discriminator has collapsed into always predicting 'fake', regardless of the generator's behavior

Answer: B. Mode collapse occurs when the generator finds a small number of outputs (or even just ONE) that reliably fool the current discriminator, and then keeps producing ONLY those outputs repeatedly, ignoring the true diversity of the real data distribution — this can happen because the generator's objective only rewards 'fooling D right now', with no explicit pressure to cover the full variety of the real data, so if a narrow set of outputs consistently fools D, the generator has no incentive to explore beyond them

ExplanationMode collapse is one of the most notorious training pathologies of the original GAN formulation: instead of learning to generate the full DIVERSITY of the real data distribution (many different faces, digits, etc.), the generator discovers a narrow set of outputs — sometimes even a single output — that reliably fools the current discriminator, and then keeps producing variations on just that, abandoning the rest of the data distribution's diversity entirely. This is an inherent risk of the vanilla minimax objective, not merely a hyperparameter bug: the generator's loss only cares about fooling D at each step, with no explicit term rewarding output diversity, so if the discriminator has a blind spot that a narrow set of outputs exploits, the generator keeps exploiting exactly that blind spot rather than exploring the broader data manifold, because doing so is the path of least resistance under its own objective. This exact failure mode is a major motivation behind alternative formulations like WGAN, which replaces the original discriminator's binary real/fake classification with a smoother, more informative Wasserstein-distance-based critic that provides more consistent, mode-collapse-resistant training signal.

Question 208 · WGAN: Wasserstein Distance Motivation · hard

WGAN (Wasserstein GAN) replaces the original GAN's discriminator with a 'critic' that estimates the Wasserstein (Earth-Mover) distance between the real and generated distributions, rather than doing binary real/fake classification. What specific training problem does this change address?

  1. WGAN eliminates the need for a generator entirely
  2. The original GAN's loss (based on Jensen-Shannon divergence, implicit in the binary cross-entropy discriminator loss) can produce VANISHING GRADIENTS for the generator whenever the discriminator becomes too confident/accurate — the gradient signal telling the generator how to improve essentially disappears; the Wasserstein distance provides a smoother, more informative measure that keeps producing MEANINGFUL, non-vanishing gradients even when the current generator and real data distributions are far apart or barely overlapping, giving more stable training
  3. WGAN uses a completely different neural network architecture with no similarity to the original GAN
  4. The Wasserstein distance can only be computed for image data, never for other data types

Answer: B. The original GAN's loss (based on Jensen-Shannon divergence, implicit in the binary cross-entropy discriminator loss) can produce VANISHING GRADIENTS for the generator whenever the discriminator becomes too confident/accurate — the gradient signal telling the generator how to improve essentially disappears; the Wasserstein distance provides a smoother, more informative measure that keeps producing MEANINGFUL, non-vanishing gradients even when the current generator and real data distributions are far apart or barely overlapping, giving more stable training

ExplanationA core problem with the original GAN's discriminator-based loss is that once the discriminator becomes very good at distinguishing real from fake (which tends to happen readily, especially early in training when the generator's outputs are still poor), the JS-divergence-based loss saturates — the discriminator's output becomes extremely confident (near 0 or 1) in regions with little useful gradient signal, meaning the GENERATOR receives a vanishing gradient telling it almost nothing useful about how to improve, even though it clearly still needs to. The Wasserstein distance, by contrast, remains a smooth, meaningful, non-saturating measure of how far apart two distributions are, even when they have little or no overlap — it keeps providing a genuinely informative gradient signal to the generator throughout training, rather than flatlining once the critic becomes confident. This smoother loss landscape is WGAN's central practical advantage, directly addressing the vanishing-gradient and general training-instability problems that plague the original GAN formulation — though it requires additional constraints (like weight clipping, or the improved gradient penalty in WGAN-GP) to keep the critic within the mathematically required 1-Lipschitz function class.

Question 209 · Policy Gradient: Baseline/Advantage Subtraction · hard

In the REINFORCE policy gradient algorithm, the raw gradient estimate for a trajectory can be written as (return G) x (gradient of log pi(action|state)). This raw estimator, used as-is, tends to have very HIGH VARIANCE, making training slow and unstable. What is the standard fix, and why does it not introduce bias?

  1. Simply reducing the learning rate to a very small value fixes the variance problem entirely, with no other changes needed
  2. Subtracting a BASELINE (commonly an estimate of the state's value function, V(s)) from the return G, using (G - baseline) instead of G alone — this reduces variance because it centers the learning signal around zero (rewarding actions that did BETTER than expected, penalizing ones that did WORSE than expected, rather than using the raw, highly variable absolute return); this does not introduce bias into the gradient estimate because, mathematically, subtracting any baseline that doesn't depend on the current ACTION (only on the state) leaves the EXPECTED value of the gradient estimate unchanged — only its variance is reduced
  3. Baselines are never used in practice because they always make training worse
  4. The fix is to remove the log probability term entirely from the gradient computation

Answer: B. Subtracting a BASELINE (commonly an estimate of the state's value function, V(s)) from the return G, using (G - baseline) instead of G alone — this reduces variance because it centers the learning signal around zero (rewarding actions that did BETTER than expected, penalizing ones that did WORSE than expected, rather than using the raw, highly variable absolute return); this does not introduce bias into the gradient estimate because, mathematically, subtracting any baseline that doesn't depend on the current ACTION (only on the state) leaves the EXPECTED value of the gradient estimate unchanged — only its variance is reduced

ExplanationREINFORCE's raw gradient estimator uses the full return G to scale the log-probability gradient of each action taken — but G's raw scale can vary enormously between trajectories (a return of 100 in one episode vs. 10,000 in another, even for similarly-good actions relative to what was achievable in that state), producing a noisy, high-variance gradient estimate that makes learning slow and unstable. Subtracting a baseline b(s) — commonly an estimate of the state's expected value V(s) — reframes the learning signal as an ADVANTAGE: (G - b(s)) captures 'how much better or worse did this action's outcome turn out compared to what was expected from this state', a naturally more centered, lower-variance quantity that still points gradients in the correct direction. Critically, this subtraction is UNBIASED as long as the baseline depends only on the state (not on the specific action chosen) — a well-known result in policy gradient theory shows that the expected value of the gradient contribution from any action-independent baseline term is exactly zero, so subtracting it changes the estimator's VARIANCE without shifting its expected value (and thus without changing what the algorithm converges to).

Question 210 · RLHF: Reward Model Training Data · medium

In RLHF (Reinforcement Learning from Human Feedback), a reward model is trained BEFORE the actual reinforcement learning step begins. What specific data is this reward model trained on, and why not train it directly on absolute numeric ratings (like 'rate this response 1-10') instead?

  1. The reward model is trained on the exact same data used to pretrain the base language model, with no separate step needed
  2. The reward model is trained on human PAIRWISE COMPARISONS — shown two (or more) candidate responses to the same prompt, a human labeler indicates which one is BETTER (a relative preference), not an absolute numeric score; pairwise comparisons are used instead of absolute ratings because humans are demonstrably more CONSISTENT and reliable at relative judgments ('is A better than B') than at assigning stable absolute numeric scores (different labelers, or even the same labeler on different days, tend to disagree much more on 'is this a 7 or an 8' than on 'is A better than B')
  3. The reward model requires no training data at all — it is a fixed, hand-coded function
  4. The reward model is trained using only automated metrics like BLEU score, with no human involvement

Answer: B. The reward model is trained on human PAIRWISE COMPARISONS — shown two (or more) candidate responses to the same prompt, a human labeler indicates which one is BETTER (a relative preference), not an absolute numeric score; pairwise comparisons are used instead of absolute ratings because humans are demonstrably more CONSISTENT and reliable at relative judgments ('is A better than B') than at assigning stable absolute numeric scores (different labelers, or even the same labeler on different days, tend to disagree much more on 'is this a 7 or an 8' than on 'is A better than B')

ExplanationRLHF's reward model is trained on human-labeled PAIRWISE COMPARISONS: for a given prompt, two (or more) candidate model responses are shown to a human labeler, who indicates which response they prefer — a RELATIVE judgment, not an absolute numeric rating. This design choice is deliberate and well-documented: extensive research (including in the original InstructGPT-style RLHF papers) has found that human raters are considerably more consistent when making relative comparisons ('is response A better than response B') than when assigning absolute numeric scores ('rate this 1 to 10') — the same response might get wildly different absolute scores from different labelers, or even the same labeler at different times, whereas 'which of these two is better' tends to produce much more stable, reproducible agreement. These pairwise preference labels are then used (typically via a Bradley-Terry style model) to train a reward model that outputs a SINGLE numeric score per response, which subsequently serves as the reward signal for the actual PPO reinforcement learning step that fine-tunes the language model's policy.

Question 211 · Reinforcement Learning: MDP Components · medium

In reinforcement learning, a problem is formally modeled as a Markov Decision Process (MDP). What are the core components of an MDP, and what does the 'Markov' property specifically require?

  1. An MDP consists only of states and rewards, with no notion of actions or transitions
  2. An MDP consists of: states (S), actions (A), a transition function (probability of reaching a new state given the current state and action), a reward function, and typically a discount factor; the MARKOV property specifically requires that the transition probabilities and rewards depend ONLY on the CURRENT state and action, not on the full history of how the agent arrived there — the current state must fully capture all information relevant to predicting the future
  3. An MDP requires the environment to be fully deterministic, with no randomness allowed anywhere
  4. The Markov property means the agent must always take the same action regardless of the current state

Answer: B. An MDP consists of: states (S), actions (A), a transition function (probability of reaching a new state given the current state and action), a reward function, and typically a discount factor; the MARKOV property specifically requires that the transition probabilities and rewards depend ONLY on the CURRENT state and action, not on the full history of how the agent arrived there — the current state must fully capture all information relevant to predicting the future

ExplanationA Markov Decision Process formalizes sequential decision-making under uncertainty with five core elements: a set of States (S) describing all possible situations; a set of Actions (A) available to the agent; a Transition function P(s'|s,a) giving the probability of landing in state s' after taking action a in state s; a Reward function R(s,a) (or R(s,a,s')) specifying the immediate reward received; and a discount factor gamma weighing future rewards against immediate ones. The defining 'Markov' property is a specific, strong assumption: the transition and reward at any step depend ONLY on the current state and action — NOT on the full history of states/actions that led there. In other words, the current state must be a sufficient statistic capturing everything relevant to predicting the future; if the true dynamics genuinely depended on older history beyond the current state, the state representation itself would need to be redesigned (e.g., by including recent history explicitly) to restore the Markov property, which is exactly why careful STATE DESIGN is such a critical, often underappreciated part of formulating a real-world problem as an MDP.

Question 212 · Neural Architecture Search: Search Space · medium

Neural Architecture Search (NAS) automates the design of neural network architectures rather than having a human hand-design them. What is the SEARCH SPACE in NAS, and why does its design matter enormously for whether NAS succeeds practically?

  1. The search space refers to the physical server hardware NAS runs on, unrelated to the architectures themselves
  2. The search space is the set of all possible architecture CHOICES the search algorithm is allowed to consider — things like which operations (convolution, pooling, skip-connection) are available at each layer, how layers connect, and how many layers exist; its design matters enormously because a search space that's too LARGE makes the search computationally intractable (too many combinations to explore), while a search space that's too NARROW or poorly designed might not even CONTAIN any genuinely good architectures, meaning no search algorithm, however clever, could find one that isn't there to begin with
  3. The search space is always identical to the space of all possible hyperparameter learning rates only
  4. NAS has no search space concept — it generates architectures completely randomly with no defined boundaries

Answer: B. The search space is the set of all possible architecture CHOICES the search algorithm is allowed to consider — things like which operations (convolution, pooling, skip-connection) are available at each layer, how layers connect, and how many layers exist; its design matters enormously because a search space that's too LARGE makes the search computationally intractable (too many combinations to explore), while a search space that's too NARROW or poorly designed might not even CONTAIN any genuinely good architectures, meaning no search algorithm, however clever, could find one that isn't there to begin with

ExplanationThe search space in NAS defines the full universe of candidate architectures the search process is even allowed to consider — for example, which specific operations (3x3 convolution, 5x5 convolution, max pooling, skip connections, etc.) are available as building blocks at each position, how many layers/blocks the network can have, and what connectivity patterns between them are permitted. This design choice is critically important on both ends of a real tradeoff: an excessively LARGE, unconstrained search space (allowing essentially arbitrary connections and operations) makes the actual search computationally intractable, since the number of possible architectures can be astronomically large, and most search strategies (reinforcement learning controllers, evolutionary methods, or gradient-based approaches like DARTS) become far less sample-efficient as the space balloons. Conversely, a search space designed too narrowly (e.g., only allowing variations on one basic building block) might structurally EXCLUDE any genuinely excellent architecture from ever being considered, no matter how good the search algorithm is — the search can only find the best architecture that actually EXISTS within the space it's given to explore. This is why practical NAS research invests heavily in designing search spaces that are both tractable AND known to contain strong candidates, often based on human architectural intuition as a starting scaffold.

Question 213 · Mixture of Experts: Routing Advantage · hard

A Mixture of Experts (MoE) layer contains 8 'expert' sub-networks, but a learned GATING (routing) function selects only the TOP 2 experts to actually process each individual input token. What is the key computational advantage this provides over a single dense network with the SAME total parameter count as all 8 experts combined?

  1. There is no computational advantage — routing to fewer experts always makes the model strictly worse at every task
  2. The model gets access to a much LARGER total parameter count (spread across all 8 experts) while the actual COMPUTE cost per token stays proportional to only the 2 active experts, not all 8 — this decouples total model CAPACITY (which scales with all the parameters, even the unused ones for a given token) from per-token computational COST (which scales only with the active subset), letting the model be far larger in total capacity without a proportional increase in the compute needed to process each individual token
  3. MoE always uses fewer total parameters than a single dense network with equivalent performance
  4. The gating function eliminates the need for a loss function during training entirely

Answer: B. The model gets access to a much LARGER total parameter count (spread across all 8 experts) while the actual COMPUTE cost per token stays proportional to only the 2 active experts, not all 8 — this decouples total model CAPACITY (which scales with all the parameters, even the unused ones for a given token) from per-token computational COST (which scales only with the active subset), letting the model be far larger in total capacity without a proportional increase in the compute needed to process each individual token

ExplanationThe central appeal of Mixture of Experts is decoupling a model's total PARAMETER COUNT (its overall capacity/knowledge storage) from its per-token COMPUTATIONAL COST (how much compute is spent processing any single input). With 8 experts but a gate that routes each token to only the TOP 2, a given token's forward pass only activates 2/8 = 25% of the expert parameters — the compute cost for that token is roughly the same as a dense network only 2 experts' worth in size, even though the model's TOTAL parameter count (and thus its overall representational capacity, since different tokens can route to different expert combinations) reflects all 8 experts combined. This means an MoE model can have dramatically more total parameters than a comparably-priced (in compute terms) dense model, since most of those parameters sit idle for any given token, only 'switching on' when a token happens to route to them — a property that has made MoE architectures central to scaling modern large language models to enormous total parameter counts without a proportional explosion in the compute required per token processed.

Question 214 · Multi-Task Learning: Shared Representations · medium

A multi-task learning model shares its early (lower) layers across multiple tasks (e.g., detecting edges and textures useful for BOTH object detection and depth estimation), while having separate, task-specific output layers for each task. Why does this SHARING often improve performance on each individual task, compared to training completely separate models for each task?

  1. Sharing layers always hurts every task, since the tasks inevitably interfere with each other destructively
  2. Sharing lower layers acts as a form of REGULARIZATION: features useful for multiple related tasks tend to be more general and robust (less likely to be spurious patterns that only happen to help one specific task by overfitting to its particular training set), and each task's gradient signal effectively provides MORE, complementary training data for those shared layers than any single task alone would provide — this is especially valuable when individual tasks have limited labeled data, letting tasks with more data help tasks with less
  3. Multi-task learning is purely a computational efficiency trick, with zero effect on per-task accuracy
  4. Task-specific layers are never actually necessary; all layers should always be fully shared in multi-task learning

Answer: B. Sharing lower layers acts as a form of REGULARIZATION: features useful for multiple related tasks tend to be more general and robust (less likely to be spurious patterns that only happen to help one specific task by overfitting to its particular training set), and each task's gradient signal effectively provides MORE, complementary training data for those shared layers than any single task alone would provide — this is especially valuable when individual tasks have limited labeled data, letting tasks with more data help tasks with less

ExplanationSharing lower layers across related tasks provides two complementary benefits. First, it acts as an implicit REGULARIZER: a feature representation that must simultaneously serve multiple different tasks well is under pressure to capture genuinely general, robust patterns (like real edges and textures useful for many vision tasks) rather than overfitting to quirks specific to just one task's training set — features that only happen to help one narrow task, possibly by exploiting spurious correlations in its data, are less likely to also help a genuinely different task, so the shared representation gets pushed toward more transferable structure. Second, and just as importantly, each task's labeled training examples effectively contribute gradient signal to the SAME shared parameters — a task with abundant labeled data can help train better shared features that a DATA-SCARCE related task then benefits from too, a form of implicit knowledge transfer between tasks that wouldn't happen with fully separate models. This is precisely why multi-task learning tends to particularly shine when at least one task has limited labeled data but shares meaningful underlying structure with a data-richer task.

Question 215 · Object Detection: IoU Computation · medium

An object detector predicts a bounding box (0,0,4,4) for a car, while the ground-truth box is (2,2,6,6) — both boxes are 4x4 squares (area 16 each) that partially overlap. What is the Intersection over Union (IoU) between these two boxes?

  1. IoU = 1.0, since both boxes have the same area
  2. IoU ≈ 0.1429 — the overlapping region spans x from 2 to 4 and y from 2 to 4, giving an intersection area of 2x2=4; the union area is (16+16-4)=28 (total area of both boxes minus the double-counted overlap); IoU = intersection/union = 4/28 ≈ 0.1429
  3. IoU = 0.5, since the boxes overlap by half their width
  4. IoU cannot be computed for two boxes of equal size

Answer: B. IoU ≈ 0.1429 — the overlapping region spans x from 2 to 4 and y from 2 to 4, giving an intersection area of 2x2=4; the union area is (16+16-4)=28 (total area of both boxes minus the double-counted overlap); IoU = intersection/union = 4/28 ≈ 0.1429

ExplanationIoU measures overlap quality between a predicted box and the ground-truth box, computed as intersection area divided by union area. The predicted box spans x:[0,4], y:[0,4]; the ground-truth spans x:[2,6], y:[2,6]. The INTERSECTION is the overlapping rectangle: x-overlap is [max(0,2), min(4,6)] = [2,4] (width 2), y-overlap is [max(0,2), min(4,6)] = [2,4] (height 2), giving intersection area = 2x2 = 4. The UNION is the total area covered by either box, computed as (area of box 1) + (area of box 2) - (intersection, since it would otherwise be double-counted) = 16+16-4 = 28. IoU = 4/28 ≈ 0.1429. This relatively low IoU (well below the common 0.5 threshold used to judge a 'correct' detection in benchmarks like PASCAL VOC or COCO) illustrates that even two same-sized, substantially-overlapping boxes can have surprisingly low IoU if their overlap region is small relative to their combined footprint — which is exactly why IoU, not simple overlap area alone, is the standard metric for judging localization quality.

Question 216 · Semantic Segmentation: Dice Coefficient · medium

A semantic segmentation model predicts a mask covering 10 pixels as 'road', while the ground-truth road mask covers 12 pixels, with an overlap of 8 pixels between the two. What is the Dice coefficient for this prediction, and how does it compare conceptually to IoU?

  1. Dice ≈ 0.5714, identical to IoU for this example
  2. Dice ≈ 0.7273 — computed as (2 x overlap)/(predicted + ground truth) = (2x8)/(10+12) = 16/22 ≈ 0.7273; this is HIGHER than the IoU for the same numbers (which would be 8/(10+12-8)=8/14≈0.5714), because Dice weights the overlap TWICE in its numerator relative to the simple sum of both areas, making it structurally more forgiving/higher-valued than IoU for the identical overlap scenario — though both metrics rank predictions in the same relative order
  3. Dice and IoU are always exactly equal for any segmentation, by mathematical definition
  4. Dice cannot be computed unless the predicted and ground-truth masks are exactly the same size

Answer: B. Dice ≈ 0.7273 — computed as (2 x overlap)/(predicted + ground truth) = (2x8)/(10+12) = 16/22 ≈ 0.7273; this is HIGHER than the IoU for the same numbers (which would be 8/(10+12-8)=8/14≈0.5714), because Dice weights the overlap TWICE in its numerator relative to the simple sum of both areas, making it structurally more forgiving/higher-valued than IoU for the identical overlap scenario — though both metrics rank predictions in the same relative order

ExplanationThe Dice coefficient (also called the F1 score in a set-overlap context) is computed as (2 x intersection) / (size of set A + size of set B): here, (2x8)/(10+12) = 16/22 ≈ 0.7273. Comparing to IoU for the identical scenario — IoU = intersection/union = 8/(10+12-8) = 8/14 ≈ 0.5714 — Dice gives a noticeably HIGHER numeric value for the exact same underlying overlap. This isn't a contradiction; it's a structural property of the two formulas: Dice's numerator counts the overlap TWICE (2x8=16) against a denominator that's simply the sum of both areas (22, which double-counts the overlap region once), while IoU's denominator is the true UNION (14, counting the overlap region only once) — Dice is mathematically always greater than or equal to IoU for the same two sets (in fact, Dice = 2xIoU/(1+IoU) exactly). Despite differing numerically, both metrics rank different candidate predictions in the SAME relative order (a prediction with better overlap always scores higher on both), which is why either metric is a valid choice for segmentation evaluation, with Dice being especially common in medical image segmentation.

Question 217 · Self-Supervised Learning: Pretext Tasks · medium

Self-supervised learning trains a model on unlabeled data using a 'pretext task' — a task the model can learn from the data's own structure, without any human-provided labels. What is a PRETEXT TASK, and why is 'predict a randomly masked-out patch of an image from its surrounding context' a good example of one?

  1. A pretext task is any task that requires extensive human labeling before training can begin
  2. A pretext task is a supervisory signal DERIVED AUTOMATICALLY from the unlabeled data itself (no human labels needed) — the labels used to train it are constructed programmatically from the raw data (e.g., the masked-out patch's actual pixel values ARE the 'label', trivially obtainable from the very same unlabeled image); solving this task well requires the model to learn genuinely useful, transferable representations of visual structure (edges, textures, object parts, spatial relationships) — knowledge that then transfers well to real downstream tasks (like classification) after fine-tuning, even though the pretext task itself was never the actual goal
  3. A pretext task is always identical to the final downstream task the model will ultimately be used for
  4. Pretext tasks can only be applied to text data, never to images

Answer: B. A pretext task is a supervisory signal DERIVED AUTOMATICALLY from the unlabeled data itself (no human labels needed) — the labels used to train it are constructed programmatically from the raw data (e.g., the masked-out patch's actual pixel values ARE the 'label', trivially obtainable from the very same unlabeled image); solving this task well requires the model to learn genuinely useful, transferable representations of visual structure (edges, textures, object parts, spatial relationships) — knowledge that then transfers well to real downstream tasks (like classification) after fine-tuning, even though the pretext task itself was never the actual goal

ExplanationThe defining trick of self-supervised learning is constructing a training SIGNAL entirely from unlabeled data's own inherent structure, with no human annotation required — the 'labels' for the pretext task are derived programmatically and automatically. For masked-patch prediction: you take an unlabeled image, deliberately hide (mask) a patch, and task the model with predicting what was there — the actual pixel values of the masked patch, which you already know (you masked it yourself), serve as a free, automatically-generated label. Crucially, the pretext task is never the actual end goal — nobody genuinely cares about a model's ability to fill in masked patches for its own sake. What matters is that SOLVING this task well forces the model to learn genuinely useful internal representations: understanding masked-patch content well requires understanding textures, object boundaries, spatial context, and typical scene structure — exactly the kind of general visual knowledge that transfers effectively to real downstream tasks (like image classification or object detection) once the pretrained model is fine-tuned on a smaller labeled dataset for that actual task. This 'pretrain on a free, automatically-generated task, then fine-tune on the real task' pattern underlies most modern self-supervised approaches, in vision and language alike.

Question 218 · BERT: Masked Language Modeling · medium

BERT's pretraining uses Masked Language Modeling (MLM): roughly 15% of input tokens are replaced with a [MASK] token, and the model must predict the original word. Why does BERT use masking (rather than, like GPT, predicting the NEXT word given only the preceding words) as its pretraining objective?

  1. Masking and next-word prediction are functionally identical, with no meaningful architectural consequence
  2. Masking allows the model to use FULL BIDIRECTIONAL context — attending to words both BEFORE and AFTER the masked position — when predicting the masked word, which produces richer contextual representations for tasks like classification or question-answering that benefit from understanding a word's full surrounding context; a standard left-to-right next-word predictor CANNOT use bidirectional context during pretraining, because doing so would let it 'see the answer' (the actual next word) trivially, making the prediction task meaningless
  3. BERT uses masking purely because it makes training computationally cheaper, with no representational benefit
  4. Masking is only used at inference time, never during BERT's actual pretraining

Answer: B. Masking allows the model to use FULL BIDIRECTIONAL context — attending to words both BEFORE and AFTER the masked position — when predicting the masked word, which produces richer contextual representations for tasks like classification or question-answering that benefit from understanding a word's full surrounding context; a standard left-to-right next-word predictor CANNOT use bidirectional context during pretraining, because doing so would let it 'see the answer' (the actual next word) trivially, making the prediction task meaningless

ExplanationThe choice between masking (BERT) and left-to-right next-word prediction (GPT-style) reflects a fundamental architectural tradeoff. A standard next-word predictor must be causally constrained — it can only attend to PREVIOUS tokens when predicting the next one, because if it could see future tokens during training, predicting the 'next' word would become a trivial lookup (the answer would be sitting right there in the visible context), making the whole training signal meaningless. Masking sidesteps this constraint entirely: since the model is predicting a token in the MIDDLE of a sequence (with both earlier and later tokens visible, just not the masked position itself), it's free to use FULL bidirectional context — attending to words both before AND after the masked position — without any risk of trivially 'cheating', since the actual masked word is genuinely hidden, not just positioned later in a left-to-right scan. This bidirectional context is what makes BERT's learned representations particularly strong for tasks requiring deep understanding of a word's full surrounding context (like question-answering or sentence classification), which is exactly the design goal MLM was created to serve — at the cost of BERT not being naturally suited to autoregressive text GENERATION the way a next-word predictor is.

Question 219 · Word2Vec: CBOW vs Skip-gram · medium

Word2Vec has two main training architectures: CBOW (Continuous Bag of Words) and Skip-gram. Given the sentence 'the quick brown fox jumps', with 'brown' as the target word and a context window of 2, what does CBOW predict FROM what, versus what does Skip-gram predict FROM what?

  1. CBOW and Skip-gram are the exact same algorithm with two different names
  2. CBOW predicts the TARGET word ('brown') GIVEN its surrounding CONTEXT words ('the', 'quick', 'fox', 'jumps') as input — context predicts target; Skip-gram does the REVERSE — it takes the target word ('brown') as input and predicts each surrounding CONTEXT word individually — target predicts context
  3. CBOW only works on single-word sentences, while Skip-gram requires at least 10 words
  4. Both algorithms predict the NEXT sentence in a document, not individual words

Answer: B. CBOW predicts the TARGET word ('brown') GIVEN its surrounding CONTEXT words ('the', 'quick', 'fox', 'jumps') as input — context predicts target; Skip-gram does the REVERSE — it takes the target word ('brown') as input and predicts each surrounding CONTEXT word individually — target predicts context

ExplanationCBOW and Skip-gram are mirror-image training setups for learning word embeddings from local context, differing in which direction the prediction runs. CBOW (Continuous Bag of Words) takes the SURROUNDING context words as input (here, 'the', 'quick', 'fox', 'jumps' within the window-2 context around 'brown') and tries to predict the single TARGET word ('brown') that belongs in the middle — context words predict the target. Skip-gram works in the opposite direction: it takes the single TARGET word ('brown') as input and tries to predict EACH of the surrounding context words individually ('the', 'quick', 'fox', 'jumps' as separate prediction targets) — the target predicts its context. In practice, Skip-gram tends to perform better on rarer words (since it generates multiple training examples, one per context word, from each occurrence of a word), while CBOW trains faster and can perform slightly better on frequent words, since it smooths over multiple context words as a single averaged input signal rather than treating them as separate training examples.

Question 220 · Transfer Learning: Layer Freezing Rationale · medium

You have a small dataset of 500 medical X-ray images for a rare-disease classification task. Using TRANSFER LEARNING, you take a large model pretrained on millions of general photos (ImageNet) and FREEZE its early convolutional layers, only fine-tuning the later layers and a new classification head on your 500 X-rays. Why freeze the EARLY layers specifically, rather than fine-tuning the entire network?

  1. Freezing early layers is done purely to save disk storage space, with no effect on model performance or training
  2. Early convolutional layers in a network pretrained on diverse natural images tend to learn very GENERAL, low-level features (edges, corners, basic textures, color gradients) that are broadly useful across almost ANY visual domain, including X-rays; freezing them preserves this general, well-learned knowledge and prevents it from being DEGRADED by fine-tuning on a small dataset (500 images is far too few to re-learn robust low-level features from scratch without overfitting), while the LATER layers (which capture more task/domain-specific, higher-level patterns) are the ones that genuinely need adjustment for the new domain and task
  3. Early layers must always be frozen in every transfer learning scenario, regardless of dataset size or domain similarity
  4. Freezing early layers makes the model incapable of learning anything new whatsoever

Answer: B. Early convolutional layers in a network pretrained on diverse natural images tend to learn very GENERAL, low-level features (edges, corners, basic textures, color gradients) that are broadly useful across almost ANY visual domain, including X-rays; freezing them preserves this general, well-learned knowledge and prevents it from being DEGRADED by fine-tuning on a small dataset (500 images is far too few to re-learn robust low-level features from scratch without overfitting), while the LATER layers (which capture more task/domain-specific, higher-level patterns) are the ones that genuinely need adjustment for the new domain and task

ExplanationConvolutional neural networks trained on large, diverse image datasets tend to develop a characteristic HIERARCHY of learned features: early layers capture very general, low-level visual patterns (edges, corners, simple textures, color gradients) that are broadly useful across nearly any visual recognition task, since virtually all real images are built from these same basic visual primitives — this generality is exactly why these early features transfer well even to a very different domain like X-rays. Later layers, by contrast, tend to capture increasingly task-specific, high-level, semantic patterns (like 'this combination of shapes typically indicates a cat's face') that are much more tied to the specific dataset and task the network was originally trained on. With only 500 X-ray images, attempting to fine-tune ALL layers (including the early, general ones) risks CATASTROPHICALLY overfitting or degrading those well-learned general features — 500 images is nowhere near enough data to relearn robust low-level feature detectors from scratch without them collapsing into overly narrow, X-ray-specific (and likely worse) versions. Freezing the early layers protects this valuable, broadly-useful general knowledge while still allowing the later, more task-specific layers (and the new classification head) the flexibility to adapt to the new domain and task.

Question 221 · LSTM vs GRU: Structural Tradeoff · medium

An LSTM cell has THREE gates (forget, input, output) and maintains two separate states (a cell state c and a hidden state h). A GRU cell has only TWO gates (reset, update) and maintains a SINGLE state (h only). Given this structural difference, what is the practical tradeoff between choosing LSTM versus GRU for a given sequence task?

  1. LSTM and GRU are mathematically identical; the different gate names are purely cosmetic
  2. GRU's simpler structure (fewer gates, fewer parameters, one state instead of two) makes it FASTER to train and less prone to overfitting on smaller datasets, while LSTM's extra gate and separate cell state give it more fine-grained control over what information to retain versus forget, which can capture more complex long-range dependencies on larger, more complex datasets — neither is strictly superior; the choice is an empirical tradeoff between model capacity/expressiveness and training efficiency/data requirements
  3. GRU always outperforms LSTM on every task, making LSTM obsolete
  4. LSTM can only process fixed-length sequences, while GRU can process sequences of any length

Answer: B. GRU's simpler structure (fewer gates, fewer parameters, one state instead of two) makes it FASTER to train and less prone to overfitting on smaller datasets, while LSTM's extra gate and separate cell state give it more fine-grained control over what information to retain versus forget, which can capture more complex long-range dependencies on larger, more complex datasets — neither is strictly superior; the choice is an empirical tradeoff between model capacity/expressiveness and training efficiency/data requirements

ExplanationThe structural difference translates into a genuine practical tradeoff, not a strict ordering of 'better' and 'worse'. GRU's design — 2 gates instead of 3, and a single merged hidden state instead of LSTM's separate cell state and hidden state — means fewer total learnable parameters for a given hidden size, which typically means faster training per step, lower memory usage, and often better generalization on SMALLER datasets (fewer parameters means less capacity to overfit limited data). LSTM's additional gate and separate cell state (which acts as a more protected, longer-term 'memory highway' distinct from the hidden state used for immediate output) give it finer-grained, more expressive control over exactly what information gets added, kept, or discarded at each timestep — this extra capacity can help capture more complex long-range dependencies, but requires more data and compute to fully exploit; on smaller or simpler tasks that extra capacity may bring no benefit while adding unnecessary training cost. In practice, both remain in active use, and the right choice is typically determined empirically per task and dataset size, not by a universal rule that one always beats the other.
← Set 10