summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTom Smeding <tom@tomsmeding.com>2023-03-01 11:03:32 +0100
committerTom Smeding <tom@tomsmeding.com>2023-03-01 11:03:42 +0100
commitb00b5abfbbbd14afa559452b909b23348e35c9fc (patch)
treea631453dcd97961ffa368ff20d48d13df0285a7e
parent813aae5bddcb2f8e34371cd5be44f8dcbfdf8a04 (diff)
Add ad/intro post
-rw-r--r--ad/intro.html16
-rw-r--r--ad/intro.md20
2 files changed, 36 insertions, 0 deletions
diff --git a/ad/intro.html b/ad/intro.html
new file mode 100644
index 0000000..7ea60b8
--- /dev/null
+++ b/ad/intro.html
@@ -0,0 +1,16 @@
+<h2>An intro to Automatic Differentiation</h2>
+<p>I originally wrote the text below to put on my homepage, but then I decided it would just clutter up the page without tremendous benefit.
+So the text is now here fofr you to enjoy.</p>
+<p>In automatic differentiation (AD), we study how to generalise taking symbolic/algebraic derivatives from simple mathematical expressions to whole computer programs, while keeping computational efficiency in mind.
+Being able to take the derivative of a numerical function implemented as a program is useful whenever you want to get some idea a program's local behaviour when you change its inputs a little; in the case of AD, we consider continuous inputs — in practice, floating point numbers.
+(If you're interested in the case where inputs are discrete, such as integers, look to <em>incremental computation</em> instead — about which I know very little.)</p>
+<p>For example, in machine learning, the usual approach is to formulate a <em>model</em> with a lot of parameters, and then optimise those parameters to make the model compute some kind of target function as well as possible.
+This model is a computer program; neural networks (as considered in machine learning) are simply computer programs of a particular, quite structured form.
+Optimising a model involves changing the parameters in such a way as to get the output closer to the desired output on some set of inputs, and the derivative (gradient, in this case) of the model tells you, at least locally, how to change the parameters to make the model a <em>little bit</em> better.
+Gradient descent, and other more sophisticated algorithms, use this derivative information to optimise a model in some fashion.
+AD allows model implementors to have a lot of freedom in designing their models, because whatever they do, the AD algorithm will let the system compute the model's derivative.</p>
+<p>Another application of AD is in statistical inference, such as in <a href="https://mc-stan.org/">Stan</a>, where users formulate a <em>statistical</em> model (with some parameters) of some part of the real world and then try to determine, given some real-world observations, where the parameters will approximately lie.
+(This is the Bayesian inference approach to statistical inference — frequentist inference fairly directly reduces to optimisation, for example using gradient descent.)
+Such inference algorithms need to compute a probability distribution (namely, the result: the distribution telling you where the parameters lie), and while it is relatively easy to give an indication of where these distributions are high (likely parameter values) and where they are low (unlikely ones), it's harder to <em>normalise</em> this distribution, which means computing what the actual <em>probability</em> of some parameter value is (as opposed to just being more or less likely than another parameter value).
+This normalisation involves integrating the produced unnormalised probability distribution, and clever integration algorithms (for continuous parameters, <a href="https://en.wikipedia.org/wiki/Hamiltonian_Monte_Carlo">HMC</a>) use the local &quot;relief&quot; (derivative) of your statistical model to more quickly find areas of interest, and more quickly converge to a good estimate of the overall integral (and thus the actual probabilities).
+Here, again, AD allows model implementors to not have to worry about writing their models in a specific form — any computation will do.</p>
diff --git a/ad/intro.md b/ad/intro.md
new file mode 100644
index 0000000..e81bf2f
--- /dev/null
+++ b/ad/intro.md
@@ -0,0 +1,20 @@
+## An intro to Automatic Differentiation
+
+I originally wrote the text below to put on my homepage, but then I decided it would just clutter up the page without tremendous benefit.
+So the text is now here fofr you to enjoy.
+
+In automatic differentiation (AD), we study how to generalise taking symbolic/algebraic derivatives from simple mathematical expressions to whole computer programs, while keeping computational efficiency in mind.
+Being able to take the derivative of a numerical function implemented as a program is useful whenever you want to get some idea a program's local behaviour when you change its inputs a little; in the case of AD, we consider continuous inputs &mdash; in practice, floating point numbers.
+(If you're interested in the case where inputs are discrete, such as integers, look to _incremental computation_ instead &mdash; about which I know very little.)
+
+For example, in machine learning, the usual approach is to formulate a _model_ with a lot of parameters, and then optimise those parameters to make the model compute some kind of target function as well as possible.
+This model is a computer program; neural networks (as considered in machine learning) are simply computer programs of a particular, quite structured form.
+Optimising a model involves changing the parameters in such a way as to get the output closer to the desired output on some set of inputs, and the derivative (gradient, in this case) of the model tells you, at least locally, how to change the parameters to make the model a _little bit_ better.
+Gradient descent, and other more sophisticated algorithms, use this derivative information to optimise a model in some fashion.
+AD allows model implementors to have a lot of freedom in designing their models, because whatever they do, the AD algorithm will let the system compute the model's derivative.
+
+Another application of AD is in statistical inference, such as in [Stan](https://mc-stan.org/), where users formulate a _statistical_ model (with some parameters) of some part of the real world and then try to determine, given some real-world observations, where the parameters will approximately lie.
+(This is the Bayesian inference approach to statistical inference &mdash; frequentist inference fairly directly reduces to optimisation, for example using gradient descent.)
+Such inference algorithms need to compute a probability distribution (namely, the result: the distribution telling you where the parameters lie), and while it is relatively easy to give an indication of where these distributions are high (likely parameter values) and where they are low (unlikely ones), it's harder to _normalise_ this distribution, which means computing what the actual _probability_ of some parameter value is (as opposed to just being more or less likely than another parameter value).
+This normalisation involves integrating the produced unnormalised probability distribution, and clever integration algorithms (for continuous parameters, [HMC](https://en.wikipedia.org/wiki/Hamiltonian_Monte_Carlo)) use the local "relief" (derivative) of your statistical model to more quickly find areas of interest, and more quickly converge to a good estimate of the overall integral (and thus the actual probabilities).
+Here, again, AD allows model implementors to not have to worry about writing their models in a specific form &mdash; any computation will do.