📺

Transformerよりもシンプル?「MLP-Mixer」爆誕(1日目) ~Abstract / Introduction編~

2021/05/16に公開

ニツオです。TwitterでAIやMLについて関連する話題を紹介してます。海外の研究者をフォローしていますので、情報源を増やしたい方はお気軽にフォローください。

さて、2021年5月にMLP-Mixerというモデルが爆誕しました。本日はその解説シリーズ1日目です。

  • 1日目: Abstract / Introduction
  • 2日目: Mixer Architecture
  • 3日目: Experiments
  • 4日目: Related Work
  • 5日目: Conclusion
  • 6日目: Appendix
  • 7日目: Source Code

「MLP-Mixer: An all-MLP Architecture for Vision」の原文はこちらです。2021年5月4日にGoogle ResearchとGoogle Brainの混合チームが発表され、関係者のTwitterでもかなり話題になっています。

シリーズ関連記事は一番下にリンク貼ってます。
早速みていきましょう。

Abstract

Convolutional Neural Networks (CNNs) are the go-to model for computer vision.

畳み込みニューラルネットワーク(CNN)は、コンピュータビジョンの代表的なモデル。

Recently, attention-based networks, such as the Vision Transformer, have also become popular.

最近では、Vision Transformerに代表されるAttentionベースのネットワークも普及してきた。

In this paper we show that while convolutions and attention are both sufficient for good performance, neither of them are necessary.

本論文では、CNNやAttentionモデルはどちらも良い性能を発揮するのに有用であるが、どちらも必須ではないことを示す。

We present MLP-Mixer, an architecture based exclusively on multi-layer perceptrons (MLPs).

今回紹介するのは、「MLP-Mixer」。これは、多層パーセプトロン(MLP)のみを使用したアーキテクチャだ。

本論文におけるパーセプトロンがどういうものか、というのは追々解説していきますが、一般的なパーセプトロンは、複数の入力に対して1つの出力を計算する関数で、出力は0か1になります。多層パーセプトロンはその単一のパーセプトロンを複数回使用したものを指します。機械学習を勉強する際に、一番最初に出てくる概念でもあります。

詳しくはこちらの記事がわかりやすいです。
https://qiita.com/yudsuzuk/items/a8e1eee92403f0921d92

MLP-Mixer contains two types of layers: one with MLPs applied independently to image patches (i.e. “mixing” the per-location features), and one with MLPs applied across patches (i.e. “mixing” spatial information).

MLP-Mixerは2種類のレイヤーで構成される。1つ目は画像パッチとは独立に適用されるMLP(位置ごとの特徴を”混合”するイメージ)、2つ目は画像パッチ全体に対して適用されるMLP(空間情報を”混合”するイメージ)だ。

When trained on large datasets, or with modern regularization schemes, MLP-Mixer attains competitive scores on image classification benchmarks, with pre-training and inference cost comparable to state-of-the-art models.

大規模データや最新の正則化スキームを用いて学習した場合、MLP-Mixerは画像分類ベンチマークで競争力のあるスコアを獲得し、事前学習と推論のコストは最新モデルと同等。

We hope that these results spark further research beyond the realms of well established CNNs and Transformers.1

今回の結果が、CNNやTransformerで確立された領域に一石を投じ、さらなる研究のきっかけになることを期待している。

1 Introduction

As the history of computer vision demonstrates, the availability of larger datasets coupled with increased computational capacity often leads to a paradigm shift.

コンピュータビジョンの歴史が示すように、大規模なデータセットの入手と計算能力の向上は、しばしばパラダイムシフトを引き起こします。

改めてパラダイムシフトというのは、Wikipediaからですが、「その時代や分野において当然のことと考えられていた認識や思想、社会全体の価値観などが革命的にもしくは劇的に変化すること」だそうです。
http://パラダイムシフトja.wikipedia.org/wiki/パラダイムシフト

画像認識だけでなく、機械学習(ML)の世界では特にそうだと思います。

