Skip to content
ml-recall

#batch-matmul

2 questions from PyTorch, NumPy

Timed test

2 questions · 2 min · score and explanations at the end

Take a test
Q 1 / 2Score 0 / 0

Question 1: Short answer

easyAI-checkedPyTorch

A and B each hold a batch of two 2×22 \times 2 matrices, with the batch dimension first:

import torch
A = torch.tensor([[[1., 0.], [2., 1.]],
                  [[0., 3.], [1., 2.]]])
B = torch.tensor([[[2., 1.], [1., 4.]],
                  [[1., 0.], [2., 5.]]])
C = A @ B
print(C[0, 1, 1].item(), C[1, 1, 0].item())

The code prints followed by .

Fill in every blank (hints in the boxes). Enter moves to the next blank.