Summoning Your First Tensors¶
Module 01 lesson 1
Mwahahaha! Welcome, my brilliant acolytes. Today, we shall peel back the very fabric of reality—or, at the very least, the fabric of a PyTorch tensors
"Prepare your minds! The gradients... they are about to flow!"
Lesson objectives¶
- Understand what tensors are and why they are useful for machine learning
- Get hands-on experience on creating and selecting elements from tensors in PyTorch
- Manipulate and transform tensors to prepare them for machine learning tasks
Time to complete: 10 minutes Level: Beginner - Intermediate
What is a tensor?¶
- what is a tensor?
- how is it different from a matrix?
- are mathematical interpretations of tensors are different from their PyTorch counterparts?
- why are tensors useful for machine learning? Why we can't use matrices?
Excercises¶
Check if your PyTorch is properly setup, lets import the libraries.
In [1]:
Copied!
import torch
import torch
In [2]:
Copied!
torch.manual_seed(1)
x = torch.randn(6, 4)
print(x)
print(x.shape)
torch.manual_seed(1)
x = torch.randn(6, 4)
print(x)
print(x.shape)
tensor([[-1.5256, -0.7502, -0.6540, -1.6095], [-0.1002, -0.6092, -0.9798, -1.6091], [ 0.4391, 1.1712, 1.7674, -0.0954], [ 0.1394, -1.5785, -0.3206, -0.2993], [-0.7984, 0.3357, 0.2753, 1.7163], [-0.0561, 0.9107, -1.3924, 2.6891]]) torch.Size([6, 4])
In [ ]:
Copied!