Skip main navigation

New offer! Get 30% off one whole year of Unlimited learning. Subscribe for just £249.99 £174.99. New subscribers only. T&Cs apply

Find out more

Practical: Tensors in PyTorch

A link to a short colab notebook demonstrating tensors in PyTorch
A screenshot of a Colab notebook discussing tensors in PyTorch
© The University of Nottingham
Tensors are the data type used to transmit data through deep learning networks.

In the linked Colab notebook we look at:

  • how to make tensors in PyTorch
  • arithmetical operations with tensors: add, subtract, multiply, divide
  • performing other mathematical functions on tensors: e.g. exponential and trigonometric functions
  • how to make tensors of a given size and shape, including random tensors
  • how to access elements within tensors or parts of tensors using indexing and slicing
  • how to reshape tensors using flatten, squeeze and unsqueeze.

Follow the link below and work through the Colab notebook as before.

Tensors in PyTorch

You may wish to open the link in a new browser tab so you can refer back here quickly.

Please leave any questions or comments below.

This article is from the free online

Deep Learning for Bioscientists

Created by
FutureLearn - Learning For Life

Reach your personal and professional goals

Unlock access to hundreds of expert online courses and degrees from top universities and educators to gain accredited qualifications and professional CV-building certificates.

Join over 18 million learners to launch, switch or build upon your career, all at your own pace, across a wide range of topic areas.

Start Learning now