Pytorch Mcq

Pytorch Interview Questions (MCQ): Test Your Knowledge!

 

 

Which PyTorch function computes the element-wise multiplication of tensors?
torch.mul()
torch.multiply()
torch.prod()
Both a and b
What is the primary function of torchvision in PyTorch?
To visualize tensors
To provide tools and datasets for computer vision
To optimize vision models
To create custom vision layers
What is the purpose of torch.nn.utils.parametrizations.orthogonal in PyTorch?
To create orthogonal matrices
For orthogonal parametrization of linear layers
To implement QR decomposition
To optimize matrix operations
How do you create a tensor with values drawn from a standard normal distribution?
torch.randn(size)
torch.normal(size)
torch.gaussian(size)
torch.standard_normal(size)
What does the torch.transpose() function do?
Flips a tensor along specified dimensions
Swaps two dimensions of a tensor
Rotates a tensor
Reverses the order of elements in a tensor
How can data shuffling be implemented in PyTorch's DataLoader?
By setting shuffle=True
By using torch.shuffle()
By implementing a custom Dataset
By modifying the model architecture
Which of the following is NOT a valid normalization technique in PyTorch?
InstanceNorm3d
BatchNorm2d
LayerNorm
GroupNorm
Which parameter in StepLR specifies the interval for learning rate decay?
step_size
interval
decay_step
lr_step
How does torch.sparse work in PyTorch?
It manages memory sparsely
For operations on sparse tensors
To implement sparse neural networks
To optimize storage for sparse data
What is the main advantage of PyTorch's dynamic computational graphs?
They allow for more flexible and intuitive model building
They are faster than static graphs
They use less memory
They are easier to deploy
Which PyTorch function applies instance normalization?
nn.InstanceNorm1d()
nn.InstanceNorm2d()
nn.InstanceNorm3d()
All of the above
How do you create a tensor with a specific data type?
torch.tensor([1, 2, 3], dtype=torch.float32)
torch.create([1, 2, 3], type=torch.float32)
torch.array([1, 2, 3], dtype=torch.float32)
torch.new([1, 2, 3], dtype=torch.float32)
What is transfer learning in PyTorch?
Transferring data between GPUs
Using pre-trained models for new tasks
Transferring gradients between layers
Moving tensors between devices
What is the primary function of torch.nn.ReLU in PyTorch?
To normalize inputs
To apply rectified linear activation
To compute loss
To optimize weights
What does the requires_grad attribute of a PyTorch tensor control?
Whether to compute gradients for the tensor
Whether the tensor can be modified
Whether the tensor can be moved to GPU
Whether the tensor can be saved to disk
How can you implement custom DataLoader in PyTorch?
By subclassing torch.utils.data.DataLoader
Using the @dataloader decorator
Modifying the iter() method of Dataset
PyTorch doesn't support custom DataLoaders
What is the main advantage of the Adam optimizer?
It's the fastest
It adapts the learning rate for each parameter
It doesn't require hyperparameter tuning
It's immune to vanishing gradients
What is the main purpose of the torch.clamp() function in PyTorch?
To compute gradients
To clip tensor values to a range
To normalize tensor values
To reshape tensors
Which PyTorch method is used to compute gradients during backpropagation?
backward()
backprop()
gradient()
differentiate()
How do you create a tensor with evenly spaced values on a log scale?
torch.logspace(start, end, steps)
torch.log_range(start, end, steps)
torch.logarithmic_space(start, end, steps)
torch.log_linspace(start, end, steps)
Score: 0/20