Upgrade to Pro — share decks privately, control downloads, hide ads and more …

論文紹介:Dangers of Bayesian Model Averaging under Covariate Shift

論文紹介:Dangers of Bayesian Model Averaging under Covariate Shift

Masanari Kimura

October 19, 2022
Tweet

More Decks by Masanari Kimura

Other Decks in Research

Transcript

  1. . . . . . . . . . .

    Intro . . . . . . . . . . BNNs are not robust to covariate shift . . . . . . . . . . . . Understanding BNNs under covariate shift . . . . . . Towards more robust BMA . . . . Discussion References 論文紹介:Dangers of Bayesian Model Averaging under Covariate Shift Masanari Kimura ZOZO 研究所 理論機械学習チーム [email protected]
  2. . . . . . . . . . .

    Intro . . . . . . . . . . BNNs are not robust to covariate shift . . . . . . . . . . . . Understanding BNNs under covariate shift . . . . . . Towards more robust BMA . . . . Discussion References Intro 2/23
  3. . . . . . . . . . .

    Intro . . . . . . . . . . BNNs are not robust to covariate shift . . . . . . . . . . . . Understanding BNNs under covariate shift . . . . . . Towards more robust BMA . . . . Discussion References Introduction 3/23
  4. . . . . . . . . . .

    Intro . . . . . . . . . . BNNs are not robust to covariate shift . . . . . . . . . . . . Understanding BNNs under covariate shift . . . . . . Towards more robust BMA . . . . Discussion References TL;DR ▶ Izmailov et al. [2021a]; ▶ Bayesian Model Averaging が共変量シフトに対して脆弱であることを指摘; ▶ 共変量シフトに頑健な事前分布を提案 ▶ 提案する事前分布が Bayesian Neural Network の分布外汎化性能を向上させることを 確認. 4/23
  5. . . . . . . . . . .

    Intro . . . . . . . . . . BNNs are not robust to covariate shift . . . . . . . . . . . . Understanding BNNs under covariate shift . . . . . . Towards more robust BMA . . . . Discussion References Bayesian neural networks ▶ Bayesian neural networks (BNNs) モデルはモデルの重みの事前分布 p(w) と尤度関数 p(y|x, w) によって決まる. ▶ Bayes の定理から,データセット D = {(xi, yi) | i = 1, . . . , n} を観測した後の w の事 後分布は p(w|D) = p(D|w) · p(w) ∫ w′ p(D|w′) · p(w′)dw′ = ∏n i=1 p(yi|xi, w) · p(w) ∫ w′ ∏n i=1 p(yi|xi, w′) · p(w′) . (1) ▶ こうして得た事後分布を用いて,Bayesian Model Averaging (BMA) による予測は以 下のように行われる: p(y|x) = ∫ p(y|x, w) · p(w|D)dw. (2) 5/23
  6. . . . . . . . . . .

    Intro . . . . . . . . . . BNNs are not robust to covariate shift . . . . . . . . . . . . Understanding BNNs under covariate shift . . . . . . Towards more robust BMA . . . . Discussion References Covariate shift 以下を満たす問題設定を共変量シフト仮定と呼ぶ: ptrain(x, y) = ptrain(x) · p(y|x), ptest(x, y) = ptest(x) · p(y|x), ptrain(x) ̸= ptest(x). 6/23
  7. . . . . . . . . . .

    Intro . . . . . . . . . . BNNs are not robust to covariate shift . . . . . . . . . . . . Understanding BNNs under covariate shift . . . . . . Towards more robust BMA . . . . Discussion References BNNs are not robust to covariate shift 7/23
  8. . . . . . . . . . .

    Intro . . . . . . . . . . BNNs are not robust to covariate shift . . . . . . . . . . . . Understanding BNNs under covariate shift . . . . . . Towards more robust BMA . . . . Discussion References Settings Methods: ▶ MAP 解は SGD with momentum [Robbins and Monro, 1951] で近似; ▶ BNNs は Gaussian prior と Laplace prior [Fortuin, 2022] および温度 10−2 の cold posteriors [Izmailov et al., 2021b] を用いた結果を報告. Datasets and data augmentation: ▶ MNIST [LeCun and Cortes, 2010] と CIFAR-10 [Krizhevsky et al., 2014] を使用; ▶ Izmailov et al. [2021b] に従いデータ拡張は使用しない. Neural network architectures: ▶ LeNet-5 ベースのシンプルな CNN と 2 層の隠れ層を持つ MLP を使用. 8/23
  9. . . . . . . . . . .

    Intro . . . . . . . . . . BNNs are not robust to covariate shift . . . . . . . . . . . . Understanding BNNs under covariate shift . . . . . . Towards more robust BMA . . . . Discussion References Test data corruption and domain shift 2 種類のシフトを考える: ▶ Test data corruption:テストデータに学習データにはないノイズが乗っているよう なシナリオ ▶ Domain shift:学習データとテストデータのドメインが異なっているシナリオ 9/23
  10. . . . . . . . . . .

    Intro . . . . . . . . . . BNNs are not robust to covariate shift . . . . . . . . . . . . Understanding BNNs under covariate shift . . . . . . Towards more robust BMA . . . . Discussion References Robustness on MNIST ▶ Domain shift では MNIST で学習したモデルで SVHN データセットに対する予測を 行う; ▶ 多くのケースで BNN を用いることによる共変量シフトに対する性能劣化が観測; 10/23
  11. . . . . . . . . . .

    Intro . . . . . . . . . . BNNs are not robust to covariate shift . . . . . . . . . . . . Understanding BNNs under covariate shift . . . . . . Towards more robust BMA . . . . Discussion References Robustness on CIFAR-10 ▶ Domain shift では CIFAR-10 で学習したモデルで STL-10 データセットに対する予測 を行う; ▶ BNNs は MAP 解をわずかに上回る一方で deep ensembles には大きく劣る結果. 11/23
  12. . . . . . . . . . .

    Intro . . . . . . . . . . BNNs are not robust to covariate shift . . . . . . . . . . . . Understanding BNNs under covariate shift . . . . . . Towards more robust BMA . . . . Discussion References Understanding BNNs under covariate shift 12/23
  13. . . . . . . . . . .

    Intro . . . . . . . . . . BNNs are not robust to covariate shift . . . . . . . . . . . . Understanding BNNs under covariate shift . . . . . . Towards more robust BMA . . . . Discussion References Motivating example: dead pixels and FC layers Lemma 前結合の Bayesian neural network を使用し,入力特徴量 xi k がデータセット D 内の全ての xk で 0 とする.パラメータの事前分布 p(W) が第一層のあるニューロン j について p(W) = p(w1 ij ) · p(W \ w1 ij ) と分解できるとする.このとき,事後分布 p(W|D) もまた分解 でき,パラメータ w1 ij の周辺事後分布は p(W|D) = p(W \ w1 ij |D) · p(w1 ij ) (3) と書ける.よって,MAP 解は重み w1 ij を事前確率の最大値とする. ▶ 直感的には,上記補題はあるパラメータの事前分布が他のパラメータと独立でありか つ,パラメータの値がモデルの予測に影響を与えない時,そのパラメータの事後分布 は事前分布と一致することを意味する. 13/23
  14. . . . . . . . . . .

    Intro . . . . . . . . . . BNNs are not robust to covariate shift . . . . . . . . . . . . Understanding BNNs under covariate shift . . . . . . Towards more robust BMA . . . . Discussion References Motivating example: dead pixels and FC layers Proposition 上記補題が成り立つとする.また,事前分布 p(w1 ij ) の最大値が 0 であり,ネットワークが ReLU 活性化関数を用いているとする.このとき,任意のテストデータ ¯ x について, Bayesian model averaging に基づく予測は特徴量 ¯ xi の値に依存する一方で,MAP 解はそ の特徴量に依存しない. ▶ 例えば,MNIST データセットには多くの dead pixels がある. ▶ 多くの場合,パラメータの事前分布として独立な 0 平均の事前分布(e.g. Gaussian) を用いるが,補題によると,dead pixels に対応する第一層の重みの事後分布は事前分 布に一致する. ▶ このとき,もしテスト時に Gaussian noise などによって dead pixels が 0 でない値を とることがある場合,BMA の性能は MAP に比べて大きく劣化することが予想で きる. 14/23
  15. . . . . . . . . . .

    Intro . . . . . . . . . . BNNs are not robust to covariate shift . . . . . . . . . . . . Understanding BNNs under covariate shift . . . . . . Towards more robust BMA . . . . Discussion References General linear dependencies and FC layers Proposition 第一層の重み w1 ij とバイアス b1 j の事前分布が i.i.d. な Gaussian 分布 N(0, α2) とする.ま た,データセット D 内の全ての入力 x1 , . . . , xn が入力空間のアフィン部分空間に含まれる とする: ∑m j=1 xj i cj = c0 かつ ∑m i=0 c2 i = 1.このとき, 1. 一層目の隠れ層のあるニューロン j について,確率変数 wc j = ∑m i=1 ci w1 ij − c0 b1 j の事 後分布は事前分布 N(0, α2) に一致する. 2. MAP 解は wc j を 0 にする. 3. ネットワークが ReLU 活性化関数を用いているとする.このとき,テスト時の BMA の予測平均は ∑m j=1 ¯ xjcj − c0 に依存する.一方で MAP 解はこれに依存しない. 15/23
  16. . . . . . . . . . .

    Intro . . . . . . . . . . BNNs are not robust to covariate shift . . . . . . . . . . . . Understanding BNNs under covariate shift . . . . . . Towards more robust BMA . . . . Discussion References Empirical support 16/23
  17. . . . . . . . . . .

    Intro . . . . . . . . . . BNNs are not robust to covariate shift . . . . . . . . . . . . Understanding BNNs under covariate shift . . . . . . Towards more robust BMA . . . . Discussion References Linear dependencies and convolutional layers Proposition 第一層の畳み込みフィルタのパラメータとバイアスの事前分布が i.i.d. Gaussian 分布 N(0, α2) とする.また,第一層の畳み込みフィルタのサイズが K × K × C とする.サイズ N の集合 ˆ D をデータセット D に same padding を適用して生成される集合とし,ˆ D 内の全 てのパッチ z1 , . . . , zN がアフィン部分空間 RK×K×C : ∑C c=1 ∑K a=1 ∑K b=1 za,b i γc,a,b = γ0 , ∑C c=1 ∑K a=1 ∑K b=1 γ2 c,a,b + γ2 0 = 1 に含まれるとする.このとき,FC 層における Proposition の 1~3 と同様の主張を証明できる. 17/23
  18. . . . . . . . . . .

    Intro . . . . . . . . . . BNNs are not robust to covariate shift . . . . . . . . . . . . Understanding BNNs under covariate shift . . . . . . Towards more robust BMA . . . . Discussion References Towards more robust BMA 18/23
  19. . . . . . . . . . .

    Intro . . . . . . . . . . BNNs are not robust to covariate shift . . . . . . . . . . . . Understanding BNNs under covariate shift . . . . . . Towards more robust BMA . . . . Discussion References Data empirical covariance prior ▶ 全ての入力特徴量が 0 平均 ∑n i=1 xi = 0 となるように前処理されているとする.この とき,経験共分散行列は Σ = 1 n−1 ∑n i=1 xi xT i . ▶ これを用いた,以下の EmpCov prior を提案する: p(w1) = N(0, αΣ + ϵI). (4) 19/23
  20. . . . . . . . . . .

    Intro . . . . . . . . . . BNNs are not robust to covariate shift . . . . . . . . . . . . Understanding BNNs under covariate shift . . . . . . Towards more robust BMA . . . . Discussion References Experiments 20/23
  21. . . . . . . . . . .

    Intro . . . . . . . . . . BNNs are not robust to covariate shift . . . . . . . . . . . . Understanding BNNs under covariate shift . . . . . . Towards more robust BMA . . . . Discussion References Discussion 21/23
  22. . . . . . . . . . .

    Intro . . . . . . . . . . BNNs are not robust to covariate shift . . . . . . . . . . . . Understanding BNNs under covariate shift . . . . . . Towards more robust BMA . . . . Discussion References Discussion ▶ 学習データの線形依存性が BNNs の共変量シフトに対する汎化性能に及ぼす影響を 実験的及び理論的に明らかにした; ▶ 共変量シフトに頑健な BNNs のための事前分布を提案した. 22/23
  23. . . . . . . . . . .

    Intro . . . . . . . . . . BNNs are not robust to covariate shift . . . . . . . . . . . . Understanding BNNs under covariate shift . . . . . . Towards more robust BMA . . . . Discussion References References I Vincent Fortuin. Priors in bayesian deep learning: A review. International Statistical Review, 2022. Pavel Izmailov, Patrick Nicholson, Sanae Lotfi, and Andrew G Wilson. Dangers of bayesian model averaging under covariate shift. Advances in Neural Information Processing Systems, 34:3309–3322, 2021a. Pavel Izmailov, Sharad Vikram, Matthew D Hoffman, and Andrew Gordon Gordon Wilson. What are bayesian neural network posteriors really like? In International conference on machine learning, pages 4629–4640. PMLR, 2021b. Alex Krizhevsky, Vinod Nair, and Geoffrey Hinton. Cifar-10 (canadian institute for advanced research). 2014. URL http://www.cs.toronto.edu/~kriz/cifar.html. Yann LeCun and Corinna Cortes. MNIST handwritten digit database. 2010. URL http://yann.lecun.com/exdb/mnist/. Herbert Robbins and Sutton Monro. A stochastic approximation method. The annals of mathematical statistics, pages 400–407, 1951. 23/23