第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 , where is an amplitude parameter, and is a lengthscale hyperparameter.
英語のヒント
動径基底関数(RBF)カーネルは、ガウス過程、そしてカーネル法全般で最もよく使われる共分散関数である。このカーネルはの形をもつ。ここで、は振幅パラメータ、は長さスケールのハイパーパラメータである。
Let’s derive this kernel starting from weight space. Consider the function
英語のヒント
重み空間から出発して、このカーネルを導出しよう。次の関数を考える。
(18.2.4)
is a sum of radial basis functions, with width , centred at the points , as shown in the following figure.
英語のヒント
は、次の図に示すように、点を中心とする幅の動径基底関数の和である。
We can recognize as having the form , where and is a vector containing each of the radial basis functions. The covariance function of this Gaussian process is then
英語のヒント
はの形をしていることがわかる。ここで、であり、は各動径基底関数を含むベクトルである。すると、このガウス過程の共分散関数は次のとおりである。
(18.2.5)
Now let’s consider what happens as we take the number of parameters (and basis functions) to infinity. Let , , and , and . The covariance function becomes the Riemann sum:
英語のヒント
では、パラメータ(と基底関数)の数を無限大にすると何が起こるかを考えよう。、、とし、とする。共分散関数はリーマン和になる。
(18.2.6)
By setting and , we spread the infinitely many basis functions across the whole real line, each a distance apart:
英語のヒント
、とすることで、無限に多くの基底関数を、互いに距離ずつ離して、実数直線全体に広げる。
(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 , and give each point mass any height we wish.
英語のヒント
ここで何をしたかを少し時間をとってかみしめる価値がある。関数空間の表現に移ることで、無限個のパラメータをもつモデルを、有限の量の計算で表す方法を導いた。RBFカーネルをもつガウス過程は万能近似器であり、どんな連続関数も任意の精度で表せる。その理由は、上の導出から直観的にわかる。とすることで各動径基底関数を点質量につぶし、各点質量に好きな高さを与えられるのである。
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カーネルをもつガウス過程や、長さスケールのようなハイパーパラメータについての直観をさらに深められる。前と同じように、これには簡単な手順がある。
- Choose the input points we want to query the GP: .
英語のヒント
GPに問い合わせたい入力の点を選ぶ。 - Evaluate , , and for to respectively form the mean vector and covariance matrix and , where .
英語のヒント
についてを、についてを評価して、それぞれ平均ベクトルと共分散行列を作る。ここで、である。 - Sample from this multivariate Gaussian distribution to obtain the sample function values.
英語のヒント
この多変量ガウス分布から抜き出して、見本の関数の値を得る。 - 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()