Warm Up Exercise¶
To get you back into the PyTorch groove, let’s do some easy exercises. You will have 10 minutes. See how far you can get.
- Use
torch.randn
to create two tensors of size (29, 30, 32) and and (32, 100). - Use
torch.matmul
to matrix multiply the two tensors. - Use
torch.sum
on the resulting tensor, passing the optional argument ofdim=1
to sum across the 1st dimension. Before you run this, can you predict the size? - Create a new long tensor of size (3, 10) from the
np.random.randint
method. - Use this new long tensor to index into the tensor from step 3.
- Use
torch.mean
to average across the last dimension in the tensor from step 5.