Explore topic-wise InterviewSolutions in .

This section includes InterviewSolutions, each offering curated multiple-choice questions to sharpen your knowledge and support exam preparation. Choose a topic below to get started.

1.

Which of the following is used to load dataset in batches?

Answer»

Which of the FOLLOWING is used to LOAD dataset in batches?
Please choose the correct option from below list
(1)torch.utils.Loader()
(2)torch.utils.data.Load()
(3)torch.utils.data.Loader()
(4)torch.utils.data.DataLoader()

ANSWER:-(4)torch.utils.data.DataLoader()

2.

If the shape of the Tensor is 2 x 1 x 3 x 1, performing torch.sqeeze() will output Tensor of shape _______.

Answer»

If the shape of the Tensor is 2 x 1 x 3 x 1, performing torch.sqeeze() will OUTPUT Tensor of shape _______.
Please choose the correct option from below LIST
(1)3 x 2
(2)2 x 3
(3)1 x 6
(4)6 x 1

Answer:-(2)2 x 3

3.

For an optimizer defined, which of the following function is used to update the parameters passed to the optimizer?

Answer»

For an optimizer defined, which of the following function is used to update the PARAMETERS passed to the optimizer?
Please choose the correct option from below list
(1).BACKWARD()
(2).grad()
(3).step()
(4).update()

ANSWER:-(3).step()

4.

While defining the Tensor, which of the following parameters is used to track the gradients on Tensor?

Answer»

While defining the Tensor, which of the FOLLOWING parameters is used to track the gradients on Tensor?
PLEASE choose the correct option from below list
(1)requires_grad
(2)set_grad
(3)grade
(4)has_grad

Answer:-(1)requires_grad

5.

Once you train model weights, bias can be accessed using ____________.

Answer»

Once you TRAIN model weights, BIAS can be accessed using ____________.
Please CHOOSE the correct option from below list
(1)model.state_dict()
(2)model.dict()
(3)model.parameters()
(4)model.get_state_dict()

ANSWER:-(1)model.state_dict()

6.

For x = torch.Tensor([1, 2, 3, 4]), after x = torch.unsqueeze(x, 0) x will be of the shape _______.

Answer»

For x = torch.Tensor([1, 2, 3, 4]), after x = torch.unsqueeze(x, 0) x will be of the shape _______.
Please CHOOSE the correct option from below list
(1)1 x 4
(2)1 x 1 x 4
(3)2 x 2
(4)1 x 4 x 1

Answer:-(1)1 x 4

7.

Which of the following is used to load the weights into the model from the file?

Answer»

Which of the FOLLOWING is USED to LOAD the weights into the model from the file?
Please choose the correct option from below list
(1)model.load_state()
(2)model.load_parameters()
(3)model.load_state_dict()
(4)nodel.load_weights()

Answer:-(3)model.load_state_dict()

8.

Which of the following function is used to convert NumPy array to Tensor?

Answer»

Which of the following function is used to CONVERT NUMPY array to Tensor?
PLEASE choose the CORRECT option from below list
(1).from_numpy().to_Tensor()
(2).from_numpy()

Answer:-(2).from_numpy()

9.

Which of the following function is used to save the model parameters to a file?

Answer»

Which of the following FUNCTION is used to SAVE the model PARAMETERS to a file?
Please choose the correct option from below list
(1)torch.to_file()
(2)torch.save_model()
(3)torch.save_state_dict()
(4)torch.save()

Answer:-(4)torch.save()

10.

Which of the following is used to view the shape of the Tensor?

Answer»

Which of the following is used to view the shape of the TENSOR?
PLEASE CHOOSE the correct option from below list
(1).view_()
(2).view()
(3).size()
(4).get_dimension()

Answer:-(2).view()

11.

Which of the following function is used to compute the gradients on a loss function?

Answer»

