# Is the rank of a Tensor different from the rank of a Matrix?

As far as I know, the rank of a matrix is the dimension of the vector space generated by columns.

In NumPy notation, x = np.array([[1, 2], [2, 4]]) has a rank of one.

np.linalg.matrix_rank(x) confirms that it is one.

While studying the TensorFlow page shown below, https://www.tensorflow.org/get_started/get_started I saw the following remarks:

A tensor's rank is its number of dimensions. Here are some examples of tensors:

3 # a rank 0 tensor; this is a scalar with shape []
[1. ,2., 3.] # a rank 1 tensor; this is a vector with shape 
[[1., 2., 3.], [4., 5., 6.]] # a rank 2 tensor; a matrix with shape [2, 3]
[[[1., 2., 3.]], [[7., 8., 9.]]] # a rank 3 tensor with shape [2, 1, 3]


I'm totally confused.

Q1. What is the relationship between the rank of a Matrix and the rank of a Tensor? Is it a completely different thing?

Q2. In the case of the above matrix x = np.array([[1, 2], [2, 4]]), is the rank two if we assume that it is a tensor not a matrix?

Thank you!

• Often in math the same word is used to mean totally different things. Don't let bad naming confuse you. – littleO Apr 22 '17 at 1:13
• Briefly, any matrix is a tensor of rank 2. In general, a tensor is going to "eat" a certain number of vectors and output a real number; the number of vectors it eats is the rank of the tensor. (More generally, it can eat a certain number of vectors and spit out another number of vectors. The rank will be the sum of those numbers.) – Ted Shifrin Apr 22 '17 at 1:19
• @TedShifrin Does that assume the tensor is (at least) partially covariant? – Chill2Macht Dec 3 '17 at 22:36
• @Chill2Macht: Well, I was being slightly sloppy. Of course, I should have stated that it "eats" a certain number of vectors and a number of covectors. I was trying to be as concrete as possible. – Ted Shifrin Dec 3 '17 at 23:04
• @TedShifrin That makes sense. I just wanted to test my understanding of the comment. – Chill2Macht Dec 3 '17 at 23:06

• A tensor of rank $1$ is a vector, which is a one-dimensional array, [a,b].
• A tensor of rank $2$ is a vector of vectors, or a matrix, or a two-dimensional array, [[a,b],[c,d]].
• A tensor of rank $3$ is a vector of vectors of vectors, so something with three nestings, [[[a,b],[c,d]],[[e,f],[g,h]]] sort of thing.
The "dimension" here is the (tensorial) rank, or the number of inputs you need to locate an entry. This is of course not the same as "dimension" in the sense that something has "dimension $n$" if is an ordered list of length $n$.