Really interesting, I have been confused about the einsum function before. As a former physicist, I would also like to see the actual tensor notation for the examples. So instead of ij,jk something like $A_i^j B_j^k$ (imagine the math here instead of the LaTeX).
Einsum in Depth
11–20 of 33 posts
Re: Einsum in Depth
#12I was pretty confused by this for a while. I think the context I was missing is that this is about a function in nympy called ‘einsum’ which is somewhat related to Einstein summation notation. To write a little more: there are two things people mean by ‘tensor’. One is a kind of geometric object that corresponds to a multilinear map between vector spaces (or modules, I suppose), and another is a array indexed by k-tu…
> an even number is equivalent to reapplying the ‘twice’ rule many times
I never heard that extension and in my opinion is a bad idea. One nice property of the Einstein summation notation is that you can reorder the tensors(with their index), and the result does no change. If you allow 4x repetitions this is not valid).
---
Also, a nice property of tensors written in paper is that you can write the index as subscripsts or superscripts to remember how they change when there is a base change. You can only colapse a subscripst with a superscript, so the result of the operation does not depend on the choice of the base. (It would be very nice that Python can remember and check this too to avoid silly error.)
Re: Einsum in Depth
#13Really interesting, I have been confused about the einsum function before. As a former physicist, I would also like to see the actual tensor notation for the examples. So instead of ij,jk something like $A_i^j B_j^k$ (imagine the math here instead of the LaTeX).
Re: Einsum in Depth
#14Re: Einsum in Depth
#15For anyone who does a lot of einsum I highly recommend the einx package because the stock single-letter syntax very quickly becomes hard to read.
Re: Einsum in Depth
#16I was pretty confused by this for a while. I think the context I was missing is that this is about a function in nympy called ‘einsum’ which is somewhat related to Einstein summation notation. To write a little more: there are two things people mean by ‘tensor’. One is a kind of geometric object that corresponds to a multilinear map between vector spaces (or modules, I suppose), and another is a array indexed by k-tu…
I mostly agree. > an even number is equivalent to reapplying the ‘twice’ rule many times I never heard that extension and in my opinion is a bad idea. One nice property of the Einstein summation notation is that you can reorder the tensors(with their index), and the result does no change. If you allow 4x repetitions this is not valid). --- Also, a nice property of tensors written in paper is that you can write the in…
Re: Einsum in Depth
#17I've found that thinking of tensors in terms of graphs make Einsums much more natural. For example, a matrix product MN, `a b, b c -> a c` is just two nodes with two edges each: `-a- M -b- N -c-`. Their `b` edges are connected, so the resulting graph has only two "free" edges `a` and `c`. That's how we know the result is another matrix. Once you look at tensors this way, a number of things that are normally tricky wi…
Re: Einsum in Depth
#18I've found that thinking of tensors in terms of graphs make Einsums much more natural. For example, a matrix product MN, `a b, b c -> a c` is just two nodes with two edges each: `-a- M -b- N -c-`. Their `b` edges are connected, so the resulting graph has only two "free" edges `a` and `c`. That's how we know the result is another matrix. Once you look at tensors this way, a number of things that are normally tricky wi…
A few years ago I wrote a note (never published) on how many products can be seen in this way https://arxiv.org/abs/1903.01366
Re: Einsum in Depth
#19I've found that thinking of tensors in terms of graphs make Einsums much more natural. For example, a matrix product MN, `a b, b c -> a c` is just two nodes with two edges each: `-a- M -b- N -c-`. Their `b` edges are connected, so the resulting graph has only two "free" edges `a` and `c`. That's how we know the result is another matrix. Once you look at tensors this way, a number of things that are normally tricky wi…
Re: Einsum in Depth
#20I've found that thinking of tensors in terms of graphs make Einsums much more natural. For example, a matrix product MN, `a b, b c -> a c` is just two nodes with two edges each: `-a- M -b- N -c-`. Their `b` edges are connected, so the resulting graph has only two "free" edges `a` and `c`. That's how we know the result is another matrix. Once you look at tensors this way, a number of things that are normally tricky wi…