Which of the following function is USED to COMPUTE the gradients on a loss function?
Please choose the correct OPTION from below list
(1).gradients()
(2).step()
(3).grads()
(4).backwards()

Answer:-(4).backwards()

12.

Which of the following functions is used to save the model parameters to a file?

Answer»

Which of the following functions is used to SAVE the MODEL parameters to a file?
PLEASE choose the CORRECT option from below LIST
(1)torch.save()
(2)torch.save_state_dict()
(3)torch.to_file()
(4)torch.save_model()

Answer:-(1)torch.save()

13.

Which of the following function is used to covert NumPy array to Tensor?

Answer»

Which of the FOLLOWING FUNCTION is used to COVERT NumPy array to Tensor?
Please choose the correct option from below list
(1).tensor
(2).to_Tensor()
(3).from_numpy()
(4).to_Vector()

ANSWER:-(3).from_numpy()

14.

Which of the following is the base class for all the neural networks in PyTorch?

Answer»

Which of the FOLLOWING is the BASE class for all the neural networks in PYTORCH?
Please CHOOSE the correct option from below LIST
(1)torch.nn.Model
(2)torch.Module
(3)torch.nn.Network
(4)torch.nn.Module

Answer:-(4)torch.nn.Module

15.

PyTorch requires the graph to be defined before running the model.

Answer»

PyTorch REQUIRES the graph to be defined before running the model.
Please choose the correct option from below list
(1)FALSE
(2)True

Answer:-(1)False

16.

Which of the following constructor is used to add convolution layer while building the model?

Answer»

Which of the following constructor is USED to add convolution layer while BUILDING the model?
Please choose the correct OPTION from below list
(1)nn.layers.Conv()
(2)nn.Conv()
(3)nn.layers.Conv2d()
(4)nn.Conv2d()

Answer:-(4)nn.Conv2d()

17.

Which of the following defines the convolution layer with a 3 input channel, four out channels and a 3 x 3 filter?

Answer»

Which of the following DEFINES the convolution layer with a 3 input channel, four out CHANNELS and a 3 x 3 FILTER?
Please CHOOSE the correct option from below LIST
(1)nn.Conv2d(3, 4, kernel_size=(3, 3))
(2)nn.Conv2d(3, 3, kernel_size=(3, 4))
(3)nn.Conv2d(3, 4, kernel_size=(3, 4))
(4)nn.Conv2d(4, 3, kernel_size=(4, 3))

Answer:-(2)nn.Conv2d(3, 3, kernel_size=(3, 4))

18.

If the model has 10 features, and two hidden layers of 20 nodes and 30 nodes, the network is defined as ___________.

Answer»

If the model has 10 features, and two hidden layers of 20 nodes and 30 nodes, the network is defined as ___________.
Please choose the correct option from below LIST
(1)torch.nn.Sequential(nn.Linear(20,10), nn.Linear(30,20))
(2)torch.nn.Sequential(nn.Linear(10,20), nn.Linear(20,30))
(3)torch.nn.Sequential(nn.Linear(10,30,20))
(4)torch.nn.Sequential(nn.Linear(10,20,30))

ANSWER:-(2)torch.nn.Sequential(nn.Linear(10,20), nn.Linear(20,30))

19.

Pre-trained models in PyTorch can be downloaded from which of the following modules?

Answer»

Pre-trained MODELS in PYTORCH can be DOWNLOADED from which of the following modules?
Please choose the correct option from below list
(1)torchvision.networks
(2)torchvision.models
(3)torch.models
(4)torch.nn.models

Answer:-(2)torchvision.models

20.

The network defined using nn.Module() must have a method named forward().

Answer»

The network defined using nn.Module() must have a method named forward().
PLEASE CHOOSE the correct OPTION from below list
(1)FALSE
(2)True

Answer:-(2)True

21.

Which of the following is used to convert NumPy array to Tensor?

Answer»

