News for hackers. Stuff that matters.
Re:Why tensors? A beginner's perspective by contravariant on Thursday March 10, 2022 @02:33PM (#30631362)
Mathematicians would disagree with you there. There are no coordinates to transform in an ordinary tensor space and therefore no way for a tensor to be affected by such a transformation.

Matrices (or linear transformations in general) are important examples of tensors. There's a nice adjunction between tensor spaces A(x)B and the space of linear transformations B=>C given by:

Hom(A(x)B, C) = Hom(A, B=>C)

In the case of Tensorflow I think they do actually still talk about linear transformations of some kind so it's perfectly fine to call them tensors.

Re:Why tensors? A beginner's perspective by tagrun on Thursday March 10, 2022 @06:54PM (#30634286)
Which mathematician disagrees with what exactly?

Tensors are introduced by physicists to ensure various physical quantities (which involve coordinates and their derivatives) do not depend on the arbitrarily chosen coordinate system. This is ensured through the transformation properties of tensors.

The name tensor itself comes from the theory of elasticity, Cauchy stress tensor, which BTW is uniform in many practical cases, and obeys the following tensor transformation rule:

https://en.wikipedia.org/wiki/Cauchy_stress_tensor#Transform...

like any other (contravariant) tensor must.

Matrices are not examples of tensors. Matrices can be used for representation of tensors, in which case tensor product becomes Kronecker product, but matrices in general don't have to represent tensors. You can put anything, including your favorite colors or a list of random numbers, in a matrix, and it won't be a tensor in general, not unless it must transform like a tensor under coordinate system changes.

Similarly, TensorFlow "tensor" is just a multidimensional data array, with no transformation rules enforced on it, and therefore is not a tensor.

Re:Why tensors? A beginner's perspective by clairity on Thursday March 10, 2022 @10:50PM (#30635935)
i did a whole phd-level course (a long time ago) in deformable materials, which was entirely based on tensors, and i still don’t know how to differentiate one from vectors/matrices. even the idea that tensors must obey coordinate transforms doesn’t really do it, since the practical applications of vectors/matrices do so as well.

it’s like some people invented a new word and won’t tell you what it actually means in sufficient detail to differentiate it from all the other words you know. so you keep using it with others in the hopes that contextual information will finally make it clear. one day.

Re:Why tensors? A beginner's perspective by abdullahkhalids on Friday March 11, 2022 @03:34AM (#30637665)
I just taught a module on Tensors in one of my physics courses. The mistake lots of people make is not show examples of matrices that are not tensors. But this is really difficult to do in physics courses because all physics matrix-like-objects must be tensors. Any theory that has non-tensor like objects in it will necessarily fail as soon as you change your coordinate system.

Thankfully, there is a great historical example of this. The electric field vector \vec{E} = (E_x, E_y, E_z), is not a tensor. It doesn't obey the tensor-transformation law. Similarly, the magnetic field vector is not a tensor. These are matrices, but not tensors.

As you know the Electromagnetic tensor [1] is the tensor that correctly transforms under coordinate transformation, and hence allows different observers to agree with each other.

[1] https://en.wikipedia.org/wiki/Electromagnetic_tensor

Re:Why tensors? A beginner's perspective by clairity on Friday March 11, 2022 @01:10PM (#30643689)
thanks for the examples. i vaguely recognize the term 'electromagnetic tensor', but i have to admit i didn't know that it was special in that way. i can barely spell 'tensor' at this point.

ps - one thing that always annoyed me was the limitation of linearity in so many of these models (which i totally understand why, but still). all the interesting real-world stuff happens non-linearly...

Re:Why tensors? A beginner's perspective by abdullahkhalids on Friday March 11, 2022 @03:12PM (#30645408)
Indeed it is annoying. But the models are linear not because physicists mistakenly believe that the world is linear, but because in most cases linear models are the only ones that one can solve to get qualitative predictions out. Non-linear models can be constructed as well, and then numerically solved on computers to get exact answers. But a physicist is one who understand the essential qualitative features of the world, rather than one who can compute understanding-free numerical answers.

