# Adaptive Fourier Neural Operators: Efficient Token Mixers for Transformers

论文地址：

* <https://arxiv.org/abs/2111.13587>

参考资料：

* <https://www.cvmart.net/community/detail/6177>

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

对于2维输入$$\mathbf X\in \mathbb R^{n\times d}$$：

$$
\mathbf Y =\mathrm{reshape}(\mathcal F(\mathbf X), n,-1, d/k) \in \mathbb R^{n\times k\times (d / k)}
$$

分块矩阵乘法：：

$$
\begin{aligned} \mathbf Y\_1 &= f(\mathbf Y \mathbf W\_1) \in \mathbb R^{n\times k \times (d/k)},\mathbf W\_1 \in \mathbb R^{k\times (d/k)\times (d/k)}\ \mathbf Y\_2 &= \mathbf Y\_1 \mathbf W\_2 \in \mathbb R^{n\times k \times (d/k)}, \mathbf W\_2 \in \mathbb R^{(d/k)\times (d/k)} \end{aligned}
$$

输出：

$$
\mathbf O=\mathcal F^{-1}(\mathrm{reshape}(\mathrm{softshrink} (\mathbf Y\_2), n , d) ) \in \mathbb R^{n\times d}
$$

FNO系列的对比图：

![](https://2520240655-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fb2lKDIgZ0I1cirExLedu%2Fuploads%2Fgit-blob-96c7a6153c244c6aca4045e7242a1995b11f97fd%2F1.jpg?alt=media)

## 时间复杂度

$$O(nd\log n+ n d^2 /k)$$

## 训练以及loss

不变。

## 代码

* <https://github.com/NVlabs/AFNO-transformer>

## 实验以及适用场景

适用于Encoder，效果还不错。

## 细节

softshrink操作的是因为在频域中，能量大多数集中在高频。

## 简评

这篇论文的写作是非常好的，理清楚了FNO系列的动机，改进；方法本身也值得复现。


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://doraemonzzz.gitbook.io/transformer_evolution_paper/mha/fft/003.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
