uiz Space

September 2025 term · Introduction to Deep Learning and Generative AI · BSDA2001

Introduction to Deep Learning and Generative AI Quiz 1: 26 October 2025 (September 2025 term)

The IIT Madras BS Introduction to Deep Learning and Generative AI (Deep Learning and GenAI) Quiz 1 paper sat on 26 Oct 2025, in the September 2025 term: 20 questions for 50 marks in 120 minutes. Every question is below with its answer. Take it as a timed mock test to be marked, or read it through first.

Questions
20
Marks
50
Duration
120 min
MCQ
10
Numerical
10

Updated

Official paper: IIT M DIPLOMA AN EXAM QDD2 26 Oct 2025 · No negative marking.

Question 1

+2 marksOne correct option
  1. A

    torch.tensor([1, 4, 7])

  2. B

    torch.tensor([2, 5, 8])

  3. C

    torch.tensor([3, 6, 9])

  4. D

    torch.tensor([4, 5, 6])

  5. E

    torch.tensor([5])

Show answer

Correct answer

  • B

    torch.tensor([2, 5, 8])

Question 2

+2 marksOne correct option

You have a tensor x = torch.tensor([1, 2, 3, 4]) with shape (4,). You perform the following operations:

python
stacked_x = torch.stack([x, x, x], dim=0)
stacked_y = torch.stack([x, x, x], dim=1)

What are the shapes of stacked_x and stacked_y respectively?

  1. A

    (3, 4) and (3, 4)

  2. B

    (3, 4) and (4, 3)

  3. C

    (4, 3) and (4, 3)

  4. D

    (4, 3) and (3, 4)

Show answer

Correct answer

  • B

    (3, 4) and (4, 3)

Question 3

+2 marksOne correct option
  1. A

    (1, 2, 2)

  2. B

    (2, 2)

  3. C

    (2,)

  4. D

    (1, 1, 2, 2)

  5. E

    (1, 2, 2, 1)

Show answer

Correct answer

  • B

    (2, 2)

Question 4

+2 marksOne correct option

You are writing a PyTorch training script on a machine with a CUDA-enabled GPU. You have correctly identified the device and moved your model to it. However, when you run your script, it crashes on the forward pass with a RuntimeException, indicating that the model's weights and the input data are on different devices.

Review the following code snippet and determine the single line of code that must be added to the ---BLANK --- to fix this specific error.

python
import torch
import torch.nn as nn
# 1. Setup device and move the model to it
device = torch.device("cuda" if torch.cuda.is_available() else "cpu")
model = nn.Linear(in_features=64, out_features=10).to(device)
optimizer = torch.optim.Adam(model.parameters(), lr=0.001)
# 2. Create a batch of input data (defaults to CPU)
# This simulates data coming from a DataLoader
input_batch = torch.randn(32, 64) # [batch_size, feature_size]
# 3. Perform a training step
optimizer.zero_grad()
# --- BLANK ---
# The following line causes the error:
# "RuntimeException: Expected all tensors to be on the same device,
# but found at least two devices, cuda:0 and cpu!"
outputs = model(input_batch)
# ... loss calculation and backward pass would follow

What line of code should be placed in the --- BLANK --- to resolve this device mismatch?

  1. A

    model.cuda()

  2. B

    input_batch.cuda()

  3. C

    input_batch = input_batch.requires_grad_(True)

  4. D

    input_batch = input_batch.to(device)

  5. E

    torch.set_default_tensor_type('torch.cuda.FloatTensor')

Show answer

Correct answer

  • D

    input_batch = input_batch.to(device)

Question 5

+2 marksOne correct option
  1. A

    It prevents parameters from being changed by the optimizer during the forward pass.

  2. B

    It deallocates the model's parameters from the GPU to save memory.

  3. C

    It disables the creation of the computational graph, saving memory and speeding up execution.

  4. D

    It ensures that the model operates entirely on the CPU, preventing unnecessary GPU transfers.

Show answer

Correct answer

  • C

    It disables the creation of the computational graph, saving memory and speeding up execution.

Question 6

+2 marksOne correct option
  1. A
  2. B
  3. C
  4. D
Show answer

Correct answer

  • D

Question 7

+2 marksNumerical answer

Consider the following PyTorch code that defines a small 3-layer fully connected neural network

