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 [3]
[[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!

  • 1
    $\begingroup$ Often in math the same word is used to mean totally different things. Don't let bad naming confuse you. $\endgroup$ – littleO Apr 22 '17 at 1:13
  • $\begingroup$ 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.) $\endgroup$ – Ted Shifrin Apr 22 '17 at 1:19
  • $\begingroup$ @TedShifrin Does that assume the tensor is (at least) partially covariant? $\endgroup$ – Chill2Macht Dec 3 '17 at 22:36
  • 1
    $\begingroup$ @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. $\endgroup$ – Ted Shifrin Dec 3 '17 at 23:04
  • $\begingroup$ @TedShifrin That makes sense. I just wanted to test my understanding of the comment. $\endgroup$ – Chill2Macht Dec 3 '17 at 23:06

"number of dimensions" is a pretty terrible description. Looking at the website, their interpretation of "tensor" is not the same as the strict mathematical definition (which is to do with multilinear maps with certain properties).

As far as that program is concerned, a tensor is a vector of vectors of vectors of... of vectors, where the rank is the number of nestings of "of vectors", so

  • 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.
  • &c.

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$.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.