Introduction to scalars, vectors and matrices
Introduction
Before we start talking about TensorFlow, let's try to understand what a Tensor is.
A tensor is basically an N-dimensional array with a uniform data type (called dtype). You can think of tensors as similar to NumPy arrays(np.array).
Note: Tensors are immutable. You can never update the content of a tensor but you can always create new ones.
Some of the basic tensors include:
- Scalars - tensors with rank-0 or no axes/dimension
- Vectors - tensors with rank-1 or 1 axis
- Matrix - tensors with rank-2 or 2 axes
And then you can have as many axes as you want.
Here's a diagram to help you visualize this:

Let's start off by creating some basic tensors.
Import the libraries
The first step is to import the tensorflow & numpy library, so go ahead and add the code snippet below in the cell and run it by pressing shift + Enter on your keyboard:
import numpy as np
import tensorflow as tf
Check the version of tensorflow using:
print(tf.__version__)
You should have some version of TensorFlow 2.x. If not you can use ! pip install tensorflow==2.4 to install.
Here's what this should look in the colab notebook:

With the tools imported for us to use, let's create some tensors!
5
