第18章ガウス過程
18.3.1. Posterior Inference for Regression18.3.1 回帰のための事後推論
An observation model relates the function we want to learn, , to our observations , both indexed by some input . In classification, could be the pixels of an image, and could be the associated class label. In regression, typically represents a continuous output, such as a land surface temperature, a sea-level, a concentration, etc.
英語のヒント
観測モデルは、学習したい関数を観測に関係づける。どちらも何らかの入力でインデックスづけされている。分類では、は画像の画素で、はそれに結びついたクラスラベルでありうる。回帰では、はふつう、地表の気温、海面の高さ、の濃度などの連続的な出力を表す。
In regression, we often assume the outputs are given by a latent noise-free function plus i.i.d. Gaussian noise :
英語のヒント
回帰ではしばしば、出力が、ノイズのない潜在的な関数に独立同分布のガウスノイズを加えたもので与えられると仮定する。
(18.3.1)
with . Let be a vector of our training observations, and be a vector of the latent noise-free function values, queried at the training inputs .
英語のヒント
ここで、である。を訓練の観測値のベクトル、を訓練入力で問い合わせた、ノイズのない潜在的な関数の値のベクトルとする。
We will assume , which means that any collection of function values has a joint multivariate Gaussian distribution, with mean vector and covariance matrix . The RBF kernel would be a standard choice of covariance function. For notational simplicity, we will assume the mean function ; our derivations can easily be generalized later on.
英語のヒント
と仮定する。これは、関数の値の任意の集まりが、平均ベクトルと共分散行列をもつ同時多変量ガウス分布に従うことを意味する。RBFカーネルは、共分散関数の標準的な選び方だろう。記法を簡単にするため、平均関数をと仮定する。この導出は後で簡単に一般化できる。
Suppose we want to make predictions at a set of inputs
英語のヒント
入力の集合で予測をしたいとしよう。
(18.3.2)
Then we want to find and . In the regression setting, we can conveniently find this distribution by using Gaussian identities, after finding the joint distribution over and .
英語のヒント
すると、とを見つけたい。回帰の設定では、との上の同時分布を見つけた後、ガウス分布の恒等式を使って、この分布を都合よく見つけられる。
If we evaluate equation (18.3.1) at the training inputs , we have . By the definition of a Gaussian process (see last section), where is an matrix formed by evaluating our covariance function (aka kernel) at all possible pairs of inputs . is simply a vector comprised of iid samples from and thus has distribution . is therefore a sum of two independent multivariate Gaussian variables, and thus has distribution . One can also show that where is an matrix formed by evaluating the kernel at all pairs of test and training inputs.
英語のヒント
訓練入力で式(18.3.1)を評価すると、となる。ガウス過程の定義(前の節を参照)から、である。ここで、は、入力のありうるすべての対で共分散関数(つまりカーネル)を評価してできるの行列である。は単にからの独立同分布の標本からなるベクトルであり、したがって分布に従う。したがって、は二つの独立な多変量ガウス変数の和であり、分布に従う。また、であることも示せる。ここで、は、テスト入力と訓練入力のすべての対でカーネルを評価してできるの行列である。
(18.3.3)
We can then use standard Gaussian identities to find the conditional distribution from the joint distribution (see, e.g., Bishop Chapter 2), , where , and .
英語のヒント
それから、標準的なガウス分布の恒等式を使って、同時分布から条件付き分布を見つけられる(たとえば、Bishopの第2章を参照)。ここで、、である。
Typically, we do not need to make use of the full predictive covariance matrix , and instead use the diagonal of for uncertainty about each prediction. Often for this reason we write the predictive distribution for a single test point , rather than a collection of test points.
英語のヒント
ふつうは、予測の共分散行列全体を使う必要はなく、代わりに各予測についての不確かさにはの対角成分を使う。この理由で、テスト点の集まりではなく、一つのテスト点についての予測分布を書くことが多い。
The kernel matrix has parameters that we also wish to estimate, such the amplitude and lengthscale of the RBF kernel above. For these purposes we use the marginal likelihood, , which we already derived in working out the marginal distributions to find the joint distribution over . As we will see, the marginal likelihood compartmentalizes into model fit and model complexity terms, and automatically encodes a notion of Occam’s razor for learning hyperparameters. For a full discussion, see MacKay Ch. 28 (MacKay, 2003), and Rasmussen and Williams Ch. 5 (Rasmussen and Williams, 2006).
英語のヒント
カーネル行列には、上のRBFカーネルの振幅や長さスケールのような、やはり推定したいパラメータがある。この目的のためには周辺尤度を使う。これは、の上の同時分布を見つけるために周辺分布を求めたときに、すでに導いている。後で見るように、周辺尤度はモデルの当てはまりの項とモデルの複雑さの項に分かれ、ハイパーパラメータの学習についてのオッカムの剃刀の考え方を自動的に符号化する。詳しい議論については、MacKayの第28章(MacKay, 2003)と、RasmussenとWilliamsの第5章(Rasmussen and Williams, 2006)を参照せよ。
import math
import os
import gpytorch
import matplotlib.pyplot as plt
import numpy as np
import torch
from scipy import optimize
from scipy.spatial import distance_matrix
from d2l import torch as d2l
d2l.set_figsize()