Large Scale GAN Training for High Fidelity Natural Image Synthesis

ICLR2019採択論文"Large Scale GAN Training for High Fidelity Natural Image Synthesis"のレビュー.

元論文はこちら

BigGANざっくり概要.GANsの規模を超でかくしたら超きれいな画像が作れた.

Abstract

Generative Adversarial Networks (GANs)の学習をこれまでにない規模で行った.

  • GANsの学習が,問題設定の大規模化によって大きな恩恵を得ることを実証し,既存の研究と比較して2~4倍多くのパラメータ及び8倍のバッチサイズでモデルを学習した.そのような大規模な学習を安定して行うためのいくつかのテクニックも提案.
  • サンプルの多様性と忠実度のトレードオフを細かく制御することを可能にする単純なサンプリング手法であるtruncation trickを提案.
  • 大規模なGANs特有の学習の不安定性を発見.これは既存のGANsの学習安定化手法の適用によって緩和することができるが,完全に安定化させるためには非常に大きなコストを必要とした.

Scaling Up GANs

  • ベースラインのネットワークアーキテクチャにはSA-GAN,目的関数にはhinge lossを使用
  • 学習には128-512 cores Google TPU Podを使用.

下記にベースラインの設定でバッチサイズを徐々に増やしていった場合の実験結果を示す.

単純にバッチサイズを大きく増やすことで,スコアの向上が見られる(バッチサイズを8倍にすることでInception Scoreが46%向上).

f:id:noconocolib:20190221135644p:plain

Trading Off Variety and Fidelity with The Truncation Trick

GANsは任意の潜在空間からノイズをサンプリングしてgeneratorでマッピングするが,著者らは学習時と異なる潜在分布をサンプリングに用いることで実験結果が改善したと報告.

具体的には,正規分布から入力ノイズをサンプリングする際,指定したレンジの外側をサンプリングしたときはレンジに収まるように再度サンプリングし直すというテクニックを使っている(Truncation Trick).

以下にTruncation Trickのレンジの閾値と生成画像の関係を図示する.

閾値が非常に小さいときは,同じ画像しか生成できていないことがわかる.

f:id:noconocolib:20190221135700p:plain

  • 生成されるサンプル画像たち
  • 従来よりも圧倒的にきれいな画像を作れていることがわかる.
  • 論文に載り切らなかったその他のサンプル画像はこちらから入手可能

f:id:noconocolib:20190221135710p:plain

Self-Attention Generative Adversarial Networks

GANsで高精細な画像を生成する手法を提案した"Self-Attention Generative Adversarial Networks"のレビュー.

元論文はこちら

Abstract

Convolutional GANsにself-attention mechanismを導入したSelf-Attention Generative Adversarial Networks (SAGANs)を提案.

Self-attentionモジュールは,畳み込み操作を補完し,画像内の広範囲の依存関係のモデリングを可能にする. こうしたself-attentionの仕組みを導入することで,generatorはより高精細な画像の生成が可能になり,discriminatorはより正確に生成画像に対する複雑な幾何学的制約を加えることができるようになる.

Self-attetnionに加えて,SAGANsでは従来discriminatorのみに適用されていたspectral normalizationをgeneratorにも適用することを提案している.

f:id:noconocolib:20190221111419p:plain

Self-Attention Generative Adversarial

f:id:noconocolib:20190221111447p:plain

多くの画像生成のためのGANsは畳み込みレイヤを採用している.畳み込み操作は局所近傍の情報を処理するため,畳み込みレイヤのみを使って画像内の広範囲をモデリングすることは計算量的に非効率.

これを可能にするため,論文ではself-attentionモジュールを導入する.

Attentionを計算するため,一つ前までの層の出力する特徴マップ x\in{\mathbb{R}^{C\times{N}}}を2つの特徴空間 f gに分解する.ここで f(x) = W_f x,\ g(x) = W_g x

 \beta_{j,i} = \frac{\exp (s_{ij})}{\sum^{N}_{i=1} \exp (s_{ij})},\ s_{ij} = f(x_{i})^{T} g(x_{j})

