プリンキピア

第18章ガウス過程

18.2.4. The Radial Basis Function (RBF) Kernel18.2.4 動径基底関数(RBF)カーネル

The radial basis function (RBF) kernel is the most popular covariance function for Gaussian processes, and kernel machines in general. This kernel has the form kRBF(x,x′)=a2exp⁡(−12ℓ2||x−x′||2), where a is an amplitude parameter, and ℓ is a lengthscale hyperparameter.
英語のヒント
動径基底関数(RBF)カーネルは、ガウス過程、そしてカーネル法全般で最もよく使われる共分散関数である。このカーネルはkRBF(x,x′)=a2exp⁡(−12ℓ2||x−x′||2)の形をもつ。ここで、aは振幅パラメータ、ℓは長さスケールのハイパーパラメータである。
Let’s derive this kernel starting from weight space. Consider the function
英語のヒント
重み空間から出発して、このカーネルを導出しよう。次の関数を考える。
f(x)=∑i=1Jwiϕi(x),wi∼𝒩(0,σ2J),ϕi(x)=exp⁡(−(x−ci)22ℓ2).(18.2.4)
f(x) is a sum of radial basis functions, with width ℓ, centred at the points ci, as shown in the following figure.
英語のヒント
f(x)は、次の図に示すように、点ciを中心とする幅ℓの動径基底関数の和である。
We can recognize f(x) as having the form w⊤ϕ(x), where w=(w1,…,wJ)⊤ and ϕ(x) is a vector containing each of the radial basis functions. The covariance function of this Gaussian process is then
英語のヒント
f(x)はw⊤ϕ(x)の形をしていることがわかる。ここで、w=(w1,…,wJ)⊤であり、ϕ(x)は各動径基底関数を含むベクトルである。すると、このガウス過程の共分散関数は次のとおりである。
k(x,x′)=σ2J∑i=1Jϕi(x)ϕi(x′).(18.2.5)
Now let’s consider what happens as we take the number of parameters (and basis functions) to infinity. Let cJ=log⁡J, c1=−log⁡J, and ci+1−ci=Δc=2log⁡JJ, and J→∞. The covariance function becomes the Riemann sum:
英語のヒント
では、パラメータ(と基底関数)の数を無限大にすると何が起こるかを考えよう。cJ=log⁡J、c1=−log⁡J、ci+1−ci=Δc=2log⁡JJとし、J→∞とする。共分散関数はリーマン和になる。
k(x,x′)=limJ→∞σ2J∑i=1Jϕi(x)ϕi(x′)=∫c0c∞ϕc(x)ϕc(x′)dc.(18.2.6)
By setting c0=−∞ and c∞=∞, we spread the infinitely many basis functions across the whole real line, each a distance Δc→0 apart:
英語のヒント
c0=−∞、c∞=∞とすることで、無限に多くの基底関数を、互いに距離Δc→0ずつ離して、実数直線全体に広げる。
k(x,x′)=∫−∞∞exp⁡(−(x−c)22ℓ2)exp⁡(−(x′−c)22ℓ2)dc=πℓσ2exp⁡(−(x−x′)22(2ℓ)2)∝kRBF(x,x′).(18.2.7)
It is worth taking a moment to absorb what we have done here. By moving into the function space representation, we have derived how to represent a model with an infinite number of parameters, using a finite amount of computation. A Gaussian process with an RBF kernel is a universal approximator, capable of representing any continuous function to arbitrary precision. We can intuitively see why from the above derivation. We can collapse each radial basis function to a point mass taking ℓ→0, and give each point mass any height we wish.
英語のヒント
ここで何をしたかを少し時間をとってかみしめる価値がある。関数空間の表現に移ることで、無限個のパラメータをもつモデルを、有限の量の計算で表す方法を導いた。RBFカーネルをもつガウス過程は万能近似器であり、どんな連続関数も任意の精度で表せる。その理由は、上の導出から直観的にわかる。ℓ→0とすることで各動径基底関数を点質量につぶし、各点質量に好きな高さを与えられるのである。
So a Gaussian process with an RBF kernel is a model with an infinite number of parameters and much more flexibility than any finite neural network. Perhaps all the fuss about overparametrized neural networks is misplaced. As we will see, GPs with RBF kernels do not overfit, and in fact provide especially compelling generalization performance on small datasets. Moreover, the examples in (Zhang et al., 2021), such as the ability to fit images with random labels perfectly, but still generalize well on structured problems, (can be perfectly reproduced using Gaussian processes) (Wilson and Izmailov, 2020). Neural networks are not as distinct as we make them out to be.
英語のヒント
したがって、RBFカーネルをもつガウス過程は、無限個のパラメータをもち、どんな有限のニューラルネットワークよりもはるかに柔軟なモデルである。過剰パラメータ化されたニューラルネットワークをめぐる大騒ぎは、おそらく的外れである。後で見るように、RBFカーネルをもつGPは過学習せず、実際、小さなデータセットでとりわけ説得力のある汎化性能を示す。さらに、ランダムなラベルのついた画像に完全に当てはまりながら、構造をもつ問題ではやはりよく汎化する能力のような、(Zhang et al., 2021)の例は、(ガウス過程を使って完全に再現できる)(Wilson and Izmailov, 2020)。ニューラルネットワークは、そう見なされているほど特別なものではない。
We can build further intuition about Gaussian processes with RBF kernels, and hyperparameters such as length-scale, by sampling directly from the distribution over functions. As before, this involves a simple procedure:
英語のヒント
関数の上の分布から直接抜き出すことで、RBFカーネルをもつガウス過程や、長さスケールのようなハイパーパラメータについての直観をさらに深められる。前と同じように、これには簡単な手順がある。
  1. Choose the input x points we want to query the GP: x1,…,xn.
    英語のヒント
    GPに問い合わせたい入力xの点x1,…,xnを選ぶ。
  2. Evaluate m(xi), i=1,…,n, and k(xi,xj) for i,j=1,…,n to respectively form the mean vector and covariance matrix μ and K, where (f(x1),…,f(xn))∼𝒩(μ,K).
    英語のヒント
    i=1,…,nについてm(xi)を、i,j=1,…,nについてk(xi,xj)を評価して、それぞれ平均ベクトルμと共分散行列Kを作る。ここで、(f(x1),…,f(xn))∼𝒩(μ,K)である。
  3. Sample from this multivariate Gaussian distribution to obtain the sample function values.
    英語のヒント
    この多変量ガウス分布から抜き出して、見本の関数の値を得る。
  4. Sample more times to visualize more sample functions queried at those points.
    英語のヒント
    さらに何度も抜き出して、それらの点で問い合わせた見本の関数をもっと可視化する。
We illustrate this process in the figure below.
英語のヒント
この過程を下の図で示す。
def rbfkernel(x1, x2, ls=4.):  #@save
    dist = distance_matrix(np.expand_dims(x1, 1), np.expand_dims(x2, 1))
    return np.exp(-(1. / ls / 2) * (dist ** 2))

x_points = np.linspace(0, 5, 50)
meanvec = np.zeros(len(x_points))
covmat = rbfkernel(x_points,x_points, 1)

prior_samples= np.random.multivariate_normal(meanvec, covmat, size=5);
d2l.plt.plot(x_points, prior_samples.T, alpha=0.5)
d2l.plt.show()