> For the complete documentation index, see [llms.txt](https://doraemonzzz.gitbook.io/transformer_evolution_paper/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://doraemonzzz.gitbook.io/transformer_evolution_paper/longconv/001.md).

# Legendre Memory Units: Continuous-Time Representation in Recurrent Neural Networks

论文地址：

* <https://papers.nips.cc/paper/2019/hash/952285b9b7e7a1be5aa7849f32ffff05-Abstract.html>

## 整体思路以及计算方式

一种RNN结构，模型计算的是输入信号在某个窗口内关于勒让德多项式的系数，达到某种程度的最优，系数的微分方程为：

$$
\theta \dot{\mathbf{m}}(t)=\mathbf{A} \mathbf{m}(t)+\mathbf{B} u(t)
$$

其中：

$$
\begin{aligned} \mathbf{A}&=\[a]*{i j} \in \mathbb{R}^{d \times d}, \quad a*{i j}=(2 i+1) \begin{cases}-1 & i\<j \ (-1)^{i-j+1} & i \geq j\end{cases} \ \mathbf{B}&=\[b]*{i} \in \mathbb{R}^{d \times 1}, \quad b*{i}=(2 i+1)(-1)^{i}, \quad i, j \in\[0, d-1] \end{aligned}
$$

离散化可得：

$$
\mathbf{m}*{t}=\mathbf{\overline A} \mathbf{m}*{t-1}+\mathbf{\overline B} u\_{t}
$$

其中：

$$
{\mathbf{\overline A}}=(\Delta t / \theta) \mathbf{A}+\mathbf{I}, \quad {\mathbf{\overline B}}=(\Delta t / \theta) \mathbf{B}
$$

最后的模型结构为：

$$
\mathbf{h}*{t}=f\left(\mathbf{W}*{\mathbf{x}} \mathbf{x}*{t}+\mathbf{W}*{\mathbf{h}} \mathbf{h}*{t-1}+\mathbf{W}*{\mathbf{m}} \mathbf{m}*{t}\right)\ u*{t}=\mathbf{e}*{\mathbf{x}}^{\top} \mathbf{x}*{t}+\mathbf{e}*{\mathbf{h}}{ }^{\top} \mathbf{h}*{t-1}+\mathbf{e}*{\mathbf{m}}^{\top} \mathbf{m}*{t-1}
$$

## 代码

* <https://github.com/hrshtv/pytorch-lmu>
* <https://github.com/nengo/keras-lmu>

## 简评

感觉S4应该或多或少从这篇文章受到某些启发。