Attentionレイヤの出力 o = (o_1, o_2,\dots,o_j,\dots,o_N)\in{\mathbb{R}^{C\times{N}}}は,

 o_{j} = \sum^{N}_{i=1} \beta_{j,i} h(x_{i}),\ h(x_{i}) = W_{h} x_{i}

最終的な出力は,attentionの出力にスケーリングファクタをかけて入力に足したものになる.

 y_i = \gamma o_i + x_i

Technique to stabilize GAN training

GANsの学習の安定化のためにいくつかのテクニックを導入している.

Spectral normalization for both generator and discriminator

Spectral normalizationのもともとの論文では,GANsの学習の安定化のためにspectral normalizationをdiscriminatorのみに適用していた.これは,discriminatorがLipschitz連続性を満たすようにするため.

ここで,この論文ではspectral normalizationはdiscriminatorだけでなく,generatorにとっても有効であると主張し,両方に適用することで実験的に学習の安定化を達成.

Imbalanced learning rate for generator and discriminator updates

従来はgeneratorを一回更新するたびにdiscriminatorを複数更新するテクニックが使われていたが,その代わりにgeneratorとdiscriminatorの学習率を不均衡にすることを提案.

Experiments

  • SAGANとResidual blockを用いたGANsとの比較.
  • FID,ISともにSAGANがより良い結果を得られている.

f:id:noconocolib:20190221111957p:plain

  • いろいろなクラスの画像のSAGANによる生成結果.
  • かなりきれいな画像が生成できていることがわかる.

f:id:noconocolib:20190221112008p:plain

実装例

PyTorch C++ FrontendでTensor <-> cv::Matの相互変換

PyTorchのC++ APIであるLibTorchのTensorOpencvの行列を相互変換する方法.

torch::Tensor -> cv::Mat

  • torch::Tensorをcv::Matに変換する例
  • 例えば,128x128の1ch行列を変換するには以下のようにする.
cv::Mat mat(128,128, CV_32FC1, tensor. template data<float>());

cv::Mat -> torch::Tensor

  • cv::Matをtorch::Tensorに変換する例
  • torch::from_brobの第二引数には行列のshapeを渡す
std::vector<int64_t>shape = {1, height, width};
torch::Tensor tensor = torch::from_blob(mat.data, at::IntList(shape), at::ScalarType::Byte);

Defense against Adversarial Attacks Using High-Level Representation Guided Denoiser

CVPR2018採択論文"Defense against Adversarial Attacks Using High-Level Representation Guided Denoiser"のレビュー.

元論文はこちら

Classifierの誤分類を誘発するAdversarial Attacksに対する防御手法の提案.

入力画像に載せられている,悪意のあるノイズ(Adversarial Perturbations)を除去するDenoiserを用意して,正しい分類結果を得ることが目的.

Abstract

Image ClassificationタスクについてのAdversarial Attacksに対する防御手法であるhigh-level representation guided denoiser (HGD)を提案.

普通のノイズ除去モデルでは,画像内のすべてのadversarial perturbationsを除去することはできない. これを解決するため,一般的なdenoisersで用いられるpixel-level reconstruction lossではなく,もともとのサンプルとAdversarial Examplesに対する攻撃対象のモデルの出力の差を損失として扱う新しい損失関数を導入する.

f:id:noconocolib:20190129163128p:plain
Figure 1: The idea of high-level representation guided denoiser. The difference between the original image and adversarial image is tiny, but the difference is amplified in high-level representation (logits for example) of a CNN. We use the distance over high-level representations to guide the training of an image denoiser to suppress the influence of adversarial perturbation.

High-Level Representation Guided Denoiser

ピクセルレベルのノイズ除去モデルは,以下の損失関数を最適化する.

 L = |x - \hat{x}|

