SlideShare a Scribd company logo
20. Deep Generative Models
20.9 ~20.15
M2 Daichi Shibata
final !!
今からの内容 

大雑把にはこんな感じ
• 20.9 誤差逆伝播法の拡張
• 20.10 有向生成ネットワーク

20.10.3 VAE

20.10.4 GAN

20.10.7 自己符号化器
• 20.14 生成モデルの評価
• 20.15 結論
• 従来のNNは入力変数xの決定論的な変換

決定論的:入力が同じなら出力はいつも同じ
• 生成モデルの場合はxの確率的な変換を実装したいことが多い



一般的な機械学習の問題
• 物体認識でラベルを当てる
• 音の波形から発音を当てる基本的に不確実性はない
• 誰が見ても答えは同じ,あるいは正解が1つ.
生成モデルの問題
• 生成モデルでは画像の上半分だけ与えて下半分を予測する
• 有名人っぽい顔を生成する,オリジナルな音楽を作る
• 答えは1つではない
ランダム操作を経由する誤差逆伝播

Back-Propagation through Random Operations
[1] https://www.youtube.com/watch?v=7CPcvLs8iEs
[2] https://www.slideshare.net/beam2d/learning-stochastic-neural-networks-with-chainer
• 生成モデルの場合はxの確率的な変換を実装したいことが多い

単純な解決法:入力zを一様分布やガウス分布からサンプリングする



この場合,NNは内部的に決定論的な計算をし,zを観測できない者にはf(x,z)が確率的に現れる 

=> 確率的なNNとみなせる
• 確率的なNNユニット:
• 確率的なNNユニットってBP(誤差逆伝播)できなくない?

fが連続で微分可能ならば,BPを用いて訓練が可能である

zをサンプリングしているから数学的に???な状態

ランダム操作を経由する誤差逆伝播

Back-Propagation through Random Operations
Bernoulli unit ([2]より)Gaussian unit ([2]より)
ランダム操作を経由する誤差逆伝播

Back-Propagation through Random Operations
• 平均μ,分散σ^2,を持つガウス分布から以下のようにサンプルzを抽出する操作
を考える
• このユニットの勾配が計算できれば,今まで通り最適化できる
z ∼ N(μ, σ2
)
Gaussian unit ([2]より)
ランダム操作を経由する誤差逆伝播

Back-Propagation through Random Operations
• 再パラメータ化トリック(Reparametrization trick)

サンプリング操作を,追加の入力zに対する決定論的な演算であると見做す
• ノイズを与えることで決定論的な演算になる!!
Reparameterization trick ([2]より)
ランダム操作を経由する誤差逆伝播

Back-Propagation through Random Operations
• 再パラメータ化トリック(Reparametrization trick)

決定論的な演算であれば,微分可能!!
[3] https://stats.stackexchange.com/questions/199605/how-does-the-reparameterization-trick-for-vaes-work-and-why-is-it-important
Reparameterization trickとBackprop ([3]より)
[補足] 離散的な確率的操作を経由する誤差逆伝播

Back-Propagation through Discrete Stochastic Operations
• モデルが離散変数yを出力する際には,再パラメータ化トリックは適応できない

y=f(z;w) と記述,入力x,パラメータθをまとめたベクトルをw, ランダムノイズをzとする

ここでyは離散とする => fはステップ関数
• fがステップ関数であるため,微分してもほとんど0で意味ない

誤差逆伝播を行うためには微分してどっちに最適化すれば良いかの情報が欲しい
• REINFORCEアルゴリズム[4][24]

損失関数:J(f(z; w))が役に立たずとも,コストの期待値 E_{z~p(z)} J(f(z; w)) は滑らかな関数であること
が多い

Jはwに関与しないことを仮定
対数の微分公式より導出
勾配の不偏モンテカルロ推定量
[4] http://www-anw.cs.umass.edu/~barto/courses/cs687/williams92simple.pdf

[24] https://github.com/pytorch/examples/blob/master/reinforcement_learning/reinforce.py
20.10.3 変分自己符号化器
VAE(variational autoencoder)
• 学習された近似推論を用い,勾配に基づく方法で純粋に訓練できる有向モデル

= NNのエンコーダー,デコーダーの仕組みで生成モデルを学習できる
• VAE Reference

