Back to course
Next page
Interactive Quiz
Test your knowledge!
1
What are the necessary conditions for two tensors to be broadcastable in PyTorch?
A
Each tensor must have at least one dimension, and for each dimension starting from the end, the sizes must be equal or one must be 1 or the dimension must not exist.
B
Both tensors must have exactly the same number of dimensions and all sizes must be equal.
C
At least one of the tensors must be a scalar; otherwise, broadcasting is not possible.
D
Both tensors must have the same total number of elements.
2
What is the first step applied by PyTorch during an arithmetic operation between two tensors of different dimensions to perform broadcasting?
A
Add dimensions of size 1 at the beginning of the tensor with fewer dimensions until both tensors have the same number of dimensions.
B
Transpose the tensor with fewer dimensions.
C
Duplicate the elements of the smaller tensor so that it has the same size as the other.
D
Flatten both tensors into vectors before the operation.
3
In PyTorch, what is the purpose of the unsqueeze() method in broadcasting?
A
To add a dimension of size 1 to a tensor at a given position, allowing manual shape modification for broadcasting.
B
To remove all dimensions of size 1 from a tensor.
C
To duplicate a tensor so that it matches the size of another tensor.
D
To reverse the order of the dimensions of a tensor.
4
What does the argument keepdim=True do in reduction functions like torch.sum or torch.mean?
A
It preserves the dimension on which the operation is performed with a size equal to 1 instead of removing it.
B
It removes all dimensions of size 1 after the operation.
C
It changes the value of elements by replacing them with the mean.
D
It reverses the order of the tensor's dimensions.
5
What is the main function of Einstein Summation notation (torch.einsum) in PyTorch?
A
To compactly and efficiently express operations involving products and sums over multiple tensor dimensions, such as matrix multiplications or transpositions.
B
To convert a tensor into a list of elements.
C
To calculate only the sum of the elements of a tensor.
D
To add dimensions of size 1 at the beginning of a tensor.
Score: 0/5
Score: 0/5