In the words of Dirac, "I consider that I understand an equation when I can predict the properties of its solutions, without actually solving it." This usually only works if your equations are linear.

Re:Why tensors? A beginner's perspective by clairity on Friday March 11, 2022 @03:34PM (#30645653)
yah, as an engineer[0], i totally get the solvability angle, and even the physicist's core desire to be able to test (and predict via) the math rather than the physical manifestations (which may be impossible to test directly), but i'm eager to see us advance deeper into the non-linear, since that's where it gets really interesting. like, how do proteins really work? or multi-body energy fields? we're in the infancy of really understanding all this stuff. the future is stochastic and non-linear. in a thousand years, people might look back with amusement on how ignorant we were with our puny little linear models and deterministic computers. =)

[0]: but at this point, not really. even in grad school, i only did linear modeling, and relatively rudimentary ones, at that.

Re:Why tensors? A beginner's perspective by vcxy on Thursday March 10, 2022 @07:28PM (#30634584)
Interesting, you use the word matrix differently than me. The way I use it, a 2d array isn't necessarily a matrix. It's only a matrix if it represents a linear map between vector spaces with respect to chosen bases. Then again, I'm not much of a programmer, but I've taught linear algebra a few times. My head is just in a different place I guess.
Re:Why tensors? A beginner's perspective by tagrun on Thursday March 10, 2022 @07:43PM (#30634731)
Any 2D array of data is a valid matrix.

But not any multidimensional data is a valid tensor.

Re:Why tensors? A beginner's perspective by vcxy on Thursday March 10, 2022 @07:46PM (#30634758)
I'm not sure I buy this after you just used an example of a 2d array of you're favorite colors just a few minutes ago. Maybe I'm missing something. What kind of linear transformation does that represent, and between what vector spaces?
Re:Why tensors? A beginner's perspective by xyzzyz on Thursday March 10, 2022 @07:53PM (#30634803)
(the exchange between you two is a perfect example of the disconnect between how mathematicians see linear algebra, and how physicists do)
Re:Why tensors? A beginner's perspective by vcxy on Thursday March 10, 2022 @08:18PM (#30634997)
Haha, maybe so. I'm a mathematician, but based on some other comments I seem to be playing the role of physicist I think? Not sure.
Re:Why tensors? A beginner's perspective by tagrun on Thursday March 10, 2022 @07:54PM (#30634816)
My favorite colors are 1, 2, 3 and 4 in some 8-bit grayscale color space. Here's a matrix

  [ 1 2 ]
  [ 3 4 ]
This represents some linear transformation, and is a matrix. Are you trying to argue otherwise?

FYI, matrices transform between vectors within a vector space.

Re:Why tensors? A beginner's perspective by vcxy on Thursday March 10, 2022 @08:16PM (#30634983)
You have a list of labels you've conveniently decided to conflate with numbers. It's fine to use an enum for your data, but no, this data structure is not meant to convey a transformation.

You bring up a good point though, if this were meant to be a transformation, then we're talking about modules (Z/2^8Z being the underlying ring) and not vector spaces, which is fine. I was needlessly narrow when I said "vector spaces" earlier.

Re:Why tensors? A beginner's perspective by tagrun on Thursday March 10, 2022 @10:10PM (#30635661)
You can have matrices of anything including rings, quaternions, octonions, dual numbers, matrices, vectors, bras, kets, etc etc, as long as you can multiply and add those objects. If you prefer real numbers, use the corresponding wavelength of the light, or voltage values in a photosensor, it doesn't matter. It still is a matrix.

Why do you mention things like data structures, enums and labels? This is math, not C++.

Anyway, the point is, any arbitrary 2D arrangement of numbers can be a valid matrix, whatever those numbers may represent.

Re:Why tensors? A beginner's perspective by vcxy on Thursday March 10, 2022 @11:07PM (#30636043)
Sure, I can get rid of the word enum. The symbols in the example are numerals for sure, but you explicitly say they're representing colors. I don't know how to multiply colors. What I'm saying is you merely have labels there, the numbers those numerals usually represent have nothing to do with the explicitly stated meaning. If I saw that array without context, yeah sure, I'd assume it's a matrix. But there is context that tells me interpreting this as a transformation makes no sense.

