Understand Tensors and Matrices

Uniqtech
Data Science Bootcamp
3 min readFeb 17, 2019

--

Before machine learning and deep learning become super popular, Tensor is more of a Physics concept. In this case, tensor refers to high dimensional matrices (plural for matrix). Let’s start with a normal number, a scalar, like 1. It’s zero dimension.

For the sake of understanding deep learning, for beginners, simply put: Tensors are just high dimensional matrices. Usually it is a stack or pile of matrices that have more than just two dimensions (width and height), now has depth (and even more dimensions), each depth layer is a matrix. In contrast, each matrix has a row or column vector, each vector is consisted of scalar numbers.

Each tensor is one or more stacks of matrices. Each matrix is a stack of rows and columns vectors. Each row or column vector is a stack of numbers.

One dimensional matrix is also known as vectors. Here’s a row vector:

Here’s a column vector:

How about a two dimension tensor? That’s simply a matrix. A large matrix looks like an excel sheet. Here’s a small 2x2 matrix.

Generally tensor refers to higher dimensional matrices like the RGB value of each pixel in an image. Each pixel has an x,y coordinate (x,y) for its horizontal location and vertical location in an image. It also has three additional values: red, green, blue.

See the above image REPOST for visualization of column vector, or just vectors, matrix and tensor.

Given the above visualization technique. You can visualize an image tensor has a width, height, and the depth is usually three, one for red, one for green and one for blue.

Illustration of a Pixel and its RGB value
An illustration of a tensor that represents 3 pixels in a row of the RGB value [255,175,97] corresponding to red green blue

Simple green screen: you can create a simple green screen background by using this RGB value RGB value for green screen (0,255, 0). By definition, this means zero red, max green 255, zero blue.

Does the name tensor sound familiar? Yes, Google’s Deep Learning framework Tensorflow is named for tensors flowing through computational graphs.

Check out our four solid definitions of what’s a tensor?

What is a tensor, deep learning data structure, definition 01 [public]

https://ml.learn-to-code.co/skillView.html?skill=ACUmVX7rno3CZIUhUIr7

What is a tensor, deep learning data structure, definition 02 [public]

https://ml.learn-to-code.co/skillView.html?skill=9AC9V2Hxpy3XPZvcKD0t

What is a tensor, deep learning data structure, definition 03 [pro]

https://ml.learn-to-code.co/skillView.html?skill=ATYdKimsQpwQtcBEnm5x

Tensor definition 04 [pro paid LTC members, analogy] https://ml.learn-to-code.co/skillView.html?skill=ipaDTPgvrgrIJA16nhBq

--

--