[5] Auto Encoding Variational Bayes [https://arxiv.org/pdf/1312.6114.pdf]

[6] VAE Tutorial [https://arxiv.org/pdf/1606.05908.pdf]

[7] Variational Autoencoder徹底解説 [https://qiita.com/kenmatsu4/items/b029d697e9995d93aa24]

[8] Variational Auto Encoder [https://nzw0301.github.io/notes/vae.pdf]

[9] 猫でもわかる VAE [https://www.slideshare.net/ssusere55c63/variational-autoencoder-64515581] 

[10] Intuitively Understanding Variational Autoencoders[https://towardsdatascience.com/intuitively-understanding-variational-autoencoders-1bfe67eb5daf]
VAEの概念図 ([7]より)
20.10.3 変分自己符号化器
VAE(variational autoencoder)
• VAEでは潜在変数zが正規分布に従うことを仮定している
AutoEncoderの概念図 ([7]より) VAEの概念図 ([7]より)
20.10.3 変分自己符号化器
VAE(variational autoencoder)
• Encoderは入力をz(潜在変数)に圧縮 • Decoderはz(潜在変数)から出力画像を生成
Decoder部分
VAEのEncoder部分 ([7]より)
VAEのDecoder部分 ([7]より)
20.10.3 変分自己符号化器
VAE(variational autoencoder)
• ネットワークの全体を図示するとこんな感じ
• 潜在変数に正規分布を仮定しているのはなぜ?

生成モデルでは確率的なNNを扱いたい + 一番扱いやすいから
VAEのネットワーク ([10]より)
20.10.3 変分自己符号化器
VAE(variational autoencoder)
• より一般的な話に移ります(ニューラルネットは一旦置いておく)
• 上の図をグラフィカルに表す
VAEの概念図 ([9]より)
([7] より) ([7] より)
20.10.3 変分自己符号化器
VAE(variational autoencoder)
• 生成モデルの目的

データの分布であるp(X)を推定すること
• パラメータを求めるためには?

1. p(X) の尤度を最大にするパラメータ(theta, phi)を最尤法によって求める

2. 扱いやすいように対数尤度log p(X) を最大にする

3. log p(X)を最大にしたいが,積分の扱いが困難

 変分下限 L(X, z) を最大にすることで,下から抑える
変分法の話と同じ
変分下限の導出 ([7]より)
20.10.3 変分自己符号化器
VAE(variational autoencoder)
• 対数尤度 log p(X)と変分下限 L(X, z)の差を計算する

カルバックライブラーダイバージェンス(Kullback-Leibler divergence)が出てくる

= 2つの確率分布の差異を表す量(一致で0 ※詳細は3章へ)
([7]より)
20.10.3 変分自己符号化器
VAE(variational autoencoder)
• ここまでの関係を一旦まとめると
• Kullback-Leibler divergence は3つの項に分解できる
L(X, z) = logp(X) − DKL[qϕ(z|X)||pθ(z|X)]
([7]より)
20.10.3 変分自己符号化器
VAE(variational autoencoder)
• 変分下限に代入する
• ニューラルネットではマイナスをかけて最小化問題にする
([9]より)
([7]より)
20.10.3 変分自己符号化器
VAE(variational autoencoder)
• Kullback-Leibler divergence (KLD) 2つの確率分布の差異を表す量:一致で0

p(z) = N(0, I)と仮定した

q(z|X) の方は,N(mu, sigma) からsampling(Reparametrization trick)してる
• 正規分布間のKLDは下記のように計算 ([5] Appendix B, [6] 参照) Jはzの次元数
−DKL[q(z|X)||p(z)]
20.10.3 変分自己符号化器
VAE(variational autoencoder)
• Reconstruction Error (復元誤差)と呼ばれる値

zが与えられた時にデータXが復元する確率(期待値) を大きくしたい
• 以下の式で近似することが可能,ここで
• p(x|z)に多変量ベルヌーイ分布を仮定すると以下のように書ける
• 詳細は [5] chapter3, Appendix C 参照
Eq(z|X)
[logp(X|z)]
zl
∼ qϕ(z|x)
20.10.3 変分自己符号化器
VAE(variational autoencoder)
• 訓練時の動作 • テスト時の動作
VAEの概念図 ([6]より)
20.10.3 変分自己符号化器
VAE(variational autoencoder)
• 今回の話を実装したコード(ほぼ本家のパクり)

20.10.4 GAN

Generative Adversarial Network
• Reference

[11] Generative Adversarial Nets [https://arxiv.org/pdf/1406.2661.pdf]

[12] Improved Techniques for Training GANs [https://arxiv.org/pdf/1606.03498.pdf]

[13] Introduction to Generative Adversarial Networks [http://www.iangoodfellow.com/slides/2016-12-9-gans.pdf]

[14] DCGAN TUTORIAL [https://pytorch.org/tutorials/beginner/dcgan_faces_tutorial.html]

[15] NIPS 2016 Tutorial [https://arxiv.org/pdf/1701.00160.pdf]

[16] Generating Letters Using Generative Adversarial Networks

[https://medium.com/ml-everything/generating-letters-using-generative-adversarial-networks-gans-161b0be3c229]

[30] GAN (と強化学習の関係) [https://www.slideshare.net/masa_s/gan-83975514]

• 敵対的生成ネットワーク

敵対的:Generator(生成),Discriminator(識別)が相反する目的で学習する
• Generator,Discriminatorはニューラルネット
([16]より)
20.10.4 GAN

Generative Adversarial Network
• 敵対的に学習する

=> ゲーム理論の枠組みで定式化できる
• D and G play the following two-player minimax game with value function V(G, D)

[11] chapter3 より
([13] より)
([11] より)
20.10.4 GAN

Generative Adversarial Network
• Minimax Game [12] (二人ゼロ和ゲーム ?)
• Non-Saturating Game [12] (二人非ゼロ和ゲーム ?)
• 学習にはJを最小化させる
>ゼロ和2人ゲームのナッシュ均衡点は,マックスミニ戦略とミニマックス戦略との組
である.このような均衡点をミニマックス均衡点という[25].
[25] ゲーム理論(鈴木光男)
20.10.4 GAN

Generative Adversarial Network
• 学習は不安定だけど結構いい画像ができる

Mode Collapse:同じ画像が生成されてしまう現象
• 画像合成タスクに対しては深層畳み込みGANを作ると良い結果が得られ
る:DCGAN[23]
• 低解像度な画像を生成してから,徐々に高解像度な画像を生成するようにす
ると結構良い結果:LAPGAN[24]
• ドロップアウトは識別器ネットワークに重要
[23] DCGAN [https://arxiv.org/pdf/1511.06434.pdf]
[24] LAPGAN [https://arxiv.org/pdf/1506.05751.pdf]
20.10.6 DCGAN
• 畳み込み層,転置畳み込み層を追加したGAN
• DCGANを使って有名人の顔画像を生成する

pytorchのtutorialのパクリ
20.10.5 モーメントマッチングネットワーク
MMD(maximum mean discrepancy)[17]
• GANから派生

GANのDiscriminatorの代わりに,MMDと呼ばれるコスト関数 (大きいほど区別しやすい)
を最小化することで生成器を学習する. 本物と偽物の分布の距離が近くなるように生成
器を学習
• MMDのコスト関数の概念図[18]:
[18] https://www.researchgate.net/figure/Calculating-maximum-mean-discrepancy-MMD-between-the-negative-control-
and-drug-treated_fig2_320108860
[17] https://arxiv.org/pdf/1705.08584.pdf
20.10.7~ 自己回帰ネットワーク

Autoregressive Network
• 潜在確率変数を持たない有向確率モデル

時系列,生成モデルとしてよく使われている
• 自己回帰 vs 回帰

回帰: y = b + b1*X1

自己回帰:X(t+1) = b + b1*X(t-1) + b2*X(t-2)
• ベイジアンネットワーク(FVBN)

確率変数間の因果関係を視覚的に表現する方法

観測変数における同時確率を確率の連鎖律を用いて分解する

p(a, b, c) = p(cla, b)p(bla)p(a)

a, bが起きることでcが起きる, aが起きることでbが起きる, aが起きる

• Reference

[19] Autoregressive Networks[https://medium.com/intuitionmachine/voice-style-transfer-using-deep-learning-d173f1608af5]

[21] Deep AutoRegressive Networks [https://arxiv.org/pdf/1310.8499.pdf]

[23] PRML 第8章 グラフィカルモデル [https://www.slideshare.net/antiplastics/prml8]
i 番目の変数を,その前の i − 1 個の変数から予
測する完全に可視的な信念ネットワーク (p674)
ベイジアンネットワーク(FVBN)
20.10.7~ 自己回帰ネットワーク

Autoregressive Network
ニューラル自己回帰密度推定器の図 (p677)
• 生成モデルとしての利用

x=(x1,...,xn)であるとき,以下のように分解することが可能



• 条件付き分布をNNによって表現する

(i-1) x n 個の入力とn個の出力を持つニューラルネットワークによって,

それぞれのP(x_i, | x_{i-1}, .., x_1)をパラメータ化
• ニューラル自己回帰密度推定器[20]

ニューラル自己回帰ネットワークにパラメータ共有手段

を追加した手法 

[20] The Neural Autoregressive Distribution Estimator 

[http://proceedings.mlr.press/v15/larochelle11a/larochelle11a.pdf]
• 最近の研究: PixelCNN[28], PixelRNN[29]

[28] https://arxiv.org/pdf/1701.05517.pdf

[29] https://arxiv.org/pdf/1601.06759.pdf

p(x) = p(x1, . . . , xn) = Πn
i=1p(xi |x1, . . . , xi−1)
最近の研究
• Pix2Pix[25], CycleGAN[26] [UC Berkeley]

Image-to-image translationの研究

[25] https://phillipi.github.io/pix2pix/

[26] https://junyanz.github.io/CycleGAN/
• A Style-Based Generator Architecture for Generative Adversarial Networks [NVIDIA]

latent code(潜在変数?)をそのまま入力とするのではなく,Mapping Networkを用いて潜在空間に射影

[27] https://arxiv.org/pdf/1812.04948.pdf

20.14 評価
• 生成モデリングにおける最も重要な研究課題の1つ

評価の観点と欠点はそれぞれ以下の通り



1. 生成モデルと実際のデータの分布が近いこと評価

- 事前処理をすると生成モデルの分布が変わってしまう

- 目的によって評価すべき指標が異なる(通常のモデルも同じだけど)



2. 画像や音声であれば実際に生成されたデータを見る

- 単純に訓練データのコピーを出力すると良いように見える

- 犬と猫の訓練画像から犬の画像だけを生成するように過学習しても,視覚的には良い可能性がある
• サーベイ論文(GANの評価手法)

もっとも有名:Inception Score[12]

[31] Pros and Cons of GAN Evaluation Measures [https://arxiv.org/pdf/1802.03446.pdf]
20.15 結論
• 生成モデルは,世界を理解するためのモデルを作るための強力な方法

人工知能が理解する必要のある直感的な概念の枠組みを提供し,不確実であっても
これらの概念について推論する能力を与える
• 読者には,これらの方法をより強力にする新たな方法を見つけることや,学習と知
識の基礎になっている原理を理解するための探求を続けることを望んでいる



(We hope that our readers will find new ways to make these approaches more
powerful and continue the journey to understanding the principles that underlie
learning and intelligence.)

More Related Content

Featured

2024 State of Marketing Report – by Hubspot
2024 State of Marketing Report – by Hubspot2024 State of Marketing Report – by Hubspot
2024 State of Marketing Report – by Hubspot
Marius Sescu
 
Everything You Need To Know About ChatGPT
Everything You Need To Know About ChatGPTEverything You Need To Know About ChatGPT
Everything You Need To Know About ChatGPT
Expeed Software
 
Product Design Trends in 2024 | Teenage Engineerings
Product Design Trends in 2024 | Teenage EngineeringsProduct Design Trends in 2024 | Teenage Engineerings
Product Design Trends in 2024 | Teenage Engineerings
Pixeldarts
 
How Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental HealthHow Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental Health
ThinkNow
 
AI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdfAI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdf
marketingartwork
 
Skeleton Culture Code
Skeleton Culture CodeSkeleton Culture Code
Skeleton Culture Code
Skeleton Technologies
 
PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024
Neil Kimberley
 
Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)
contently
 
How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024
Albert Qian
 
Social Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie InsightsSocial Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie Insights
Kurio // The Social Media Age(ncy)
 
Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024
Search Engine Journal
 
5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary
SpeakerHub
 
ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd
Clark Boyd
 
Getting into the tech field. what next
Getting into the tech field. what next Getting into the tech field. what next
Getting into the tech field. what next
Tessa Mero
 
Google's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search IntentGoogle's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search Intent
Lily Ray
 
How to have difficult conversations
How to have difficult conversations How to have difficult conversations
How to have difficult conversations
Rajiv Jayarajah, MAppComm, ACC
 
Introduction to Data Science
Introduction to Data ScienceIntroduction to Data Science
Introduction to Data Science
Christy Abraham Joy
 
Time Management & Productivity - Best Practices
Time Management & Productivity -  Best PracticesTime Management & Productivity -  Best Practices
Time Management & Productivity - Best Practices
Vit Horky
 
The six step guide to practical project management
The six step guide to practical project managementThe six step guide to practical project management
The six step guide to practical project management
MindGenius
 
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
RachelPearson36
 

Featured (20)

2024 State of Marketing Report – by Hubspot
2024 State of Marketing Report – by Hubspot2024 State of Marketing Report – by Hubspot
2024 State of Marketing Report – by Hubspot
 
Everything You Need To Know About ChatGPT
Everything You Need To Know About ChatGPTEverything You Need To Know About ChatGPT
Everything You Need To Know About ChatGPT
 
Product Design Trends in 2024 | Teenage Engineerings
Product Design Trends in 2024 | Teenage EngineeringsProduct Design Trends in 2024 | Teenage Engineerings
Product Design Trends in 2024 | Teenage Engineerings
 
How Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental HealthHow Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental Health
 
AI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdfAI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdf
 
Skeleton Culture Code
Skeleton Culture CodeSkeleton Culture Code
Skeleton Culture Code
 
PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024
 
Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)
 
How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024
 
Social Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie InsightsSocial Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie Insights
 
Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024
 
5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary
 
ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd
 
Getting into the tech field. what next
Getting into the tech field. what next Getting into the tech field. what next
Getting into the tech field. what next
 
Google's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search IntentGoogle's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search Intent
 
How to have difficult conversations
How to have difficult conversations How to have difficult conversations
How to have difficult conversations
 
Introduction to Data Science
Introduction to Data ScienceIntroduction to Data Science
Introduction to Data Science
 
Time Management & Productivity - Best Practices
Time Management & Productivity -  Best PracticesTime Management & Productivity -  Best Practices
Time Management & Productivity - Best Practices
 
The six step guide to practical project management
The six step guide to practical project managementThe six step guide to practical project management
The six step guide to practical project management
 
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
 

Deep Learning 20章 輪講会 資料

  • 1. 20. Deep Generative Models 20.9 ~20.15 M2 Daichi Shibata
  • 3. 今からの内容 
 大雑把にはこんな感じ • 20.9 誤差逆伝播法の拡張 • 20.10 有向生成ネットワーク
 20.10.3 VAE
 20.10.4 GAN
 20.10.7 自己符号化器 • 20.14 生成モデルの評価 • 20.15 結論
  • 4. • 従来のNNは入力変数xの決定論的な変換
 決定論的:入力が同じなら出力はいつも同じ • 生成モデルの場合はxの確率的な変換を実装したいことが多い
 
 一般的な機械学習の問題 • 物体認識でラベルを当てる • 音の波形から発音を当てる基本的に不確実性はない • 誰が見ても答えは同じ,あるいは正解が1つ. 生成モデルの問題 • 生成モデルでは画像の上半分だけ与えて下半分を予測する • 有名人っぽい顔を生成する,オリジナルな音楽を作る • 答えは1つではない ランダム操作を経由する誤差逆伝播
 Back-Propagation through Random Operations [1] https://www.youtube.com/watch?v=7CPcvLs8iEs [2] https://www.slideshare.net/beam2d/learning-stochastic-neural-networks-with-chainer
  • 5. • 生成モデルの場合はxの確率的な変換を実装したいことが多い
 単純な解決法:入力zを一様分布やガウス分布からサンプリングする
 
 この場合,NNは内部的に決定論的な計算をし,zを観測できない者にはf(x,z)が確率的に現れる 
 => 確率的なNNとみなせる • 確率的なNNユニット: • 確率的なNNユニットってBP(誤差逆伝播)できなくない?
 fが連続で微分可能ならば,BPを用いて訓練が可能である
 zをサンプリングしているから数学的に???な状態
 ランダム操作を経由する誤差逆伝播
 Back-Propagation through Random Operations Bernoulli unit ([2]より)Gaussian unit ([2]より)
  • 6. ランダム操作を経由する誤差逆伝播
 Back-Propagation through Random Operations • 平均μ,分散σ^2,を持つガウス分布から以下のようにサンプルzを抽出する操作 を考える • このユニットの勾配が計算できれば,今まで通り最適化できる z ∼ N(μ, σ2 ) Gaussian unit ([2]より)
  • 7. ランダム操作を経由する誤差逆伝播
 Back-Propagation through Random Operations • 再パラメータ化トリック(Reparametrization trick)
 サンプリング操作を,追加の入力zに対する決定論的な演算であると見做す • ノイズを与えることで決定論的な演算になる!! Reparameterization trick ([2]より)
  • 8. ランダム操作を経由する誤差逆伝播
 Back-Propagation through Random Operations • 再パラメータ化トリック(Reparametrization trick)
 決定論的な演算であれば,微分可能!! [3] https://stats.stackexchange.com/questions/199605/how-does-the-reparameterization-trick-for-vaes-work-and-why-is-it-important Reparameterization trickとBackprop ([3]より)
  • 9. [補足] 離散的な確率的操作を経由する誤差逆伝播
 Back-Propagation through Discrete Stochastic Operations • モデルが離散変数yを出力する際には,再パラメータ化トリックは適応できない
 y=f(z;w) と記述,入力x,パラメータθをまとめたベクトルをw, ランダムノイズをzとする
 ここでyは離散とする => fはステップ関数 • fがステップ関数であるため,微分してもほとんど0で意味ない
 誤差逆伝播を行うためには微分してどっちに最適化すれば良いかの情報が欲しい • REINFORCEアルゴリズム[4][24]
 損失関数:J(f(z; w))が役に立たずとも,コストの期待値 E_{z~p(z)} J(f(z; w)) は滑らかな関数であること が多い
 Jはwに関与しないことを仮定 対数の微分公式より導出 勾配の不偏モンテカルロ推定量 [4] http://www-anw.cs.umass.edu/~barto/courses/cs687/williams92simple.pdf
 [24] https://github.com/pytorch/examples/blob/master/reinforcement_learning/reinforce.py
  • 10. 20.10.3 変分自己符号化器 VAE(variational autoencoder) • 学習された近似推論を用い,勾配に基づく方法で純粋に訓練できる有向モデル
 = NNのエンコーダー,デコーダーの仕組みで生成モデルを学習できる • VAE Reference
 [5] Auto Encoding Variational Bayes [https://arxiv.org/pdf/1312.6114.pdf]
 [6] VAE Tutorial [https://arxiv.org/pdf/1606.05908.pdf]
 [7] Variational Autoencoder徹底解説 [https://qiita.com/kenmatsu4/items/b029d697e9995d93aa24]
 [8] Variational Auto Encoder [https://nzw0301.github.io/notes/vae.pdf]
 [9] 猫でもわかる VAE [https://www.slideshare.net/ssusere55c63/variational-autoencoder-64515581] 
 [10] Intuitively Understanding Variational Autoencoders[https://towardsdatascience.com/intuitively-understanding-variational-autoencoders-1bfe67eb5daf] VAEの概念図 ([7]より)
  • 11. 20.10.3 変分自己符号化器 VAE(variational autoencoder) • VAEでは潜在変数zが正規分布に従うことを仮定している AutoEncoderの概念図 ([7]より) VAEの概念図 ([7]より)
  • 12. 20.10.3 変分自己符号化器 VAE(variational autoencoder) • Encoderは入力をz(潜在変数)に圧縮 • Decoderはz(潜在変数)から出力画像を生成 Decoder部分 VAEのEncoder部分 ([7]より) VAEのDecoder部分 ([7]より)
  • 13. 20.10.3 変分自己符号化器 VAE(variational autoencoder) • ネットワークの全体を図示するとこんな感じ • 潜在変数に正規分布を仮定しているのはなぜ?
 生成モデルでは確率的なNNを扱いたい + 一番扱いやすいから VAEのネットワーク ([10]より)
  • 14. 20.10.3 変分自己符号化器 VAE(variational autoencoder) • より一般的な話に移ります(ニューラルネットは一旦置いておく) • 上の図をグラフィカルに表す VAEの概念図 ([9]より) ([7] より) ([7] より)
  • 15. 20.10.3 変分自己符号化器 VAE(variational autoencoder) • 生成モデルの目的
 データの分布であるp(X)を推定すること • パラメータを求めるためには?
 1. p(X) の尤度を最大にするパラメータ(theta, phi)を最尤法によって求める
 2. 扱いやすいように対数尤度log p(X) を最大にする
 3. log p(X)を最大にしたいが,積分の扱いが困難
  変分下限 L(X, z) を最大にすることで,下から抑える 変分法の話と同じ 変分下限の導出 ([7]より)
  • 16. 20.10.3 変分自己符号化器 VAE(variational autoencoder) • 対数尤度 log p(X)と変分下限 L(X, z)の差を計算する
 カルバックライブラーダイバージェンス(Kullback-Leibler divergence)が出てくる
 = 2つの確率分布の差異を表す量(一致で0 ※詳細は3章へ) ([7]より)
  • 17. 20.10.3 変分自己符号化器 VAE(variational autoencoder) • ここまでの関係を一旦まとめると • Kullback-Leibler divergence は3つの項に分解できる L(X, z) = logp(X) − DKL[qϕ(z|X)||pθ(z|X)] ([7]より)
  • 18. 20.10.3 変分自己符号化器 VAE(variational autoencoder) • 変分下限に代入する • ニューラルネットではマイナスをかけて最小化問題にする ([9]より) ([7]より)
  • 19. 20.10.3 変分自己符号化器 VAE(variational autoencoder) • Kullback-Leibler divergence (KLD) 2つの確率分布の差異を表す量:一致で0
 p(z) = N(0, I)と仮定した
 q(z|X) の方は,N(mu, sigma) からsampling(Reparametrization trick)してる • 正規分布間のKLDは下記のように計算 ([5] Appendix B, [6] 参照) Jはzの次元数 −DKL[q(z|X)||p(z)]
  • 20. 20.10.3 変分自己符号化器 VAE(variational autoencoder) • Reconstruction Error (復元誤差)と呼ばれる値
 zが与えられた時にデータXが復元する確率(期待値) を大きくしたい • 以下の式で近似することが可能,ここで • p(x|z)に多変量ベルヌーイ分布を仮定すると以下のように書ける • 詳細は [5] chapter3, Appendix C 参照 Eq(z|X) [logp(X|z)] zl ∼ qϕ(z|x)
  • 21. 20.10.3 変分自己符号化器 VAE(variational autoencoder) • 訓練時の動作 • テスト時の動作 VAEの概念図 ([6]より)
  • 22. 20.10.3 変分自己符号化器 VAE(variational autoencoder) • 今回の話を実装したコード(ほぼ本家のパクり)

  • 23. 20.10.4 GAN
 Generative Adversarial Network • Reference
 [11] Generative Adversarial Nets [https://arxiv.org/pdf/1406.2661.pdf]
 [12] Improved Techniques for Training GANs [https://arxiv.org/pdf/1606.03498.pdf]
 [13] Introduction to Generative Adversarial Networks [http://www.iangoodfellow.com/slides/2016-12-9-gans.pdf]
 [14] DCGAN TUTORIAL [https://pytorch.org/tutorials/beginner/dcgan_faces_tutorial.html]
 [15] NIPS 2016 Tutorial [https://arxiv.org/pdf/1701.00160.pdf]
 [16] Generating Letters Using Generative Adversarial Networks
 [https://medium.com/ml-everything/generating-letters-using-generative-adversarial-networks-gans-161b0be3c229]
 [30] GAN (と強化学習の関係) [https://www.slideshare.net/masa_s/gan-83975514]
 • 敵対的生成ネットワーク
 敵対的:Generator(生成),Discriminator(識別)が相反する目的で学習する • Generator,Discriminatorはニューラルネット ([16]より)
  • 24. 20.10.4 GAN
 Generative Adversarial Network • 敵対的に学習する
 => ゲーム理論の枠組みで定式化できる • D and G play the following two-player minimax game with value function V(G, D)
 [11] chapter3 より ([13] より) ([11] より)
  • 25. 20.10.4 GAN
 Generative Adversarial Network • Minimax Game [12] (二人ゼロ和ゲーム ?) • Non-Saturating Game [12] (二人非ゼロ和ゲーム ?) • 学習にはJを最小化させる >ゼロ和2人ゲームのナッシュ均衡点は,マックスミニ戦略とミニマックス戦略との組 である.このような均衡点をミニマックス均衡点という[25]. [25] ゲーム理論(鈴木光男)
  • 26. 20.10.4 GAN
 Generative Adversarial Network • 学習は不安定だけど結構いい画像ができる
 Mode Collapse:同じ画像が生成されてしまう現象 • 画像合成タスクに対しては深層畳み込みGANを作ると良い結果が得られ る:DCGAN[23] • 低解像度な画像を生成してから,徐々に高解像度な画像を生成するようにす ると結構良い結果:LAPGAN[24] • ドロップアウトは識別器ネットワークに重要 [23] DCGAN [https://arxiv.org/pdf/1511.06434.pdf] [24] LAPGAN [https://arxiv.org/pdf/1506.05751.pdf]
  • 27. 20.10.6 DCGAN • 畳み込み層,転置畳み込み層を追加したGAN • DCGANを使って有名人の顔画像を生成する
 pytorchのtutorialのパクリ
  • 28. 20.10.5 モーメントマッチングネットワーク MMD(maximum mean discrepancy)[17] • GANから派生
 GANのDiscriminatorの代わりに,MMDと呼ばれるコスト関数 (大きいほど区別しやすい) を最小化することで生成器を学習する. 本物と偽物の分布の距離が近くなるように生成 器を学習 • MMDのコスト関数の概念図[18]: [18] https://www.researchgate.net/figure/Calculating-maximum-mean-discrepancy-MMD-between-the-negative-control- and-drug-treated_fig2_320108860 [17] https://arxiv.org/pdf/1705.08584.pdf
  • 29. 20.10.7~ 自己回帰ネットワーク
 Autoregressive Network • 潜在確率変数を持たない有向確率モデル
 時系列,生成モデルとしてよく使われている • 自己回帰 vs 回帰
 回帰: y = b + b1*X1
 自己回帰:X(t+1) = b + b1*X(t-1) + b2*X(t-2) • ベイジアンネットワーク(FVBN)
 確率変数間の因果関係を視覚的に表現する方法
 観測変数における同時確率を確率の連鎖律を用いて分解する
 p(a, b, c) = p(cla, b)p(bla)p(a)
 a, bが起きることでcが起きる, aが起きることでbが起きる, aが起きる
 • Reference
 [19] Autoregressive Networks[https://medium.com/intuitionmachine/voice-style-transfer-using-deep-learning-d173f1608af5]
 [21] Deep AutoRegressive Networks [https://arxiv.org/pdf/1310.8499.pdf]
 [23] PRML 第8章 グラフィカルモデル [https://www.slideshare.net/antiplastics/prml8] i 番目の変数を,その前の i − 1 個の変数から予 測する完全に可視的な信念ネットワーク (p674) ベイジアンネットワーク(FVBN)
  • 30. 20.10.7~ 自己回帰ネットワーク
 Autoregressive Network ニューラル自己回帰密度推定器の図 (p677) • 生成モデルとしての利用
 x=(x1,...,xn)であるとき,以下のように分解することが可能
 
 • 条件付き分布をNNによって表現する
 (i-1) x n 個の入力とn個の出力を持つニューラルネットワークによって,
 それぞれのP(x_i, | x_{i-1}, .., x_1)をパラメータ化 • ニューラル自己回帰密度推定器[20]
 ニューラル自己回帰ネットワークにパラメータ共有手段
 を追加した手法 
 [20] The Neural Autoregressive Distribution Estimator 
 [http://proceedings.mlr.press/v15/larochelle11a/larochelle11a.pdf] • 最近の研究: PixelCNN[28], PixelRNN[29]
 [28] https://arxiv.org/pdf/1701.05517.pdf
 [29] https://arxiv.org/pdf/1601.06759.pdf
 p(x) = p(x1, . . . , xn) = Πn i=1p(xi |x1, . . . , xi−1)
  • 31. 最近の研究 • Pix2Pix[25], CycleGAN[26] [UC Berkeley]
 Image-to-image translationの研究
 [25] https://phillipi.github.io/pix2pix/
 [26] https://junyanz.github.io/CycleGAN/ • A Style-Based Generator Architecture for Generative Adversarial Networks [NVIDIA]
 latent code(潜在変数?)をそのまま入力とするのではなく,Mapping Networkを用いて潜在空間に射影
 [27] https://arxiv.org/pdf/1812.04948.pdf

  • 32. 20.14 評価 • 生成モデリングにおける最も重要な研究課題の1つ
 評価の観点と欠点はそれぞれ以下の通り
 
 1. 生成モデルと実際のデータの分布が近いこと評価
 - 事前処理をすると生成モデルの分布が変わってしまう
 - 目的によって評価すべき指標が異なる(通常のモデルも同じだけど)
 
 2. 画像や音声であれば実際に生成されたデータを見る
 - 単純に訓練データのコピーを出力すると良いように見える
 - 犬と猫の訓練画像から犬の画像だけを生成するように過学習しても,視覚的には良い可能性がある • サーベイ論文(GANの評価手法)
 もっとも有名:Inception Score[12]
 [31] Pros and Cons of GAN Evaluation Measures [https://arxiv.org/pdf/1802.03446.pdf]
  • 33. 20.15 結論 • 生成モデルは,世界を理解するためのモデルを作るための強力な方法
 人工知能が理解する必要のある直感的な概念の枠組みを提供し,不確実であっても これらの概念について推論する能力を与える • 読者には,これらの方法をより強力にする新たな方法を見つけることや,学習と知 識の基礎になっている原理を理解するための探求を続けることを望んでいる
 
 (We hope that our readers will find new ways to make these approaches more powerful and continue the journey to understanding the principles that underlie learning and intelligence.)