python
import torch
import torch.nn as nn
class SmallNet(nn.Module):
def __init__(self):
super(SmallNet, self).__init__()
self.fc1 = nn.Linear(4, 6) # input -> hidden1
self.fc2 = nn.Linear(6, 3) # hidden1 -> hidden2
self.fc3 = nn.Linear(3, 2) # hidden2 -> output
def forward(self, x):
x = torch.relu(self.fc1(x))
x = torch.relu(self.fc2(x))
x = self.fc3(x)
return x

How many trainable parameters (weights + biases) does this network have in total?

Show answer

Correct answer: 59

Question 8

+3 marksOne correct option

Consider the following code:

python
import torch
import torch.nn as nn
model = nn.Sequential(
nn.Linear(10, 10),
nn.BatchNorm1d(10),
nn.ReLU(),
nn.Dropout(p=0.5),
nn.Linear(10, 1)
)
X = torch.randn(4, 10)
# Run in training mode
model.train()
out_train = model(X)
# Run in evaluation mode
model.eval()
out_eval = model(X)
print(out_train)
print(out_eval)

Removing which of the following layers will make out_train and out_eval identical for the same input?

  1. A
  2. B
  3. C
  4. D
  5. E
Show answer

Correct answer

  • C

Question 9

+3 marksOne correct option

Based on the above data, answer the given subquestions.

If all the weights are initalized to 0 and the input to the network is also a zero vector, then what should be the value of bias so that the output of the network is 0.5 ?

  1. A

    0.5

  2. B

    ln(5)

  3. C

    ln(1)

  4. D

    1

Show answer

Correct answer

  • C

    ln(1)

Question 10

+4 marksOne correct option

Based on the above data, answer the given subquestions.

  1. A
  2. B
  3. C
  4. D
Show answer

Correct answer

  • D

Question 11

+3 marksOne correct option

Select the equation representing the forward pass of the given network:

  1. A
  2. B
  3. C
  4. D
Show answer

Correct answer

  • B

Question 12

+6 marksNumerical answer
Show answer

Correct answer: 1

Question 13

+2 marksNumerical answer
Show answer

Correct answer: 1

Question 14

+3 marksNumerical answer

Consider the following CNN defined in PyTorch:

python
import torch
import torch.nn as nn
import torch.nn.functional as F
class SimpleCNN(nn.Module):
def __init__(self):
super(SimpleCNN, self).__init__()
# Conv Layer 1: in_channels=1 (grayscale), out_channels=8
self.conv1 = nn.Conv2d(in_channels=1, out_channels=8,
kernel_size=3, stride=1, padding=1)
# Pool Layer 1
self.pool1 = nn.MaxPool2d(kernel_size=2, stride=2)
# Conv Layer 2: in_channels=8, out_channels=16
self.conv2 = nn.Conv2d(in_channels=8, out_channels=16,
kernel_size=3, stride=1, padding=1)
# Pool Layer 2
self.pool2 = nn.MaxPool2d(kernel_size=2, stride=2)
# Fully Connected Layers
self.fc1 = nn.Linear(16 * 7 * 7, 128)
# Flattened from conv2 output
self.fc2 = nn.Linear(128, 10) # Output for 10 classes
def forward(self, x):
x = self.pool1(F.relu(self.conv1(x))) # Conv1 + Pool1
x = self.pool2(F.relu(self.conv2(x))) # Conv2 + Pool2
x = x.view(-1, 16 * 7 * 7) # Flatten
x = F.relu(self.fc1(x)) # FC1
x = self.fc2(x) # FC2
return x
# Example input
model = SimpleCNN()
print(model)

Based on the above data, answer the given subquestions.

How many trainable parameters are there in the first convolutional layer including bias (conv1)?

Show answer

Correct answer: 80

Question 15

+1 markNumerical answer

Consider the following CNN defined in PyTorch:

python
import torch
import torch.nn as nn
import torch.nn.functional as F
class SimpleCNN(nn.Module):
def __init__(self):
super(SimpleCNN, self).__init__()
# Conv Layer 1: in_channels=1 (grayscale), out_channels=8
self.conv1 = nn.Conv2d(in_channels=1, out_channels=8,
kernel_size=3, stride=1, padding=1)
# Pool Layer 1
self.pool1 = nn.MaxPool2d(kernel_size=2, stride=2)
# Conv Layer 2: in_channels=8, out_channels=16
self.conv2 = nn.Conv2d(in_channels=8, out_channels=16,
kernel_size=3, stride=1, padding=1)
# Pool Layer 2
self.pool2 = nn.MaxPool2d(kernel_size=2, stride=2)
# Fully Connected Layers
self.fc1 = nn.Linear(16 * 7 * 7, 128)
# Flattened from conv2 output
self.fc2 = nn.Linear(128, 10) # Output for 10 classes
def forward(self, x):
x = self.pool1(F.relu(self.conv1(x))) # Conv1 + Pool1
x = self.pool2(F.relu(self.conv2(x))) # Conv2 + Pool2
x = x.view(-1, 16 * 7 * 7) # Flatten
x = F.relu(self.fc1(x)) # FC1
x = self.fc2(x) # FC2
return x
# Example input
model = SimpleCNN()
print(model)

