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.

  1. Use torch.randn to create two tensors of size (29, 30, 32) and and (32, 100).
  2. Use torch.matmul to matrix multiply the two tensors.
  3. Use torch.sum on the resulting tensor, passing the optional argument of dim=1 to sum across the 1st dimension. Before you run this, can you predict the size?
  4. Create a new long tensor of size (3, 10) from the np.random.randint method.
  5. Use this new long tensor to index into the tensor from step 3.
  6. Use torch.mean to average across the last dimension in the tensor from step 5.