DEV Community

Cover image for Tensors Explained Part 2: Why Tensors Are Useful
Rijul Rajesh
Rijul Rajesh

Posted on

Tensors Explained Part 2: Why Tensors Are Useful

In the previous article, we started with a brief introduction to tensors.

In this article, we will explore why tensors are useful.

Why Tensors Matter

Unlike normal scalars, arrays, matrices, and multi-dimensional matrices, tensors are designed to take advantage of hardware acceleration.

Tensors do not just store data in different shapes.

They are also designed to perform mathematical operations on that data efficiently and quickly.

Tensors and Hardware Acceleration

Tensors can take advantage of GPUs (Graphics Processing Units), which many of us use in our day-to-day devices.

GPUs are very good at performing many mathematical calculations in parallel, making them useful for training neural networks.

There is also specialized hardware called TPUs (Tensor Processing Units).

TPUs are specifically designed to work with tensors and help neural networks run even faster.

Automatic Differentiation

Another important use case of tensors is in backpropagation.

In neural networks, we estimate the optimal weights and biases using backpropagation.

This process requires calculating many derivatives and applying the chain rule.

Instead of manually calculating all these derivatives, tensor frameworks can handle this automatically using something called automatic differentiation.

This means that even as neural networks become more complex, tensors help manage the difficult mathematical calculations behind the scenes.

So that is it for tensors.

In the next article, we will explore another topic


AI agents write code fast. They also silently remove logic, change behavior, and introduce bugs -- without telling you. You often find out in production.

git-lrc fixes this. It hooks into git commit and reviews every diff before it lands. 60-second setup. Completely free.

Any feedback or contributors are welcome! It's online, source-available, and ready for anyone to use.

Give it a ⭐ star on Github

Top comments (0)