What’s a Tensor?
Unpacking a common data science structure
The concept of a Tensor was created in 1900 by two Italian mathematicians, Tullio Levi-Civita and Gregorio Ricci-Curbastro, and as is common, they built upon the work of other mathematicians. The Wikipedia page for “Tensor” begins:
For non-mathematicians, that’s a lot to unpack!
Fortunately, it’s a lot easier to grasp what a tensor is in a practical sense and how we manipulate them in data science.
I find it helpful to visualize a tensor as nested “lists” of numbers, with any number of “levels.” Another way of visualizing this is to imagine each cell in an Excel spreadsheet containing all the contents from another entire spreadsheet. Then, in that second spreadsheet, each cell there is also linked to another entire spreadsheet, and so on. Each spreadsheet could be thought of as an additional “dimension.”
A “first-order” tensor has just one dimension. In computer science, this would be called a “vector,” an ordered list of numbers. A “second-order” tensor would be a matrix, like an Excel spreadsheet, and have two dimensions. As the dimensions increase, we can think of…