0Pricing
Deep Learning Academy · Lesson

Tensors Talk to NumPy

Convert between torch tensors and NumPy arrays.

Two Worlds, One Bridge

Lots of data starts life as a NumPy array. PyTorch makes it easy to move between arrays and tensors in both directions.

NumPy Arrays Are Like Tensors

A NumPy array also stores numbers in a shape, just without GPU support or autograd. Tensors add those superpowers.

import numpy as np
a = np.array([1, 2, 3])
print(a.shape)  # (3,)

All lessons in this course

  1. Shapes, Dtypes & Indexing
  2. Reshape, View, Squeeze & Unsqueeze
  3. Broadcasting Rules That Save You Loops
  4. Tensors Talk to NumPy
← Back to Deep Learning Academy