第22章付録:深層学習のための数学
22.7.1. The Maximum Likelihood Principle22.7.1 最尤原理
This has a Bayesian interpretation which can be helpful to think about. Suppose that we have a model with parameters and a collection of data examples . For concreteness, we can imagine that is a single value representing the probability that a coin comes up heads when flipped, and is a sequence of independent coin flips. We will look at this example in depth later.
英語のヒント
これには、考えるのに役立つベイズ的な解釈がある。パラメータをもつモデルと、データの例の集まりがあるとする。具体的にするため、はコインを投げたときに表が出る確率を表す一つの値であり、は独立なコイン投げの系列だと想像できる。この例は後で詳しく見る。
If we want to find the most likely value for the parameters of our model, that means we want to find
英語のヒント
モデルのパラメータについて最も尤もらしい値を見つけたいなら、次を見つけたいということである。
(22.7.1)
By Bayes’ rule, this is the same thing as
英語のヒント
ベイズの規則により、これは次と同じである。
(22.7.2)
The expression , a parameter agnostic probability of generating the data, does not depend on at all, and so can be dropped without changing the best choice of . Similarly, we may now posit that we have no prior assumption on which set of parameters are better than any others, so we may declare that does not depend on theta either! This, for instance, makes sense in our coin flipping example where the probability it comes up heads could be any value in without any prior belief it is fair or not (often referred to as an uninformative prior). Thus we see that our application of Bayes’ rule shows that our best choice of is the maximum likelihood estimate for :
英語のヒント
データを生成する、パラメータによらない確率である式は、にまったく依存しないので、の最善の選択を変えずに落とせる。同様に、どのパラメータの組がほかより優れているかについて事前の仮定はないと置けるので、もθに依存しないと宣言できる。これはたとえば、表が出る確率が、コインが公正かどうかについての事前の信念なしにのどんな値でもありうる(よく無情報事前分布と呼ばれる)コイン投げの例では理にかなっている。したがって、ベイズの規則を適用すると、の最善の選択はの最尤推定値であることがわかる。
(22.7.3)
As a matter of common terminology, the probability of the data given the parameters () is referred to as the likelihood.
英語のヒント
よく使われる用語の問題として、パラメータが与えられたときのデータの確率()は尤度と呼ばれる。
22.7.1.1. A Concrete Example22.7.1.1 具体例
Let’s see how this works in a concrete example. Suppose that we have a single parameter representing the probability that a coin flip is heads. Then the probability of getting a tails is , and so if our observed data is a sequence with heads and tails, we can use the fact that independent probabilities multiply to see that
英語のヒント
これが具体例でどう働くかを見よう。コイン投げで表が出る確率を表す一つのパラメータがあるとする。すると、裏が出る確率はであり、観測データが表回と裏回からなる系列なら、独立な確率は掛け合わされるという事実を使って、次がわかる。
(22.7.4)
If we flip coins and get the sequence “HHHTHTTHHHHHT”, which has and , we see that this is
英語のヒント
枚のコインを投げて「HHHTHTTHHHHHT」という系列を得たとすると、これは、なので、次のようになる。
(22.7.5)
One nice thing about this example will be that we know the answer going in. Indeed, if we said verbally, “I flipped 13 coins, and 9 came up heads, what is our best guess for the probability that the coin comes us heads?,” everyone would correctly guess . What this maximum likelihood method will give us is a way to get that number from first principals in a way that will generalize to vastly more complex situations.
英語のヒント
この例のよいところの一つは、答えが最初からわかっていることである。実際、「13枚のコインを投げて9枚が表になった。コインが表になる確率の最善の推測は何か」と口で言えば、だれもが正しくと推測するだろう。この最尤法が与えてくれるのは、その数を第一原理から得る方法であり、それははるかに複雑な状況へと一般化できる。
For our example, the plot of is as follows:
英語のヒント
この例では、のプロットは次のとおりである。
%matplotlib inline
import torch
from d2l import torch as d2l
theta = torch.arange(0, 1, 0.001)
p = theta**9 * (1 - theta)**4.
d2l.plot(theta, p, 'theta', 'likelihood')This has its maximum value somewhere near our expected . To see if it is exactly there, we can turn to calculus. Notice that at the maximum, the gradient of the function is flat. Thus, we could find the maximum likelihood estimate (22.7.1) by finding the values of where the derivative is zero, and finding the one that gives the highest probability. We compute:
英語のヒント
これは、期待したの近くのどこかで最大値をとる。ちょうどそこなのかを確かめるため、微積分に頼れる。最大値では関数の勾配が平らになることに注意しよう。したがって、導関数が0になるの値を見つけ、その中で最も高い確率を与えるものを見つけることで、最尤推定値(式(22.7.1))を見つけられる。次のように計算する。
(22.7.6)
This has three solutions: , and . The first two are clearly minima, not maxima as they assign probability to our sequence. The final value does not assign zero probability to our sequence, and thus must be the maximum likelihood estimate .
英語のヒント
これには、、の三つの解がある。最初の二つは系列に確率を割り当てるので、明らかに最大値ではなく最小値である。最後の値は系列に0の確率を割り当てないので、最尤推定値でなければならない。