While Convolutional Neural Networks (CNNs) have been the de-facto standard for computer vision, recently Vision Transformers [14] (ViT), an alternative based on self-attention layers, attained state-of-the-art performance.

例えば、畳み込みニューラルネットワーク(CNN)は、長らくコンピュータビジョンにおけるデファクトスタンダードだった。が、最近ではSelf-Attentionレイヤーを用いたVision Transformers(ViT)が最先端の性能を獲得している。

ViTは自然言語処理分野で2017年に最初提案されたTransformerの技術を画像認識に転用したモデルです。ベースとなったTransformerについては過去記事をどうぞ。
https://zenn.dev/attentionplease/articles/2d4b2b55ba396e

ViT continues the long-lasting trend of removing hand-crafted visual features and inductive biases from models and relies further on learning from raw data.

ViTは、人の手で介在した視覚的特徴や帰納的バイアスをモデルから排除し、生のデータからの学習により重きを置いていこうという、長年のトレンドを引き継いでいる。

帰納的というのは、複数の事実などから1つの推論を行う方法のことです。またここでいう、帰納的バイアスというのは、学習データ以外に既に持っている知識のことで、事前に別のデータで学習済みのパラメータなどを指すと思われます。
https://next.rikunabi.com/journal/20161101_s7/
https://xtech.nikkei.com/dm/atcl/mag/15/00144/00026/

We propose the MLP-Mixer architecture (or “Mixer” for short), a competitive but conceptually and technically simple alternative, that does not use convolutions or self-attention.

今回、本論文では、MLP-Mixerアーキテクチャー(略してMixer)を提案する。このアーキテクチャーは性能面において競争力があるにも関わらず、概念的にも技術的にもシンプルであり、畳み込みやSelf-Attentionレイヤーを使用しない(ところが良い)。

Instead, Mixer’s architecture is based entirely on multi-layer perceptrons (MLPs) that are repeatedly applied across either spatial locations or feature channels.

(それらを使用しない)代わりに、Mixerのアーキテクチャは、(ベクトル)空間的な位置や、特徴的なチャンネルの、いずれかに繰り返し適用される多層パーセプトロン(MLP)をベースに構成されている。

具体的なことは後続に出てくるので、そこで見ていきましょう。

Mixer relies only on basic matrix multiplication routines, changes to data layout (reshapes and transpositions), and scalar non-linearities.

Mixerが使用するのは、基本的な行列の乗算やその繰り返し、データレイアウトの変更(行列のReshapeという要素数は変えずに形状を変えることや、行と列を入れ替える転置)、および非線形変換のみ。

Figure 1 depicts he macro-structure of Mixer.

図1は、Mixerのマクロ構造を表す。

It accepts a sequence of linearly projected image patches (also referred to as tokens) shaped as a “patches × channels” table as an input, and maintains this dimensionality.

Mixerは、線形代数的な意味で言う線形射影されて、ベクトルの次元数が減らされて計算しやすくなった画像パッチ(トークンとも呼ばれる)の配列(列ベクトル)を、「パッチ×チャネル」のテーブルとして入力し、その次元を維持するものである。

1つ1つ見ていきましょう。

Mixer makes use of two types of MLP layers: channel-mixing MLPs and token-mixing MLPs.

Mixerには2種類のMLPレイヤーがある。チャネル混合MLPとトークン混合MLPだ。図で言うと、MLP1とMLP2だ。

The channel-mixing MLPs allow communication between different channels; they operate on each token independently and take individual rows of the table as inputs.

チャネル混合MLPは、異なるチャネル間のデータの相互関係を考えることができる仕組みで、列に当たる各トークンに対して独立して動作し、テーブルの各行を入力とする。

つまり、MLP2を指す。MLP2に対する入力は列ベクトルの各要素のトークンに対して、チャネルをまたいだものになるので、チャネル間の混合になる。

The token-mixing MLPs allow communication between different spatial locations (tokens); they operate on each channel independently and take individual columns of the table as inputs.

トークン混合MLPは、ベクトル空間的に異なる位置情報(つまり異なる列ベクトルであるトークン)間のデータの相互関係を考えることができる仕組みで、行に当たる各チャネルで独立して動作し、テーブルの各列を入力とする。

