News for hackers. Stuff that matters.
Re:Einsum Is All You Need – Einstein Summation in Deep Learn... by joppy on Saturday February 02, 2019 @09:29PM (#19067423)
I've never really understood the point of Einstein notation, as a piece of mathematical notation. Is writing something like A[i, j] * B[j, k] really that much faster than writing something like Sum[j](A[i, j] * B[j, k])? Especially when you have to check the left hand side of the equality sign just to know which indices to sum over, it seems like making things less clear for a minuscule saving on ink.
Re:Einsum Is All You Need – Einstein Summation in Deep Learn... by ssivark on Saturday February 02, 2019 @10:44PM (#19067708)
It's not just about the sum. The upper and lower indices are semantically crucial. Eg: vectors have upper indices and gradients have lower indices. It's nonsensical to add the two, so the core step in gradient descent doesn't make sense. To add the two, you need the metric (Hessian) to raise the index of the gradient. And just like that, voila, you've discovered natural gradients!
Re:Einsum Is All You Need – Einstein Summation in Deep Learn... by mmmmpancakes on Sunday February 03, 2019 @06:43PM (#19072943)
Gradients are vectors. You can certainly add them to other vectors.

I think what you mean to say is that you can not add vectors and covectors. The differential of a function is a 1-form. Pointwise, it is a covector. This data is the natural starting point from which to compute gradients.

Metrics can be used to convert covectors into vectors and forms into vector fields. The result is the thing you call the natural gradient. If you do this with the standard metric on R^n, then you get the vector field which you call the gradient.

Re:Einsum Is All You Need – Einstein Summation in Deep Learn... by mhh__ on Saturday February 02, 2019 @10:26PM (#19067641)
Absolutely yes.

Doing tensor magic without einstein notation will make you shoot yourself, and even you don't someone else will if publish it.

The only real problem I have with it personally is the abstraction of upper and lower indices, which I constantly forget the conventions as to which is which.

Re:Einsum Is All You Need – Einstein Summation in Deep Learn... by krastanov on Sunday February 03, 2019 @02:12AM (#19068254)
This is interesting... I love the notation, but mainly because how upper and lower indices make it easy to distinguish vectors and forms (not that it matters in ML where everything is "euclidean").
Re:Einsum Is All You Need – Einstein Summation in Deep Learn... by joppy on Sunday February 03, 2019 @04:01AM (#19068518)
Upper and lower indices are great, but are still unrelated to the convention of dropping the big sigma at the front.
Re:Einsum Is All You Need – Einstein Summation in Deep Learn... by antidesitter on Sunday February 03, 2019 @11:18AM (#19070402)
> not that it matters in ML where everything is "euclidean"

Non-euclidean spaces are actually quite common in ML, but many people don’t realize the spaces they’re working in are non-euclidean!

Re:Einsum Is All You Need – Einstein Summation in Deep Learn... by improbable22 on Sunday February 03, 2019 @02:02PM (#19071456)
Would be curious to hear what you have in mind here -- could you expand?
Re:Einsum Is All You Need – Einstein Summation in Deep Learn... by g82918 on Tuesday February 05, 2019 @10:09PM (#19092367)
Co -> low, primes below.
Re:Einsum Is All You Need – Einstein Summation in Deep Learn... by lenticular on Saturday February 02, 2019 @10:12PM (#19067575)
It's more succinct, and the thing is that in most physics, repeated indices really almost always are sums. When you're doing fluid mechanics or anything like that, it's tensors all the time. The terseness is nice once you get used to it.
Re:Einsum Is All You Need – Einstein Summation in Deep Learn... by ajkjk on Saturday February 02, 2019 @09:39PM (#19067460)
Yes, it's incredibly faster. You do a lot of tensor algebra in a relativity class.
Re:Einsum Is All You Need – Einstein Summation in Deep Learn... by joppy on Saturday February 02, 2019 @09:56PM (#19067528)
To the point where writing one large sigma and listing indices under it at the start of each line would significantly slow you down? I found I had to do this mentally during my own relativity class, just to figure out what each expression meant.
Re:Einsum Is All You Need – Einstein Summation in Deep Learn... by frutiger on Sunday February 03, 2019 @12:20AM (#19068021)
> To the point where writing one large sigma and listing indices under it at the start of each line would significantly slow you down?

Yes (in my relativity & QFT classes). But the timesaving aspect was not that important for me. The notation enabled the intuition of “zipping” together these somewhat unwieldy mathematical objects, and that was the clincher.

Re:Einsum Is All You Need – Einstein Summation in Deep Learn... by pishpash on Sunday February 03, 2019 @03:41AM (#19068476)
Then you're doing it wrong. The point of notation (or learning any new language) is to operate in that language, not to translate back and forth.
Re:Einsum Is All You Need – Einstein Summation in Deep Learn... by joppy on Sunday February 03, 2019 @04:54AM (#19068689)
It's not actually a new notation though, it's literally just deleting a part of the old notation and then getting the reader to fill that part back in. While this is fine for calculations, I would rather that when equations are actually presented, that one extra piece of information is explicitly given.

I guess a similar thing that happens on the programming language side would be leaving out types when the compiler can infer them. This is great, and can make code more concise, but when reading an API I would really like the types written down explicitly, rather than having the play the part of the compiler.

Re:Einsum Is All You Need – Einstein Summation in Deep Learn... by ajkjk on Sunday February 03, 2019 @08:31AM (#19069463)
If types are omitted then there's actual missing information from the equation. If summations are omitted, there... isn't. They add nothing (at least in relativity where every sum is over the same 4 values).

Anyway, index notation is more of a shorthand for symbolic tensor algebra computations than actual sums. The problem is that when dealing with 2, 3, and 4 index tensors, with co- and contra-variant indexes, it's quite cumbersome to notate which component of a tensor contracts with which component of another tensor, and anything you could come up with would end up looking like index notation. Rarely do you actually mean to sum anything.

Re:Einsum Is All You Need – Einstein Summation in Deep Learn... by joppy on Monday February 04, 2019 @07:25PM (#19082019)
I don't have a problem with using indices for anything, they are fine. Distinguishing upper and lower indices is even better. The exact complaint I have is the implicit sums. For example, a matrix A would be written with one upper and one lower index, which I'll just write as A[i, j]. In einstein (implicit sum) notation, the trace of the matrix is written Tr A = A[i, i]. Is this really better than saying Tr A = Sum[i] A[i, i]?
Re:Einsum Is All You Need – Einstein Summation in Deep Learn... by mcabbott on Sunday February 03, 2019 @05:10AM (#19068750)
If you have just one term, then leaving out the summation sign saves little. But in larger expressions, the rule applies sums per term, and then the savings in clutter can be quite large. For example, here v_i is not summed, and the term with z_b has two sums:

A_ia x_a + v_i + x_a y_a ( w_i + B_ib z_b )

You should not need to check the LHS, x_a y_a should always mean the dot product of these two. At least this is the convention among the heavy addicts; among lighter users you will sometimes find other setups.

Re:Einsum Is All You Need – Einstein Summation in Deep Learn... by joppy on Monday February 04, 2019 @07:29PM (#19082041)
I still feel that the whole expression could be clarified quite easily be writing a \Sum_{a, b} at the front?
Re:Einsum Is All You Need – Einstein Summation in Deep Learn... by mcabbott on Tuesday February 05, 2019 @04:12AM (#19083897)
But that would sum everything, not just the parts which need it. You'd actually have to write this:

\sum_a(A_ia x_a) + v_i + \sum_a(x_a y_a) ( w_i + \sum_b(B_ib z_b) )

My example is actually still easier without indices. (Although you lose some information, like the fact that x & y are vectors in the indexed by a,b.) Here it's clear that Ax and x⋅y each involve a sum, which never includes v:

Ax + v + (x⋅y)(w + Bz)

Re:Einsum Is All You Need – Einstein Summation in Deep Learn... by feanaro on Sunday February 03, 2019 @07:28AM (#19069249)
As an analogy, why do you write A⋅B instead of Sum[i](A[i] * B[i])?
Re:Einsum Is All You Need – Einstein Summation in Deep Learn... by joppy on Monday February 04, 2019 @07:32PM (#19082057)
This is a bit of a red herring - why would people using Einstein notation write A[i] B[i] instead of writing A⋅B?
Re:Einsum Is All You Need – Einstein Summation in Deep Learn... by feanaro on Tuesday February 05, 2019 @02:46AM (#19083627)
They wouldn't. My point was that A⋅B is also hiding a sum across all indices, just like Einstein notation. The sum never changes and is therefore visual/cognitive noise, once you've understood it the first time. The dot product is an abstraction that hides it and makes it implied.