Language: "tensor" vs "array"

When (in which situations) would you employ the word “tensor” and when instead you would stick to “array” to describe a generic n-dimensional “matrix”, for example to describe your API ?

I’d use “tensor” only for objects representing a mathematical tensor. An “array” is an n-dimensional generalization of a matrix (i.e. an arrangement of numbers).


Agreeing with @Samuel3008. From my understanding, tensors can be represented in a particular coordinate system by an array. Tensors are more abstract though, and they follow rules that make them invariant in the choice of coordinate system (Cartesian, polar, curvilinear…).

I know the ML community has adopted the word “tensor”, although I’m not sure if the word is used in the same sense as in math and physics as it is not my field.

1 Like

There are a couple of 2 nice discussions here and here.
Before today my thought was like in one of the answers there, with array be the computer implementation of the mathematical concept of tensor, but it seems I was wrong.

Thanks everyone for the clarification.

I agree with the above responses. I would avoid the Python-ism of calling an n-dimensional array a tensor, unless it truly is an array representation of an abstract tensor. I think it’s common in Python/ML to sandwich together loosely related matrices along additional dimensions and call that a tensor, even though it most definitely is not a tensor.


Another +1 here. Just want to add that Wikipedia now has another tensor page describing the Python/ML meaning of the word. I hate when perfectly well-defined terms get co-opted and misused by a large community, because it causes great confusion and we end up needing to define new words to disambiguate. Literally makes my mind explode.


I don’t think Python has anything to do with this terminology other than much machine learning being done in Python.

For some earlier discussion about the meaning of tensor, see (parts of) Comparison of tensor packages?.

For this matter, I actually don’t like to call 1- or 2-dimensional arrays “vectors” or “matrices” unless they represent a linear-algebraic object. Practically, however, I’ll admit of often do, given that these are the sanctioned names in Julia.

It would be somewhat inconvenient from where we are now (and impossible during v1.x), but I would advocate that linear-algebraic objects be thin wrappers over arrays. It would make excising the LinearAlgebra standard library waaaaay easier, which would be a notable savings from startup.

I also have issues with the semantic conflation of arrays and vectors/matrices. We have a lot of functions that work on both but some don’t make sense for one or the other. Sorting elements of vectors/matrices makes no sense, while sorting arrays is totally fine. Arrays don’t have norms, but vectors/matrices do. There are a small number of places (I wish I could remember a few right now) where this conflation produces real conflict.

1 Like