I'm genuinely claiming they aren't numbers due to the explicit context. The entries are colors with numerals as labels.

Now, you've said something slightly different where I think we can agree. If the entries are from a set closed under a notion of multiplication and addition, then it represents a matrix even if it isn't being used in that way. But I still say that if you're merely using the array as a place to keep some data then I won't be using the word matrix, I'll just call it an array.

Anyway. I started this by saying it was interesting that we use the word matrix slightly differently. I still think that's interesting and think it's totally fine if you want to call an array a matrix even if the entries don't come from something where a transformation makes sense. I wouldn't "correct" someone's usage. I just think it's interesting how we use it different. Anyway, I feel like you just think I'm dumb, so I'm ending this here. You might not, but it's hard to read the vibe via text. If you have something to add you think will get me to change my word choices, feel free to respond and I'll read it, but I'm not replying on this thread anymore.

Re:Why tensors? A beginner's perspective by twangist on Friday March 11, 2022 @01:38AM (#30637006)
> FYI, matrices transform between vectors within a vector space.

Square ones do, but m x n ones represent linear maps from an n-dimensional to m-dimensional vector space (over the/a field containing the elements of the matrix).

Re:Why tensors? A beginner's perspective by cygx on Thursday March 10, 2022 @03:52PM (#30632276)
There are no coordinates to transform in an ordinary tensor space and therefore no way for a tensor to be affected by such a transformation.

Sure there are: Any basis of the underlying vector space(s) induces a basis of the tensor space. Components respective to some basis are coordinates. You can then investigate what happens to the induced basis (or rather, the respective components) under a basis transformation of the underlying vector space(s), which is where the "physicist's" definition of tensors originates.

Re:Why tensors? A beginner's perspective by contravariant on Thursday March 10, 2022 @04:10PM (#30632484)
The components of a vector aren't the same as the coordinates physicists talk about when they're dealing with tensors. The components would be something like the value of the magnetic potential, or the local wind speed. The coordinates would be the location where that particular vector is 'anchored'.

A change of coordinates does indeed induce a change of basis, but a change of basis isn't really a change of coordinates. And strictly speaking some vector spaces don't really have an obvious basis (without invoking choice), so having a basis be a prerequisite for the definition is not ideal.

The whole requirement that a tensor is 'something that transforms like [...] under a coordinate transformation' is just how physicists have chosen to phrase that a vector bundle is only well defined if it's definition isn't dependent on some arbitrary choice of coordinates. In my opinion this requirement is more easily apparent in the mathematical definition where there is no choice of coordinates in the first place, rather than the physicists way of working with some choice of coordinates and checking how things transform.

Re:Why tensors? A beginner's perspective by cygx on Thursday March 10, 2022 @04:18PM (#30632588)
I'm aware. Though if we want to be more precise, that's about tensor fields, where the basis transformations of the underlying vector bundles (the tangent and cotangent bundle) are in turn induced by coordinate transformations of the base manifold.

However, physicists get introduced to tensors far earlier than any excursions into differential geometry when discussing rigid bodies.

Re:Why tensors? A beginner's perspective by contravariant on Thursday March 10, 2022 @04:29PM (#30632738)
Yes I'd also call those tensor fields. The main point I'm trying to make is that the tensor transformation law only makes sense for such fields.
Re:Why tensors? A beginner's perspective by cygx on Thursday March 10, 2022 @04:39PM (#30632840)
The terms co- and contravariant make sense on a purely algebraic basis, with components of tensors transforming 'the same as' or 'opposite to' the basis vectors. That the basis transformation is induced by transformations of some base manifold is incidental.
Re:Why tensors? A beginner's perspective by ummonk on Thursday March 10, 2022 @05:00PM (#30633048)
Exactly. The fact that the bases are related to coordinates on the manifold is a property of differential geometry but the laws for transformation between bases are more general.