つまり、MLP1を指す。ここでは行になっている各チャネルごとに、独立してMLPをあてて、各チャネル内のトークンを混合している。

These two types of layers are interleaved to enable interaction of both input dimensions.

これらの2種類のレイヤーは、両方の入力次元の相互作用を可能にするために間をあけて配置される。

In the extreme case, our architecture can be seen as a very special CNN, which uses 1×1 convolutions for channel mixing, and single-channel depth-wise convolutions of a full receptive field and parameter sharing for token mixing.

極端に言えば、我々のアーキテクチャは、非常に特殊なCNNと見なすことができる。具体的には、チャネル混合に行×列の形状が1×1の1マスの畳み込みフィルターを使い、トークン混合にパラメータ共有しあう受容野を模した単一チャネルの深さ方向の畳み込みフィルターを使ったCNNとみなせる。

Receptive Fieldとは受容野のこと。これに限らず機械学習は神経科学から来ているので、様々な言葉が神経科学から来ています。今回の受容野は、ニューロンという今回で言うと視覚に関する神経細胞に影響を与える網膜上の範囲を受容野というそうです。
https://lp-tech.net/articles/frQNo

However, the converse is not true as typical CNNs are not special cases of Mixer.

しかし、典型的なCNNはMixerの特別なケースではないので、その逆は成り立たない。

Furthermore, a convolution is more complex than the plain matrix multiplication in MLPs as it requires an additional costly reduction to matrix multiplication and/or specialized implementation.

もッというと、畳み込み演算は、MLPにおける普通の行列の掛け算よりも複雑で、行列の掛け算への変換や特殊な実装が必要となり、とにかくコストがかかります。

Despite its simplicity, Mixer attains competitive results.

Mixerは、シンプルでありながら、性能的に競争力があるという結果が出た。

When pre-trained on large datasets (i.e., ∼100M images), it reaches near state-of-the-art performance, previously claimed by CNNs and Transformers, in terms of the accuracy/cost trade-off.

Mixerは、大規模なデータセット(約1億枚)で事前学習を行うと、精度とコストというトレードオフな観点において、CNNやTransformerが主張していた最先端の性能に近い結果が得られた。

This includes 87.94% top-1 validation accuracy on ILSVRC2012 “ImageNet” [13].

87.94%という精度をたたき出した ILSVRC2012 "ImageNet" も含まれた比較で、だ。

When pre-trained on data of more modest scale (i.e., ∼1–10M images), coupled with modern regularization techniques [47, 52], Mixer also achieves strong performance.

また、別の論文で提案された正則化・正規化技術を用いて、100〜1,000万画像程度のデータを用いて学習した場合にも,高い性能を発揮した。

However, similar to ViT, it falls slightly short of specialized CNN architectures.

しかし、ViTと同様に、より特定の画像認識タスクに特化させたCNNのアーキテクチャにはやや及ばない。

おわり

「MLP-Mixer」を解説するシリーズ1日目は以上です。次回はModel Architectureです。

感想や要望・指摘等は、本記事へのコメントか、TwitterのリプライやDMでもお待ちしております!

https://twitter.com/hnishio0105/status/1393915608383639554?s=20

また、結構な時間を費やして書いていますので、投げ銭・サポートの程、よろしくお願いいたします!

シリーズ関連記事はこちら
https://zenn.dev/attentionplease/articles/532a3de6308f57
https://zenn.dev/attentionplease/articles/7a11a56d767280
https://zenn.dev/attentionplease/articles/df6170f8581b71
https://zenn.dev/attentionplease/articles/7a3e74ad1bc9bf
https://zenn.dev/attentionplease/articles/a0d88939f9ceed
https://zenn.dev/attentionplease/articles/719580daf5a2d1

【2023年5月追記】
また、Slack版ChatGPT「Q」というサービスを開発・運営しています。
こちらもぜひお試しください。
https://q-bot.suchica.com/

Discussion