Recall & Review
beginner
What is PyTorch?
PyTorch is a popular open-source library for machine learning that helps you work with tensors and build neural networks easily.
Click to reveal answer
beginner
What is a tensor in PyTorch?
A tensor is a multi-dimensional array, like a list of numbers, that PyTorch uses to store data for computations.
Click to reveal answer
beginner
How do you create a tensor with PyTorch?
You can create a tensor by calling torch.tensor() and passing a list of numbers, for example: torch.tensor([1, 2, 3]).
Click to reveal answer
beginner
What does the following PyTorch code do?
<pre>import torch
a = torch.tensor([2, 3])
b = torch.tensor([4, 5])
c = a + b</pre>This code creates two tensors a and b, then adds them element-wise to get tensor c with values [6, 8].
Click to reveal answer
beginner
Why is PyTorch useful for machine learning?
PyTorch makes it easy to do math with tensors and build models that learn from data, using simple and clear code.
Click to reveal answer
What is the main data structure used in PyTorch for computations?
✗ Incorrect
PyTorch uses tensors as its main data structure for storing and computing data.
How do you add two tensors a and b in PyTorch?
✗ Incorrect
You can add tensors element-wise simply by using the + operator.
Which Python library do you import to use PyTorch?
✗ Incorrect
The PyTorch library is imported with the name torch.
What will torch.tensor([1, 2, 3]) create?
✗ Incorrect
torch.tensor creates a tensor containing the given list of numbers.
Which of these is NOT true about tensors?
✗ Incorrect
Tensors can store any numerical data, not just images.
Explain how to create and add two tensors in PyTorch.
Think about how you create lists and add numbers, but with tensors.
You got /3 concepts.
Describe why tensors are important in PyTorch and machine learning.
Consider how data is handled in machine learning.
You got /4 concepts.