こうしたモデルによるperturbationの除去手法では,すべてのノイズを除去することはできず,残ったperturabationsによって誤った分類が行われてしまう.

これを解決するため,以下の損失関数を導入する.

 L = |f_l(\hat{x}) - f_l(x)|

f:id:noconocolib:20190129163214p:plain
Figure 3: The detail of DUNET. The numbers inside each cube stand for width × height, and the number outside the cube stands for the number of channels. In all the C3 of the feedforward path, the stride of the first C is 2 × 2.

論文では,損失関数の計算で用いられるレイヤーについて,2種類の選び方を提案している.

  •  l = -2のレイヤーを用いて特徴マップの差分を損失として用いるfeature guided denoiser (FGD)
  •  l = -1のレイヤーを用いてモデルの分類結果の差分を損失として用いるlogits guided denoiser (LGD)

f:id:noconocolib:20190129163246p:plain
Figure 4: Three different training methods for HGD. The square boxes stand for data blobs, the circles and ovals stand for networks. D stands for denoiser. CNN is the model to be defended. The parameters of the CNN are shared and fixed.

Adversarial Examples for Semantic Segmentation and Object Detection

ICCV2017採択論文"Adversarial Examples for Semantic Segmentation and Object Detection"のレビュー.

元論文はこちら

分類タスクにおいて,ニューラルネットワークの誤分類を誘発する攻撃手法であるAdversarial AttacksがSemantic SegmentationおよびObject Detectionタスクでも有効であることを示した論文.

Abstract

一般的にはClassificationタスクに対して適用されるAdversarial ExamplesをSemantic SegmentationとObject Detectionタスクに対して適用した研究.

著者らの観測から,Semantic SegmentationとObject Detectionは画像内の複数ターゲットのClassificationタスクの組み合わせから成り立っていることから,損失関数の適切な最適化によってAdversarial Examplesを生成できることを示している.これに基づき,著者らはsegmentationとdetectionに適用可能な攻撃方法であるDense Adversary Generation (DAG)を提案.

さらに,提案手法で生成したAdversarial Examplesは異なるアーキテクチャ,学習データセットおよび異なるタスクの間で使いまわせる.

f:id:noconocolib:20190126234153p:plain
An adversarial example for semantic segmentation and object detection

Dense Adversary Generation

提案手法であるDense Adversary Generation (DAG)は,入力画像とターゲットが与えられたとき,できるだけ多くのターゲットのご認識を誘発するようなAdversarial Examplesを生成する.

目的としては,ある特定のタスクについて,ネットワークの予測のすべてを間違わせるようなadversarial exampleを生成すること.

 L(X, T, L, L') = \sum^N_{n=1} [f_{l_n}(X, t_n) - f_{l'_n}(X, t_n)]

 Lを最小化したとき,すべてのターゲットについて間違った予測を誘発することができる.

提案手法では,最適化に勾配降下法を利用している.

