4 ms·
Thanks for checking out our project! Completely understand where you're coming from, I also struggled with imagining how differentiable programs could work, aft
by bmc7505 7y ago
Thanks for checking out our project! Completely understand where you're coming from, I also struggled with imagining how differentiable programs could work, after all, computer programs implement discrete functions! When building it, I learned two surprising facts:
(1) We can perform gradient descent on integer functions! [1] There are rigorous assumptions for differentiability (e.g. Lipschitz-continuity, β-smoothness), but most often, these don't apply in the real world. Although many discrete optimization problems can relaxed to semi-differentiable ones, even if a function is not strictly differentiable, we can still derive an approximately correct expression for the gradient.
(2) It is possible to symbolically derive functions in discrete spaces! There are many, many examples of this in various settings (e.g. Brzonski's derivative [2], Lambda calculus [3], Boolean algebra [4], et al. [5]). A number of researchers are studying generalized differentiation, or "change propagation" in other topological spaces [6]. Although still very abstract and hard to interpret, these ideas have important applications for incremental computation and together with probabilistic programming [7], may one day lead to an analogous mechanism to gradient descent on a much broader class of functions.
With this in mind, Kotlin𝛁 implements symbolic differentiation. Whenever the user writes "+" or "*" in their program and later asks for the derivative, we apply the sum and product rules, and do not consider the question of domain validity. For floating point numbers, we try to perform some consistency checks using finite differences, but ultimately, leave this up to the user to verify whether their their domain is a valid one.
Shameless plug, but if you find this interesting, you can learn more about this in Chapter 3 of my M.S. thesis [8]. Please don't hesitate to get in touch if you have any questions or would like to chat!
[1]: https://openreview.net/pdf?id=HJGXzmspb https://openreview.net/pdf?id=HJGXzmspb
[2]: http://maveric.uwaterloo.ca/reports/1964_JACM_Brzozowski.pdf http://maveric.uwaterloo.ca/reports/1964_JACM_Brzozowski.pdf
[3]: https://core.ac.uk/download/pdf/82396223.pdf https://core.ac.uk/download/pdf/82396223.pdf
[4]: https://pdfs.semanticscholar.org/a9c8/7568463a5ce8c2cd15ec17e9a54e1158db2b.pdf https://pdfs.semanticscholar.org/a9c8/7568463a5ce8c2cd15ec17...
[5]: https://en.wikipedia.org/wiki/Generalizations_of_the_derivative https://en.wikipedia.org/wiki/Generalizations_of_the_derivat...
[6]: https://arxiv.org/pdf/1902.05465.pdf https://arxiv.org/pdf/1902.05465.pdf
[7]: https://www.cs.ubc.ca/~fwood/CS532W-539W/ https://www.cs.ubc.ca/~fwood/CS532W-539W/
[8]: https://github.com/breandan/kotlingrad/blob/master/latex/thesis/thesis.pdf https://github.com/breandan/kotlingrad/blob/master/latex/the...