What is a tensor?
Well, the first thing you hear when you start machine learning is people tell you to pick up a framework, TensorFlow or PyTorch. The word is sitting right there in the name, but in our learning journey, we have come so far that we have somehow forgotten the basics. So let me break it down to you in under two minutes.
Forget the scary word for a second. A tensor is just a container of numbers, and that's the entire concept.
The only question is how many dimensions does the container have? Let's build one from scratch and start with a single number five.
Just one value, that's zero dimension, a scalar.
And now put numbers in a line, that's one dimension, a vector. Now we add second row underneath it, and you have rows and columns, two dimensions. That's a matrix.
Now to find any number, you need two things: which row, which column.
Moving forward, take this whole grid and stack another behind it, three dimensions. That's a tensor.
Clear: which row, which column, three directions to count in. You can keep stacking, four dimensions, five dimensions, same number, just more directions.
And here's a trick you can use in ML classes: to know the number of dimensions, just count the brackets.
One bracket, one dimension. Two brackets, two dimension. Three brackets, three dimension. Brackets are the shape. Moving forward, did you know that you have thousands of tensors in your pocket?
Every photo in your phone is one, a grid of numbers, red, blue, and green, all stacked up. Each number is just how bright that tiny dot is. Your phone doesn't store a picture of your face, it stores neatly arranged boxes of numbers. And it's not just images.
The sentence you type into Chat GPT, the model can't read words, so your sentence gets chopped into tokens, small pieces, and each token becomes a long list of numbers called embedding. One token, one vector.
Your whole sentence, a grid of those vectors, a matrix. A batch of sentences processed together, three dimensions. Text, audio, or even model weights.
Everything in deep learning travels in tensors, and that's the secret behind frameworks named themselves after. A tensor is numbers in a container, and machine learning is just math flowing through those containers.
That's literally flow in TensorFlow.