# Folding over Neural Networks

arXiv: https://arxiv.org/abs/2207.01090 · HTML: https://mlsanity.com/paper/2207.01090/

## Key facts

- Cited by 1 papers in the map (data through 14 Oct 2026).
- Builds on 2 of its 25 references that are in the map.
- First posted on arXiv 3 Jul 2022.

## Builds on (most cited first, 2 of 2)

- [PyTorch: An Imperative Style, High-Performance Deep Learning Library](https://mlsanity.com/paper/1912.01703/) (2019)
- [The simple essence of automatic differentiation](https://mlsanity.com/paper/1804.00746/) (2018)

## Built on by (most cited first, 1 of 1)

- [Coinductive guide to inductive transformer heads](https://mlsanity.com/paper/2302.01834/) (2023)

## Abstract (arXiv)

Neural networks are typically represented as data structures that are traversed either through iteration or by manual chaining of method calls. However, a deeper analysis reveals that structured recursion can be used instead, so that traversal is directed by the structure of the network itself. This paper shows how such an approach can be realised in Haskell, by encoding neural networks as recursive data types, and then their training as recursion scheme patterns. In turn, we promote a coherent implementation of neural networks that delineates between their structure and semantics, allowing for compositionality in both how they are built and how they are trained.
