uiz Space

September 2024 term · Deep Learning Practice · BSDA5013

Deep Learning Practice End Term: 22 December 2024 (September 2024 term)

The IIT Madras BS Deep Learning Practice (Deep Learning Practice) End Term paper sat on 22 Dec 2024, in the September 2024 term: 20 questions for 100 marks in 180 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
100
Duration
180 min
MCQ
19
MSQ
1

Updated

Official paper: IIT M DEGREE AN EXAM QDB4 22 Dec 2024 · No negative marking.

Question 1

+5 marksOne correct option

Consider the following code snippets for loading and modifying VGGNet-16 and VGGNet-19 architectures for a classification task with 10 classes:

python
import torch
import torch.nn as nn
from torchvision.models import vgg16, vgg19
# Block A: VGGNet-16 with modified classification head
class VGG16Modified(nn.Module):
def __init__(self, num_classes=10):
super(VGG16Modified, self).__init__()
self.vgg16 = vgg16(pretrained=True)
self.vgg16.classifier[6] = nn.Linear(4096, num_classes)
def forward(self, x):
return self.vgg16(x)
model_a = VGG16Modified()
# Block B: VGGNet-19 with modified classification head
class VGG19Modified(nn.Module):
def __init__(self, num_classes=10):
super(VGG19Modified, self).__init__()
self.vgg19 = vgg19(pretrained=True)
self.vgg19.classifier[6] = nn.Linear(4096, num_classes)
def forward(self, x):
return self.vgg19(x)
model_b = VGG19Modified()
# Block C: Loading VGGNet-16 and freezing feature extraction layers
vgg16_model = vgg16(pretrained=True)
for param in vgg16_model.features.parameters():
param.requires_grad = False
vgg16_model.classifier[6] = nn.Linear(4096, 10)
# Block D: VGGNet-19 with feature extraction layers unfrozen
vgg19_model = vgg19(pretrained=True)
vgg19_model.classifier[6] = nn.Linear(4096, 10)

Which of the following statements are true about the provided blocks?

(a) Block A uses VGGNet-16 and modifies the classification head to support 10 classes.
(b) Block B and Block C both use VGGNet-19 but differ in how feature extraction layers are handled.
(c) Block C freezes the feature extraction layers in VGGNet-16 for transfer learning.
(d) Block D unfreezes feature extraction layers in VGGNet-19, making it trainable end-to-end.

Select the correct options:

  1. A

    (a) and (c)

  2. B

    (b) and (d)

  3. C

    (a), (c), and (d)

  4. D

    All of these

Show answer

Correct answer

  • C

    (a), (c), and (d)

Question 2

+5 marksOne correct option
  1. A

    LeNet

  2. B

    ResNet

  3. C

    AlexNet

  4. D

    VGG16

  5. E

    None

Show answer

Correct answer

  • C

    AlexNet

Question 3

+5 marksOne correct option

Suppose I have an image of size 227×227. Which of the following code snippets correctly implements a Min Pooling operation with a window size of 2 × 2, stride of 2, and padding of 1 in PyTorch?

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

Correct answer

  • A

Question 4

+5 marksOne correct option

Consider a black-and-white image of dimension 227×227. Which of the following correctly demonstrates a function to flatten it along with the dimension of the newly formed vector?

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

Correct answer

  • B

Question 5

+5 marksOne correct option

Which of the following code snippets correctly implements the skip connection in ResNet?

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

Correct answer

  • A

Question 6

+5 marksOne correct option
  1. A

    11

  2. B

    10

  3. C

    12

  4. D

    14

Show answer

Correct answer

  • B

    10

Question 7

+5 marksOne correct option

The following code snippets represent different blocks in the Fast R-CNN pipeline. Identify the correct arrangement of these blocks in the Fast R-CNN architecture:

A. Block A

python
import torch
import torch.nn as nn
class RegionProposal(nn.Module):
def __init__(self, in_channels):
super(RegionProposal, self).__init__()
self.conv = nn.Conv2d(in_channels, 256, kernel_size=3, stride=1, padding=1)
self.cls_layer = nn.Conv2d(256, 18, kernel_size=1)
self.reg_layer = nn.Conv2d(256, 36, kernel_size=1)
def forward(self, x):
features = torch.relu(self.conv(x))
cls_logits = self.cls_layer(features)
reg_deltas = self.reg_layer(features)
return cls_logits, reg_deltas

B. Block B