Which of the following is used to CONVERT NUMPY array to Tensor?
Please choose the CORRECT OPTION from below list
(1).to_numpy()
(2).from_numpy()
(3).numpy()
(4).get_numpy()

ANSWER:-(3).numpy()

22.

Which of the following constructor is used as an FC layer to the network?

Answer»

Which of the following CONSTRUCTOR is used as an FC layer to the NETWORK?
PLEASE choose the correct option from below list
(1)nn.sequential()
(2)nn.Linear()
(3)nn.Layer()
(4)nn.FC()

Answer:-(2)nn.Linear()

23.

Which of the following functions is used to move the Tensors from CPU to GPU?

Answer»

Which of the FOLLOWING functions is used to move the Tensors from CPU to GPU?
PLEASE choose the correct OPTION from below list
(1).to_gpu()
(2).gpu()
(3).CUDA()
(4).to_cuda()

Answer:-(3).cuda()

24.

Which of the following functions is used to initialize Tensors in PyTorch randomly?

Answer»

Which of the following functions is used to initialize Tensors in PyTorch RANDOMLY?
PLEASE choose the correct option from below LIST
(1)torch.random()
(2)torch.array()
(3)torch.randn()
(4)torch.Tensor()

ANSWER:-(3)torch.randn()

25.

Which of the following function is used to stop tracking gradients on Tensor?

Answer»

Which of the following function is used to STOP tracking gradients on Tensor?
Please choose the correct option from below LIST
(1)torch.nn.grad(False)
(2)torch.grad(FLASE)
(3)torch.nn.no_grad()
(4)torch.no_grad()

Answer:-(4)torch.no_grad()

26.

Computing softmax activation can be skipped when using nn.CrossEntropyLoss.

Answer»

Computing softmax activation can be SKIPPED when USING nn.CrossEntropyLoss.
Please choose the CORRECT option from below list
(1)True
(2)False

Answer:-(1)True

27.

Which of the following functions is used to reshape the Tensors in PyTorch?

Answer»

Which of the following functions is used to RESHAPE the Tensors in PyTorch?
Please CHOOSE the correct option from below LIST
(1)torch.view()
(2)torch.shape()
(3)torch.resize()
(4)torch.view_()

ANSWER:-(1)torch.view()

28.

The model.eval() is used to _________.

Answer»

The model.eval() is used to _________.
Please CHOOSE the correct option from below list
(1)None of the options
(2)PREDICT the ouputs
(3)evalute model performance
(4)skip applying DROPOUT while testing the model

Answer:-(4)skip applying dropout while testing the model

29.

Which of the following function is used to move the Tensors from CPU to GPU?

Answer»

Which of the following function is USED to MOVE the Tensors from CPU to GPU?
Please choose the correct option from below list
(1).to_cuda()
(2).gpu()
(3).to_gpu()
(4).cuda()

Answer:-(4).cuda()

30.

While operating on Tensors a function name followed by underscore means ___________.

Answer»

While operating on Tensors a function name followed by underscore means ___________.
Please CHOOSE the correct option from below LIST
(1)print the Tensors
(2)To create a new copy of Tensor
(3)Tensors are manipulated in place
(4)OPERATIONS are not in place

Answer:-(3)Tensors are manipulated in place

31.

On max pooling image of shape 20 x 20 using filter 4 x 4 and stride = 2, what will be the shape of the output?

Answer»

On max pooling image of shape 20 X 20 using FILTER 4 x 4 and stride = 2, what will be the shape of the output?
Please choose the correct option from below LIST
(1)19 x 19
(2)12 x 12
(3)9 x 9
(4)7 x 7

Answer:-(3)9 x 9

32.

Which of the following constructor is used to define the layers sequentially?

Answer»

Which of the following constructor is used to define the layers sequentially?
PLEASE choose the correct OPTION from below list
(1)torch.Sequential()
(2)torch.nn.Model
(3)torch.nn.Sequential()
(4)torch.nn.Network

Answer:-(3)torch.nn.Sequential()