Live data from Hacker News

The Elements of Differentiable Programming

arxiv.org

21–30 of 84 posts

Re: The Elements of Differentiable Programming

#21
post #11

Earlier quoted context omitted.

Your program takes various inputs, does processing and gives you results. To quote the book this applies to programs "including those with control flows and data structures" and are not entirely numerical in the most common sense. Broadly speaking, with AD you can modify the results and the program will spit out the required inputs to get those results.

So if a program's result is "no access", then AD can figure out how you can get access. Sounds like an important hacker tool.

Yes, these are “adversarial patches” in image classification, like https://arxiv.org/abs/1712.09665 . Similarly you can take these adversaries and add them to your own larger model, in an arms race.

Re: The Elements of Differentiable Programming

#22
One very interesting thing about automatic differentiation is that you can think of it as involving a new algebra, similar to the complex numbers, where we adjoin an extra element to the reals to form a plane. This new algebra is called the ring of "dual numbers." The difference is that instead of adding a new element "i" with i² = -1, we add one called "h" with h² = 0!

Every element in the dual numbers is of the form a + bh, and in fact the entire ring can be turned into a totally ordered ring in a very natural way: simply declare h 0. In essence, we are saying h is an infinitesimal - so small that its square is 0. So we have a non-Archimedean ring with infinitesimals - the smallest such ring extending the real numbers.

Why is this so important? Well, if you have some function f which can be extended to the dual number plane - which many can, similar to the complex plane - we have

f(x+h) = f(x) + f'(x)h

Which is little more than restating the usual definition of the derivative: f'(x) = (f(x+h) - f(x))/h

For instance, suppose we have f(x) = 2x² - 3x + 1, then

f(x+h) = 2(x+h)² - 3(x+h) + 1 = 2(x² + 2xh + h²) - 3(x+h) + 1 = (2x² - 3x + 1) + (4x - 3)h

Where the last step just involves rearranging terms and canceling out the h² = 0 term. Note that the expression for the derivative we get, (4x-3), is correct, and magically computed itself straight from the properties of the algebra.

In short, just like creating i² = -1 revolutionized algebra, setting h² = 0 revolutionizes calculus. Most autodiff packages (such as Pytorch) use something not much more advanced than this, although there are optimizations to speed it up (e.g. reverse mode diff).

Re: The Elements of Differentiable Programming

#23

One very interesting thing about automatic differentiation is that you can think of it as involving a new algebra, similar to the complex numbers, where we adjoin an extra element to the reals to form a plane. This new algebra is called the ring of "dual numbers." The difference is that instead of adding a new element "i" with i² = -1, we add one called "h" with h² = 0! Every element in the dual numbers is of the for…

Where do I go to learn what you just said?

Re: The Elements of Differentiable Programming

#24
post #19

i don't know why people write these things. it's an absolute hodge-podge of theorem/proofs/results/techniques with no unifying theme other than "CALCULUS". so it's a pretty bad math book to actually learn math from (you can always spot a pedagogically unsound math book by its lack of exercises). the book doesn't even have any code in it which is surprising considering it has "programming" in the title. actually i kno…

You’re getting hit on a bunch of different things here, but I’d like to focus on two: it's an absolute hodge-podge of theorem/proofs/results/techniques with no unifying theme other than "CALCULUS". I mean, yes…? Maybe I’m a terrible programmer but I’ve never applied calculus to my work in any real way. A book that’s just “calculus applications for software design” seems quite useful, and quite unrelated to teaching “…

> I mean, yes…? Maybe I’m a terrible programmer but I’ve never applied calculus to my work in any real way. A book that’s just “calculus applications for software design” seems quite useful, and quite unrelated to teaching “math” in a direct way.

that's not what this book is. like i said in the first sentence right there in the part right before the all caps calculus - this is book is a compendium of theorem/proofs/etc. very little actual software.

> Doesn’t this apply to all books of any kind?

again, i already covered this: a pedadogically sound textbook will have exercises and structure/themes/etc rather than just 120 "propositions".

Re: The Elements of Differentiable Programming

#25
post #8

Would this be useful for general applications, or just numerical ones?

Your program takes various inputs, does processing and gives you results. To quote the book this applies to programs "including those with control flows and data structures" and are not entirely numerical in the most common sense. Broadly speaking, with AD you can modify the results and the program will spit out the required inputs to get those results.

> Broadly speaking, with AD you can modify the results and the program will spit out the required inputs to get those results.

