プリンキピア

第3章回帰のための線形ニューラルネットワーク

3.1.3. The Normal Distribution and Squared Loss3.1.3 正規分布と二乗損失

So far we have given a fairly functional motivation of the squared loss objective: the optimal parameters return the conditional expectation E[Y∣X] whenever the underlying pattern is truly linear, and the loss assigns large penalties for outliers. We can also provide a more formal motivation for the squared loss objective by making probabilistic assumptions about the distribution of noise.
英語のヒント
ここまでは、二乗損失という目的について、かなり実用的な動機づけをしてきた。元にあるパターンが本当に線形なら最適なパラメータは条件付き期待値E[Y∣X]を返し、損失は外れ値に大きな罰を割り当てる、というものである。ノイズの分布について確率的な仮定を置くことで、二乗損失という目的について、もっと形式的な動機づけもできる。
Linear regression was invented at the turn of the 19th century. While it has long been debated whether Gauss or Legendre first thought up the idea, it was Gauss who also discovered the normal distribution (also called the Gaussian). It turns out that the normal distribution and linear regression with squared loss share a deeper connection than common parentage.
英語のヒント
線形回帰は19世紀の変わり目に発明された。ガウスとルジャンドルのどちらが最初にこの考えを思いついたのかは長く議論されてきたが、正規分布(ガウス分布とも呼ばれる)も発見したのはガウスだった。正規分布と二乗損失による線形回帰は、生みの親が共通であること以上の深いつながりをもっていることがわかる。
To begin, recall that a normal distribution with mean μ and variance σ2 (standard deviation σ) is given as
英語のヒント
まず、平均μ、分散σ2(標準偏差σ)の正規分布は次で与えられることを思い出そう。
p(x)=12πσ2exp⁡(−12σ2(x−μ)2).(3.1.12)
Below we define a function to compute the normal distribution.
英語のヒント
下で、正規分布を計算する関数を定義する。
def normal(x, mu, sigma):
    p = 1 / math.sqrt(2 * math.pi * sigma**2)
    return p * np.exp(-0.5 * (x - mu)**2 / sigma**2)
We can now visualize the normal distributions.
英語のヒント
これで正規分布を可視化できる。
# Use NumPy again for visualization
x = np.arange(-7, 7, 0.01)

# Mean and standard deviation pairs
params = [(0, 1), (0, 2), (3, 1)]
d2l.plot(x, [normal(x, mu, sigma) for mu, sigma in params], xlabel='x',
         ylabel='p(x)', figsize=(4.5, 2.5),
         legend=[f'mean {mu}, std {sigma}' for mu, sigma in params])
Note that changing the mean corresponds to a shift along the x-axis, and increasing the variance spreads the distribution out, lowering its peak.
英語のヒント
平均を変えることはx軸に沿った平行移動に対応し、分散を大きくすると分布が広がって山が低くなることに注意してほしい。
One way to motivate linear regression with squared loss is to assume that observations arise from noisy measurements, where the noise ϵ follows the normal distribution 𝒩(0,σ2):
英語のヒント
二乗損失による線形回帰を動機づける一つの方法は、観測がノイズを含む測定から生じ、そのノイズϵが正規分布𝒩(0,σ2)に従うと仮定することである。
y=𝐰⊤𝐱+b+ϵ where ϵ∼𝒩(0,σ2).(3.1.13)
Thus, we can now write out the likelihood of seeing a particular y for a given 𝐱 via
英語のヒント
したがって、与えられた𝐱について特定のyを見る尤度を、次のように書き出せる。
P(y∣𝐱)=12πσ2exp⁡(−12σ2(y−𝐰⊤𝐱−b)2).(3.1.14)
As such, the likelihood factorizes. According to the principle of maximum likelihood, the best values of parameters 𝐰 and b are those that maximize the likelihood of the entire dataset:
英語のヒント
このように、尤度は因数分解できる。最尤の原理によれば、パラメータ𝐰とbの最良の値は、データセット全体の尤度を最大にするものである。
P(𝐲∣𝐗)=∏i=1np(y(i)∣𝐱(i)).(3.1.15)
The equality follows since all pairs (𝐱(i),y(i)) were drawn independently of each other. Estimators chosen according to the principle of maximum likelihood are called maximum likelihood estimators. While, maximizing the product of many exponential functions, might look difficult, we can simplify things significantly, without changing the objective, by maximizing the logarithm of the likelihood instead. For historical reasons, optimizations are more often expressed as minimization rather than maximization. So, without changing anything, we can minimize the negative log-likelihood, which we can express as follows:
英語のヒント
この等式が成り立つのは、すべての組(𝐱(i),y(i))が互いに独立に抽出されたからである。最尤の原理に従って選ばれた推定量を、最尤推定量という。多くの指数関数の積を最大にするのは難しく見えるかもしれないが、代わりに尤度の対数を最大にすることで、目的を変えずに物事を大きく簡単にできる。歴史的な理由から、最適化は最大化よりも最小化として表されることのほうが多い。そこで、何も変えずに、負の対数尤度を最小にすることにする。これは次のように表せる。
−log⁡P(𝐲∣𝐗)=∑i=1n12log⁡(2πσ2)+12σ2(y(i)−𝐰⊤𝐱(i)−b)2.(3.1.16)
If we assume that σ is fixed, we can ignore the first term, because it does not depend on 𝐰 or b. The second term is identical to the squared error loss introduced earlier, except for the multiplicative constant 1σ2. Fortunately, the solution does not depend on σ either. It follows that minimizing the mean squared error is equivalent to the maximum likelihood estimation of a linear model under the assumption of additive Gaussian noise.
英語のヒント
σが固定されていると仮定すれば、第1項は𝐰にもbにも依存しないので無視できる。第2項は、乗算の定数1σ2を除けば、先に紹介した二乗誤差損失と同じである。幸い、解はσにも依存しない。したがって、平均二乗誤差を最小にすることは、加法的なガウスノイズの仮定のもとでの線形モデルの最尤推定と同等である。