Recall & Review
beginner
What does
torch.tensor() do in PyTorch?It creates a tensor from a Python list or array with the exact values you provide.
Click to reveal answer
beginner
How do
torch.zeros() and torch.ones() differ?torch.zeros() creates a tensor filled with zeros, while torch.ones() creates a tensor filled with ones.Click to reveal answer
beginner
What kind of values does
torch.rand() generate?It generates a tensor with random values between 0 and 1, following a uniform distribution.
Click to reveal answer
beginner
Why is tensor creation important in machine learning?
Tensors hold data like images or numbers that models learn from. Creating tensors correctly helps models train and predict well.
Click to reveal answer
beginner
How do you specify the shape of a tensor when using
torch.zeros()?You pass the shape as separate arguments or as a tuple, like
torch.zeros(2, 3) or torch.zeros((2, 3)) to create a 2 by 3 tensor filled with zeros.Click to reveal answer
Which function creates a tensor with all elements set to one?
✗ Incorrect
torch.ones() creates a tensor filled with ones.What does
torch.rand((3,2)) produce?✗ Incorrect
torch.rand() creates a tensor with random values between 0 and 1.How do you create a tensor from a Python list [1, 2, 3]?
✗ Incorrect
torch.tensor() creates a tensor from the exact values in the list.Which function would you use to create a tensor filled with zeros of shape (4, 5)?
✗ Incorrect
torch.zeros() creates a tensor filled with zeros of the given shape.What is the range of values generated by
torch.rand()?✗ Incorrect
torch.rand() generates random values uniformly between 0 and 1.Explain how to create a tensor filled with ones of shape (3, 4) using PyTorch.
Think about the function that fills with ones and how to specify size.
You got /4 concepts.
Describe the difference between
torch.tensor() and torch.rand().One uses your data, the other creates random numbers.
You got /4 concepts.