I assume you're trying to phrase it in a non-technical way for accessibility, but I wonder if that might have lost some precision. What you describe sounds more like (logically) reversible programming (https://en.wikipedia.org/wiki/Reversible_computing). Differentiability doesn't imply reversibility; for example, the program that takes in an input and returns 1 is as differentiable as they come, but there's nothing that differentiation, automatic or otherwise, can do to tell you an input that will make it return 2.

Re: The Elements of Differentiable Programming

#26
post #25

Earlier quoted context omitted.

Your program takes various inputs, does processing and gives you results. To quote the book this applies to programs "including those with control flows and data structures" and are not entirely numerical in the most common sense. Broadly speaking, with AD you can modify the results and the program will spit out the required inputs to get those results.

> Broadly speaking, with AD you can modify the results and the program will spit out the required inputs to get those results. I assume you're trying to phrase it in a non-technical way for accessibility, but I wonder if that might have lost some precision. What you describe sounds more like (logically) reversible programming ( https://en.wikipedia.org/wiki/Reversible_computing ). Differentiability doesn't imply reve…

But it can immediately return "no".

Re: The Elements of Differentiable Programming

#27

Earlier quoted context omitted.

[flagged]

> graduate-level introduction to differentiable programming. go check out any real graduate textbook. what you will find is they all have exercises. > It's a book for ML researchers. I'm excited to read it. Calm down. just because the authors claim something doesn't make it true. i'm not wrong - this is not a good pedagogical resource and i would bet a year of my salary (as an ML researcher) that you will in fact not…

Really? I'd gladly read 6% of a book for a year of pay.

Re: The Elements of Differentiable Programming

#28

One very interesting thing about automatic differentiation is that you can think of it as involving a new algebra, similar to the complex numbers, where we adjoin an extra element to the reals to form a plane. This new algebra is called the ring of "dual numbers." The difference is that instead of adding a new element "i" with i² = -1, we add one called "h" with h² = 0! Every element in the dual numbers is of the for…

[deleted]

Re: The Elements of Differentiable Programming

#29

i don't know why people write these things. it's an absolute hodge-podge of theorem/proofs/results/techniques with no unifying theme other than "CALCULUS". so it's a pretty bad math book to actually learn math from (you can always spot a pedagogically unsound math book by its lack of exercises). the book doesn't even have any code in it which is surprising considering it has "programming" in the title. actually i kno…

It’s an introduction to a relatively niche new subfield. If I (an expert in the field but not the subfield) want to learn about differentiable programming, my only option before this monograph was to read through tens of random papers which use different presentation styles, terminology etc. Now I can read through the second half of this, around 100 pages, and jump back to the first half if there’s a prerequisite I don’t know.

That’s how most subfields are born. Assorted papers -> monograph -> textbook. The first arrow is defining the subfield as a discrete topic, which is immensely valuable. Only after you have that you can start optimizing for presentation to nonexperts.

Re: The Elements of Differentiable Programming

#30

One very interesting thing about automatic differentiation is that you can think of it as involving a new algebra, similar to the complex numbers, where we adjoin an extra element to the reals to form a plane. This new algebra is called the ring of "dual numbers." The difference is that instead of adding a new element "i" with i² = -1, we add one called "h" with h² = 0! Every element in the dual numbers is of the for…

> Most autodiff packages (such as Pytorch) use something not much more advanced than this

pytorch absolutely does not use the dual number formulation - there are absolutely no magic epsilons anywhere in pytorch's (or tensorflow's) code base. what you're calling duals are the adjoints where are indeed stored/cached on every node in pytorch graphs.

there's a reason no one uses dual numbers (non-standard analysis) for anything (neither autodiff nor calculus itself): because manipulating infinitesmals like this is fraught formal manipulation (it's algebra...) where as limits are much more rigorous (bounds, inequalities, convergence, etc.). my favorite question to ask the non-standard analysis n00bs is: please tell me under what conditions this is true

(dx/dy)(dy/dz)(dz/dx) = 1

edit:

anyone that thinks i'm wrong and this other guy is right should go and do some reading, eg where this guy tried to make this same point and got shot down:

https://math.stackexchange.com/a/341550

spoiler alert: there's a reason you had to learn epsilon-delta proofs and limits and it's not because your math professors are mean.

this is why i hate this kind of "TIL, gee whiz" math tidbits - they're full of exclamation marks and fancy sounding words ("non-archimedean rings" oooo fancy) but almost always come from a wikipedia level understanding, not actual research.

Post reply on HN