Based on the above data, answer the given subquestions.

What is the total number of trainable parameters in the pooling layers(pool1 and pool2)?

Show answer

Correct answer: 0

Question 16

+1 markNumerical answer

Consider the following CNN defined in PyTorch:

python
import torch
import torch.nn as nn
import torch.nn.functional as F
class SimpleCNN(nn.Module):
def __init__(self):
super(SimpleCNN, self).__init__()
# Conv Layer 1: in_channels=1 (grayscale), out_channels=8
self.conv1 = nn.Conv2d(in_channels=1, out_channels=8,
kernel_size=3, stride=1, padding=1)
# Pool Layer 1
self.pool1 = nn.MaxPool2d(kernel_size=2, stride=2)
# Conv Layer 2: in_channels=8, out_channels=16
self.conv2 = nn.Conv2d(in_channels=8, out_channels=16,
kernel_size=3, stride=1, padding=1)
# Pool Layer 2
self.pool2 = nn.MaxPool2d(kernel_size=2, stride=2)
# Fully Connected Layers
self.fc1 = nn.Linear(16 * 7 * 7, 128)
# Flattened from conv2 output
self.fc2 = nn.Linear(128, 10) # Output for 10 classes
def forward(self, x):
x = self.pool1(F.relu(self.conv1(x))) # Conv1 + Pool1
x = self.pool2(F.relu(self.conv2(x))) # Conv2 + Pool2
x = x.view(-1, 16 * 7 * 7) # Flatten
x = F.relu(self.fc1(x)) # FC1
x = self.fc2(x) # FC2
return x
# Example input
model = SimpleCNN()
print(model)

Based on the above data, answer the given subquestions.

How many parameters (weights and biases) does the first fully connected layer (fc1) have?

Show answer

Correct answer: 100480

Question 17

+1 markNumerical answer

Consider the following CNN defined in PyTorch:

python
import torch
import torch.nn as nn
import torch.nn.functional as F
class SimpleCNN(nn.Module):
def __init__(self):
super(SimpleCNN, self).__init__()
# Conv Layer 1: in_channels=1 (grayscale), out_channels=8
self.conv1 = nn.Conv2d(in_channels=1, out_channels=8,
kernel_size=3, stride=1, padding=1)
# Pool Layer 1
self.pool1 = nn.MaxPool2d(kernel_size=2, stride=2)
# Conv Layer 2: in_channels=8, out_channels=16
self.conv2 = nn.Conv2d(in_channels=8, out_channels=16,
kernel_size=3, stride=1, padding=1)
# Pool Layer 2
self.pool2 = nn.MaxPool2d(kernel_size=2, stride=2)
# Fully Connected Layers
self.fc1 = nn.Linear(16 * 7 * 7, 128)
# Flattened from conv2 output
self.fc2 = nn.Linear(128, 10) # Output for 10 classes
def forward(self, x):
x = self.pool1(F.relu(self.conv1(x))) # Conv1 + Pool1
x = self.pool2(F.relu(self.conv2(x))) # Conv2 + Pool2
x = x.view(-1, 16 * 7 * 7) # Flatten
x = F.relu(self.fc1(x)) # FC1
x = self.fc2(x) # FC2
return x
# Example input
model = SimpleCNN()
print(model)

Based on the above data, answer the given subquestions.

What is the total number of convolution filters used in this CNN?

Show answer

Correct answer: 24

Question 18

+3 marksNumerical answer

Based on the above data, answer the given subquestions.

Show answer

Correct answer: 1

Question 19

+3 marksNumerical answer

Based on the above data, answer the given subquestions.

Show answer

Correct answer: 2

Question 20

+3 marksNumerical answer

Based on the above data, answer the given subquestions.

Show answer

Correct answer: 192