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.randnto create two tensors of size (29, 30, 32) and and (32, 100). - Use
torch.matmulto matrix multiply the two tensors. - Use
torch.sumon the resulting tensor, passing the optional argument ofdim=1to 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.randintmethod. - Use this new long tensor to index into the tensor from step 3.
- Use
torch.meanto average across the last dimension in the tensor from step 5.