What are Tensors?

tensor’s in the context of ML is an array with depth or a multi-dimensional array.

so an example of a tensor would be:

tensor = [
  [1, 4, 5, 8, 19],
  [1, 4, 5, 8, 19],
  [1, 4, 5, 8, 19],
]

tensors are multi-dimensional arrays of data that are used to “digitize” abstract data that you want machine learning algorithms to be able to understand or replicate.

one example would be changing an image to be in a form that a ML model can understand.

you can convert a 324x324 image to a tensor with these dimensions:

[3, 324, 324]
  • 3 dimensions, height, width
[[[
	1.345, 23.9393, 29.3343, 12.1234
	...
	...
]]]

you can imagine how the tensors are formatted, kind of like the pages of a book.


the best tip to figure out the dimensions of a tensor: count the number of brackets on the left side.