TENSORS…

  • Rank : No. of Axes = No. of dimensions (ndim) = Rank
  • Shape : How many values can be stored in an axis
  • Size : Available elements in the shape

0-D Tensors/ Scalers

Scalers or the 0-D (0 Dimension) tensors are the tensors where a single number is stored. It has no direction.

import numpy as np
a = np.array(2)
a
a.ndim
#output => 0
#size = 1

1-D Tensors/ Vectors

Vectors or the 1-D (1 Dimension) tensors are a collection of scalers. It includes list of values.

import numpy as np
b = np.array([1,2,3,4])
b
b.ndim
#output => 1
#size = 4

2-D Tensors/ Matrices

Matrices or the 2-D (2 Dimension) tensors are a collection of multiple vectors. I.E it includes collection of lists.

import numpy as np
c = np.array([[1,2,3],[4,5,6],[7,8,9]])
c
c.ndim
#output => 2
#shape = (3,3)
#size = 9

3-D Tensors/ N-D Tensors/ Cuboids

3-D (3 Dimension) tensors are a collection of matrices. It includes row number, column numbers and a depth i.e. number of matrices.

row # * column # * depth = 3 * 2 * 4shape = (3,2,4)
size = 3*2*4 = 24

4-D Tensors

Collection of cuboids/ 3-D Tensors is called 4-D Tensor. We can find 4-D tensors in the computer vision domain.

5-D Tensors

Collection of 4-D Tensors is called 5-D Tensor.

Conclusion

We just briefly learned about Tensors…

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store