python
import torchvision.models as models
class FeatureExtractor(nn.Module):
def __init__(self):
super(FeatureExtractor, self).__init__()
vgg = models.vgg16(pretrained=True)
self.features = vgg.features # Use pre-trained VGG16 convolutional layers
def forward(self, x):
return self.features(x)

C. Block C

python
from torchvision.ops import roi_pool
class ROIPooling(nn.Module):
def __init__(self, output_size=(7, 7)):
super(ROIPooling, self).__init__()
self.output_size = output_size
def forward(self, feature_map, proposals):
return roi_pool(feature_map, proposals, output_size=self.output_size)

D. Block D

python
class FullyConnectedHead(nn.Module):
def __init__(self, in_features, num_classes):
super(FullyConnectedHead, self).__init__()
self.fc1 = nn.Linear(in_features, 4096)
self.fc2 = nn.Linear(4096, 4096)
self.cls_score = nn.Linear(4096, num_classes)
self.bbox_pred = nn.Linear(4096, num_classes * 4) # 4 coordinates per class
def forward(self, x):
x = torch.relu(self.fc1(x))
x = torch.relu(self.fc2(x))
cls_logits = self.cls_score(x)
bbox_deltas = self.bbox_pred(x)
return cls_logits, bbox_deltas

Which of the following is the correct arrangement of these blocks in the Fast R-CNN architecture?

  1. A

    B, A, C, D

  2. B

    A, B, C, D

  3. C

    B, C, D, A

  4. D

    C, A, B, D

Show answer

Correct answer

  • A

    B, A, C, D

Question 8

+5 marksOne correct option

Which of the following code snippets correctly models the loss function in YOLO?

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

Correct answer

  • A

Question 9

+5 marksOne correct option

Consider the following predictions and ground truths for a binary classification problem: - True Positives (TP): 30 - False Positives (FP): 10 - False Negatives (FN): 20
Which of the following correctly calculates the Precision and F1-Score for this classification task?

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

Correct answer

  • A

Question 10

+5 marksOne correct option

How many convolutional layers are there in the original YOLO architecture?

  1. A

    24

  2. B

    19

  3. C

    53

  4. D

    75

Show answer

Correct answer

  • A

    24

Question 11

+5 marksOne correct option

Consider the following code snippet that calculates the Intersection over Union (IoU) for two bounding boxes:

python
import torch
def calculate_iou(box1, box2):
# Calculate intersection
x1 = torch.max(box1[0], box2[0])
y1 = torch.max(box1[1], box2[1])
x2 = torch.min(box1[2], box2[2])
y2 = torch.min(box1[3], box2[3])
intersection = torch.clamp(x2 - x1, min=0) * torch.clamp(y2 - y1, min=0)
# Calculate union
area1 = (box1[2] - box1[0]) * (box1[3] - box1[1])
area2 = (box2[2] - box2[0]) * (box2[3] - box2[1])
union = area1 + area2 - intersection
# Compute IoU
iou = intersection / union if union > 0 else 0
return iou
# Bounding boxes: [x1, y1, x2, y2]
box1 = torch.tensor([0, 0, 2, 2])
box2 = torch.tensor([1, 1, 3, 3])
print(calculate_iou(box1, box2))

What will the function output for the given bounding boxes?

  1. A

    0.142

  2. B

    0.250

  3. C

    0.333

  4. D

    0.500

Show answer

Correct answer

  • A

    0.142

Question 12

+5 marksOne correct option

Consider the following code snippets used in a multiscale deep network for single-image depth estimation. Both blocks play different roles in the network.

Which of the following best describes the roles of the two blocks?

A. Block A:

python
import torch
import torch.nn as nn
class DepthNetwork(nn.Module):
def __init__(self):
super(DepthNetwork, self).__init__()
self.encoder = nn.Sequential(
nn.Conv2d(3, 64, kernel_size=7, stride=2, padding=3),
nn.ReLU(),
nn.Conv2d(64, 128, kernel_size=5, stride=2, padding=2),
nn.ReLU()
)
self.fc = nn.Sequential(
nn.Linear(128 * 28 * 28, 1024),
nn.ReLU(),
nn.Linear(1024, 128 * 56 * 56)
)
def forward(self, x):
x = self.encoder(x)
x = x.view(x.size(0), -1)
x = self.fc(x)
x = x.view(x.size(0), 128, 56, 56)
return x

B. Block B:

python
import torch
import torch.nn as nn
class DepthRefinementNetwork(nn.Module):
def __init__(self):
super(DepthRefinementNetwork, self).__init__()
self.refinement = nn.Sequential(
nn.Conv2d(131, 64, kernel_size=3, padding=1),
nn.ReLU(),
nn.Conv2d(64, 1, kernel_size=3, padding=1)
)
def forward(self, coarse_depth, rgb):
x = torch.cat((coarse_depth, rgb), dim=1) # Concatenate coarse depth and RGB
x = self.refinement(x)
return x
  1. A

    Block A generates high-level global features and outputs an initial coarse depth map, while Block B refines the depth map using local details from the RGB image and the coarse depth map.

  2. B

    Block A performs refinement of the depth map using concatenated coarse depth and RGB features, while Block B generates the coarse depth map from the input RGB image.

  3. C

    Both Block A and Block B are coarse networks, with Block B performing an additional refinement step.

  4. D

    Block A generates a low-resolution coarse depth map but does not include global features, while Block B produces fine-grained depth without refinement.

Show answer

Correct answer

  • A

    Block A generates high-level global features and outputs an initial coarse depth map, while Block B refines the depth map using local details from the RGB image and the coarse depth map.

Question 13

+5 marksOne correct option

Which of the following code snippets correctly implements the **downsampling** operation in a U-Net architecture?

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

Correct answer

  • A

Question 14

+5 marksOne correct option

Consider the following predictions and ground truth values:
- Predictions: [3.0,−0.5, 2.0, 7.0] - Ground Truth: [2.5, 0.0, 2.0, 8.0]
The Mean Squared Error (MSE) is calculated using one of the following code snippets. Identify the correct implementation and its result.

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

Correct answer

  • B

Question 15

+5 marksOne correct option

In a stereo vision system, left-right disparity is used to compute depth by comparing
corresponding points in the left and right images. Which of the following statements about left right disparity is correct?

  1. A

    Disparity is the absolute difference in pixel intensities between the left and right images.

  2. B

    Disparity increases as the depth of an object increases from the cameras.

  3. C

    Disparity is the horizontal shift between corresponding points in the left and right images.

  4. D

    Disparity is the vertical difference between points in the left and right images.

Show answer

Correct answer

  • C

    Disparity is the horizontal shift between corresponding points in the left and right images.

Question 16

+5 marksOne correct option

What are the primary roles of the **generator** and **discriminator** in a Super-Resolution GAN (SRGAN) architecture?

  1. A

    The generator produces high-resolution images from low-resolution inputs, while the discriminator distinguishes real high-resolution images from generated high-resolution images.

  2. B

    The generator distinguishes real high-resolution images from generated images, while the discriminator produces high-resolution images from low-resolution inputs.

  3. C

    Both the generator and discriminator produce high-resolution images from low-resolution inputs.

  4. D

    Both the generator and discriminator distinguish real high-resolution images from generated high-resolution images.

Show answer

Correct answer

  • A

    The generator produces high-resolution images from low-resolution inputs, while the discriminator distinguishes real high-resolution images from generated high-resolution images.

Question 17

+5 marksOne correct option

Which of the following code snippets correctly adds gaussian noise to an image?

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

Correct answer

  • A

Question 18

+5 marksOne correct option

What are the benefits of using depthwise and pointwise convolutions (as in depthwise separable convolutions) compared to standard convolutions?

  1. A

    They reduce the number of parameters and computational cost, making the model more efficient.

  2. B

    They improve the accuracy of the model by learning richer spatial features.

  3. C

    They reduce overfitting by performing regularization during convolution operations.

  4. D

    They allow convolutions to operate across both spatial dimensions and depth channels simultaneously.

Show answer

Correct answer

  • A

    They reduce the number of parameters and computational cost, making the model more efficient.

Question 19

+5 marksOne correct option

Which of the following code snippets correctly implements the **generator** for a super- resolution GAN (SRGAN) network?

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

Correct answer

  • D

Question 20

+5 marksOne or more correct options

Which of the following are common use cases of super-resolution using SRGAN?

Select all that apply.

  1. A

    Enhancing medical imaging scans for improved diagnosis.

  2. B

    Increasing the resolution of satellite images for geographical analysis.

  3. C

    Generating high-quality images for video streaming and upscaling.

  4. D

    Translating text from one language to another in images.

  5. E

    Improving the resolution of historical or archival images.

Show answer

Correct answers

  • A

    Enhancing medical imaging scans for improved diagnosis.

  • B

    Increasing the resolution of satellite images for geographical analysis.

  • C

    Generating high-quality images for video streaming and upscaling.

  • E

    Improving the resolution of historical or archival images.