各ステップで勾配を計算して摂動を累積していく.

 r_m = \sum_{t_n \in T_m} [\nabla x_m f_{l\'_n} (X_m, t_n) - \nabla x_m f_{l_n} (X_m, t_n)]

最終的なAdversarial Examplesは r = \sum_m r'_m

Experimental Results

  • 一つのAdversarial Exampleで複数のネットワーク,複数のタスクで誤認識を誘発することに成功している

f:id:noconocolib:20190126234508p:plain
Adding the fused adversarial perturbation confuses four different networks. The top row shows FR-VGG-07 and FR-ZF-07 detection results, and the bottom row shows FCN-Alex and FCN-VGG segmentation results. The blue in segmentation results corresponds to boat.

Decision-Based Adversarial Attacks: Reliable Attacks Against Black-Box Machine Learning Models

ICLR2018採択論文"Decision-Based Adversarial Attacks: Reliable Attacks Against Black-Box Machine Learning Models"のレビュー.

元論文はこちら

問題設定としては,クラウドAPIとして提供されているような機械学習モデルに対して,最終的な分類結果のみを使って誤分類を誘発するBlack-Box Adversarial Attackについての論文となる.

Abstract

多くの機械学習モデルは,画像内に小さな摂動を加えることで誤分類を誘発するAdversarial Examplesに脆弱性を持つ.しかし,多くの既存のAdversarial Examplesの研究は,モデルの内部情報を必要とすることから,現実の問題設定に即していないケースが多い.そこで論文では,モデルの最終的な分類結果のみから攻撃を行うdecision-based attacksの重要性を強調し,そうした環境下で攻撃を行う手法を提案.

f:id:noconocolib:20190125174629p:plain
Figure 1: (Left) Taxonomy of adversarial attack methods. The Boundary Attack is applicable to realworld ML algorithms because it only needs access to the final decision of a model (e.g. class-label or transcribed sentence) and does not rely on model information like the gradient or the confidence scores. (Right) Application to the Clarifai Brand Recognition Model.

本論文の貢献は,

  • decision-based attacksがadversarial attacksの重要なカテゴリであることを示唆.
  • decision-based attacksを達成する効果的な攻撃手法であるBoundary Attackを提案.提案手法は,(1) 非常にシンプル.(2) 非常に柔軟.(3) ハイパーパラメータのチューニングがほとんど必要ない.(4) SOTAな攻撃手法と比べて,competitiveな実験結果を達成.
  • Boundary Attackはdefensive distillationのような既存の防御手法を突破できることを示す.

Boundary Attack

Notation

  •  o: original image
  •  y = F(o): full prediction of the model $F$
  •  y_{max}: predicted label
  •  \tilde{o}: adversarially perturbed image
  •  \tilde{o}^k: perturbed image at k-th step of an attack algorithm

Algorithm

提案手法の概要をAlgorithm 1に示す.

f:id:noconocolib:20190125174859p:plain
Algorithm 1: Minimal version of the Boundary Attack.

Initialization

Boundary Attackはサンプルに加える摂動の初期化が必要となる.

untargeted scenarioでは,単純に入力ドメインのmaximum entropy distributionからサンプリングする.例えばcomputer visionにおいては,入力画像の各ピクセルは[0, 255]に制限されるため,一様分布 U(0, 255)からサンプリングすればいい.

targeted scearioでは,ターゲットクラスに分類されるような何らかの画像を初期値とする.

Proposal Distribution

提案手法の有効性はproposal distribution  Pに強く依存する.

最適なproposal distributionは一般的にはドメインと攻撃対象のモデルに依存する.

proposal distributionを決定する基本的なアイディアは以下の通り.

  1. 摂動を加えられた画像は入力ドメインに従う.

 \tilde{o}^{k-1}_i + \eta^k_i \in [0, 255]

  1. 摂動のサイズは以下を満たす.

 |\eta^k|_2 = \delta \cdot d(o, \tilde{o}^{k-1})

  1. 摂動が加えられた画像にさらに摂動を加えたとき,画像間の距離の相関関係は以下を満たす.

 d(o, \tilde{o}^{k-1}) - d(o, \tilde{o}^{k-1} + \eta^k) = \epsilon \cdot d(o, \tilde{o}^{k-1})

実際に上記の分布からサンプリングを行うのは難しいので,より単純なヒューリスティクスを利用する.

  • 最初に,iidなGaussian distributionからサンプリングを行い,上記の1と2を満たすように値のrescale & clipを行う.
  • 次に,もともとの入力画像$o$の周りの球に摂動 \eta d(o, \tilde{o}^{k-1} + \eta^k) = d(o, \tilde{o}^{k-1})となるようにマッピングする.これをorthogonal perturbationと呼び,後のハイパーパラメータのチューニングに使う.

  • 最後に,1,2,3を維持したまま,もともとの入力画像を少しだけ変化させる.

実験結果

  • 以下はtargeted attack設定による実験結果.
  • 入力画像は猫(original)で,誤分類させたいターゲットクラスは犬(0 calls)
  • step数を重ねるごとに,犬だった初期値画像がもともとの入力画像と見分けがつかなくなっていき,最終的に見た目では判断がつかないのにニューラルネットは猫を犬と誤分類してしまう.

f:id:noconocolib:20190125175248p:plain
Figure 7: Example of a targeted attack. Here the goal is to synthesize an image that is as close as possible (in L2-metric) to a given image of a tiger cat (2nd row, right) but is classified as a dalmatian dog. For each image we report the total number of model calls (predictions) until that point.

Universal adversarial perturbations

CVPR2017採択論文"Universal adversarial perturbations"のレビュー.

元論文はこちら

複数画像に対して汎用的に使えるuniversal perturbationを用いた分類機に対する攻撃が可能であることを示した論文.

Abstract

ニューラルネットワークに対して,一つのAdversarial Perturbationで複数の画像に適用可能なAdversarial Examplesを生成できるUniversal Adversarial Perturbationsを提案.

今までのAdversarial Perturbationsは,一つの画像につき一つの摂動ベクトルを生成して分類器の誤分類を誘発していたが,この論文では一つの摂動ベクトルで複数の画像に対する誤分類を誘発できるuniversal adversarial perturbationの存在を示し,そのようなベクトルを生成する手法を提案している.

f:id:noconocolib:20190131160443p:plain
Figure 1: When added to a natural image, a universal perturbation image causes the image to be misclassified by the deep neural network with high probability. Left images: Original natural images. The labels are shown on top of each arrow. Central image: Universal perturbation. Right images: Perturbed images. The estimated labels of the perturbed images are shown on top of each arrow.

Universal Perturbations

提案手法の目的は,分類器 \hat{k}を,分布 \muからサンプリングされる殆どのデータ点について騙せるような摂動ベクトル v \in \mathbb{R}^dを探すこと.

 \hat{k}(x + v) \neq \hat{k} (x)\ \  for "most" x\sim \mu

摂動ベクトル vは以下を満たす

  1.  |v|_p \leq \epsilon
  2.  \mathbb{P}_{x\sim{\mu}} (\hat{k} (x + v) \neq \hat{k}(x)) \geq 1 - \delta

パラメータ \epsilonは摂動ベクトルのサイズ, \deltaは画像全体についてのエラー率.

f:id:noconocolib:20190131160709p:plain
Schematic representation of the proposed algorithm used to compute universal perturbations.

提案アルゴリズムは,データ集合 X全体に渡ってイテレートし,徐々にuniversarial perturbationを更新していく.

 \delta v_i \gets argmin_r |r|_2 \ s.t.\ \hat{k} (x_i + v + r) \neq \hat{k} (x_i)

この最適化問題について, |v|_p \leq \epsilonを満たすため,更新するuniversal perturbationは中心0,半径 \epsilon l_p球上にマッピングされるようにする.

 P_{p, \epsilon} = argmin_{v'} |v - v'|_2 \ \ subject to |v'|_p \leq \epsilon

f:id:noconocolib:20190131160939p:plain

実験結果

  • 提案手法を用いた際の,学習セットとバリデーションセットに対するエラー率.

f:id:noconocolib:20190131161001p:plain
Table 1: Fooling ratios on the set X, and the validation set.

  • 摂動を加えられた画像と対応するラベル.

f:id:noconocolib:20190131161022p:plain
Figure 3: Examples of perturbed images and their corresponding labels. The first 8 images belong to the ILSVRC 2012 validation set, and the last 4 are images taken by a mobile phone camera. See supp. material for the original images.

  • GoogLeNetに対する複数種類のuniversarial perturbations.

f:id:noconocolib:20190131161041p:plain
Figure 5: Diversity of universal perturbations for the GoogLeNet architecture. The five perturbations are generated using different random shufflings of the set X. Note that the normalized inner products for any pair of universal perturbations does not exceed 0.1, which highlights the diversity of such perturbations.