Tensors Basics
Creating tensors and reading their shape, dtype, and device.
A PyTorch is NumPy's ndarray with two extra
superpowers: it can live on a GPU, and it can remember the operations that
built it so can flow backward through them via
(Lesson 3). If you already know NumPy, most of
this will feel familiar: the API is deliberately close.
| Call | Makes | Example |
|---|---|---|
| a tensor from existing data (list, NumPy array, …) |
|
| filled with 0s / 1s |
|
| like NumPy's |
|
| n×n identity matrix |
|
| uniform random values in [0, 1) |
|
| normal/Gaussian random values (mean 0, std 1) |
|
| dtype casts |
|
Now practice it
Exercises that use what this lesson just covered.