第22章付録:深層学習のための数学
22.11.3. Mutual Information22.11.3 相互情報量
Previously we defined entropy of a single random variable , how about the entropy of a pair random variables ? We can think of these techniques as trying to answer the following type of question, “What information is contained in and together compared to each separately? Is there redundant information, or is it all unique?”
英語のヒント
前に一つの確率変数のエントロピーを定義したが、確率変数の組のエントロピーはどうだろうか。これらの技法は、次の種類の問いに答えようとするものと考えられる。「とを合わせたものには、それぞれ別々の場合と比べてどんな情報が含まれているか。冗長な情報があるのか、それともすべて固有の情報なのか」。
For the following discussion, we always use as a pair of random variables that follows a joint probability distribution with a p.d.f. or a p.m.f. , while and follow probability distribution and , respectively.
英語のヒント
以下の議論では、はいつも、p.d.f.あるいはp.m.f.をもつ同時確率分布に従う確率変数の組とし、とはそれぞれ確率分布とに従うとする。
22.11.3.1. Joint Entropy22.11.3.1 同時エントロピー
Similar to entropy of a single random variable (22.11.3), we define the joint entropy of a pair random variables as
英語のヒント
一つの確率変数のエントロピー(式(22.11.3))と同じように、確率変数の組の同時エントロピーを次のように定義する。
(22.11.9)
Precisely, on the one hand, if is a pair of discrete random variables, then
英語のヒント
正確には、一方で、が離散確率変数の組なら、
(22.11.10)
On the other hand, if is a pair of continuous random variables, then we define the differential joint entropy as
英語のヒント
他方で、が連続確率変数の組なら、微分同時エントロピーを次のように定義する。
(22.11.11)
We can think of (22.11.9) as telling us the total randomness in the pair of random variables. As a pair of extremes, if are two identical random variables, then the information in the pair is exactly the information in one and we have . On the other extreme, if and are independent then . Indeed we will always have that the information contained in a pair of random variables is no smaller than the entropy of either random variable and no more than the sum of both.
英語のヒント
式(22.11.9)は、確率変数の組の全体のランダムさを教えてくれるものと考えられる。両極端の例として、が二つの同一の確率変数なら、組の情報はちょうど一方の情報であり、となる。もう一方の極端では、とが独立ならとなる。実際、確率変数の組に含まれる情報は、どちらの確率変数のエントロピーよりも小さくなく、両者の和よりも多くないことがいつも成り立つ。
(22.11.12)
Let’s implement joint entropy from scratch.
英語のヒント
同時エントロピーをゼロから実装しよう。
def joint_entropy(p_xy):
joint_ent = -p_xy * torch.log2(p_xy)
# Operator `nansum` will sum up the non-nan number
out = nansum(joint_ent)
return out
joint_entropy(torch.tensor([[0.1, 0.5], [0.1, 0.3]]))tensor(1.6855)Notice that this is the same code as before, but now we interpret it differently as working on the joint distribution of the two random variables.
英語のヒント
これは前と同じコードだが、今度はそれを二つの確率変数の同時分布に作用するものとして違うふうに解釈していることに注意しよう。
22.11.3.2. Conditional Entropy22.11.3.2 条件付きエントロピー
The joint entropy defined above the amount of information contained in a pair of random variables. This is useful, but oftentimes it is not what we care about. Consider the setting of machine learning. Let’s take to be the random variable (or vector of random variables) that describes the pixel values of an image, and to be the random variable which is the class label. should contain substantial information—a natural image is a complex thing. However, the information contained in once the image has been show should be low. Indeed, the image of a digit should already contain the information about what digit it is unless the digit is illegible. Thus, to continue to extend our vocabulary of information theory, we need to be able to reason about the information content in a random variable conditional on another.
英語のヒント
上で定義した同時エントロピーは、確率変数の組に含まれる情報の量である。これは役に立つが、気にしているのはこれではないことが多い。機械学習の設定を考えよう。を画像の画素値を記述する確率変数(あるいは確率変数のベクトル)、をクラスラベルである確率変数としよう。はかなりの情報を含むはずである。自然な画像は複雑なものだからである。しかし、画像が示された後にに含まれる情報は少ないはずである。実際、数字の画像は、数字が判読できないのでないかぎり、それがどの数字かについての情報をすでに含んでいるはずである。したがって、情報理論の語彙を広げ続けるには、ある確率変数を別の確率変数で条件付けたときの情報量について推論できる必要がある。
In the probability theory, we saw the definition of the conditional probability to measure the relationship between variables. We now want to analogously define the conditional entropy . We can write this as
英語のヒント
確率論では、変数間の関係を測る条件付き確率の定義を見た。今度は、同じようにして条件付きエントロピーを定義したい。これは次のように書ける。
(22.11.13)
where is the conditional probability. Specifically, if is a pair of discrete random variables, then
英語のヒント
ここでは条件付き確率である。具体的には、が離散確率変数の組なら、
(22.11.14)
If is a pair of continuous random variables, then the differential conditional entropy is similarly defined as
英語のヒント
が連続確率変数の組なら、微分条件付きエントロピーも同様に次のように定義される。
(22.11.15)
It is now natural to ask, how does the conditional entropy relate to the entropy and the joint entropy ? Using the definitions above, we can express this cleanly:
英語のヒント
ここで、条件付きエントロピーが、エントロピーや同時エントロピーとどう関係するのかを問うのは自然である。上の定義を使うと、これをすっきり表せる。
(22.11.16)
This has an intuitive interpretation: the information in given () is the same as the information in both and together () minus the information already contained in . This gives us the information in which is not also represented in .
英語のヒント
これには直観的な解釈がある。が与えられたときのの情報()は、とを合わせた情報()から、すでにに含まれている情報を引いたものと同じである。これにより、には表されていない、の情報が得られる。
Now, let’s implement conditional entropy (22.11.13) from scratch.
英語のヒント
では、条件付きエントロピー(式(22.11.13))をゼロから実装しよう。
def conditional_entropy(p_xy, p_x):
p_y_given_x = p_xy/p_x
cond_ent = -p_xy * torch.log2(p_y_given_x)
# Operator `nansum` will sum up the non-nan number
out = nansum(cond_ent)
return out
conditional_entropy(torch.tensor([[0.1, 0.5], [0.2, 0.3]]),
torch.tensor([0.2, 0.8]))tensor(0.8635)22.11.3.3. Mutual Information22.11.3.3 相互情報量
Given the previous setting of random variables , you may wonder: “Now that we know how much information is contained in but not in , can we similarly ask how much information is shared between and ?” The answer will be the mutual information of , which we will write as .
英語のヒント
前の確率変数の設定が与えられると、「にはなくに含まれる情報がどれだけかがわかったのだから、同じように、との間でどれだけの情報が共有されているかを問えるのではないか」と疑問に思うかもしれない。その答えがの相互情報量であり、それをと書く。
Rather than diving straight into the formal definition, let’s practice our intuition by first trying to derive an expression for the mutual information entirely based on terms we have constructed before. We wish to find the information shared between two random variables. One way we could try to do this is to start with all the information contained in both and together, and then we take off the parts that are not shared. The information contained in both and together is written as . We want to subtract from this the information contained in but not in , and the information contained in but not in . As we saw in the previous section, this is given by and respectively. Thus, we have that the mutual information should be
英語のヒント
形式的な定義にすぐ飛び込むのではなく、まず、前に作った項だけにもとづいて相互情報量の式を導こうとすることで、直観を鍛えよう。二つの確率変数の間で共有される情報を見つけたい。これを試みる一つの方法は、との両方を合わせたものに含まれるすべての情報から始め、共有されていない部分を取り除くことである。との両方を合わせたものに含まれる情報はと書かれる。ここから、にはなくに含まれる情報と、にはなくに含まれる情報を引きたい。前の節で見たように、これらはそれぞれとで与えられる。したがって、相互情報量は次のようになるはずである。
(22.11.17)
Indeed, this is a valid definition for the mutual information. If we expand out the definitions of these terms and combine them, a little algebra shows that this is the same as
英語のヒント
実際、これは相互情報量の有効な定義である。これらの項の定義を展開して組み合わせると、少しの代数計算で、これが次と同じであることがわかる。
(22.11.18)
We can summarize all of these relationships in image Fig. 22.11.1. It is an excellent test of intuition to see why the following statements are all also equivalent to .
英語のヒント
これらの関係はすべて、図22.11.1の図にまとめられる。次の言明がなぜすべてとも同値なのかを確かめるのは、直観のすばらしいテストである。
Fig. 22.11.1図22.11.1
Mutual information’s relationship with joint entropy and conditional entropy.
英語のヒント
相互情報量と、同時エントロピーおよび条件付きエントロピーとの関係。
In many ways we can think of the mutual information (22.11.18) as principled extension of correlation coefficient we saw in Section 22.6. This allows us to ask not only for linear relationships between variables, but for the maximum information shared between the two random variables of any kind.
英語のヒント
多くの点で、相互情報量(式(22.11.18))は、22.6節で見た相関係数の原理にかなった拡張と考えられる。これにより、変数間の線形の関係だけでなく、任意の種類の二つの確率変数の間で共有される最大の情報を問える。
Now, let’s implement mutual information from scratch.
英語のヒント
では、相互情報量をゼロから実装しよう。
def mutual_information(p_xy, p_x, p_y):
p = p_xy / (p_x * p_y)
mutual = p_xy * torch.log2(p)
# Operator `nansum` will sum up the non-nan number
out = nansum(mutual)
return out
mutual_information(torch.tensor([[0.1, 0.5], [0.1, 0.3]]),
torch.tensor([0.2, 0.8]), torch.tensor([[0.75, 0.25]]))tensor(0.7195)22.11.3.4. Properties of Mutual Information22.11.3.4 相互情報量の性質
Rather than memorizing the definition of mutual information (22.11.18), you only need to keep in mind its notable properties:
英語のヒント
相互情報量の定義(式(22.11.18))を暗記するよりも、その注目すべき性質を心にとめておくだけでよい。
- Mutual information is symmetric, i.e., .
英語のヒント
相互情報量は対称である。つまりである。 - Mutual information is non-negative, i.e., .
英語のヒント
相互情報量は非負である。つまりである。 - if and only if and are independent. For example, if and are independent, then knowing does not give any information about and vice versa, so their mutual information is zero.
英語のヒント
となるのは、とが独立であるとき、かつそのときに限る。たとえば、とが独立なら、を知ってもについての情報は何も得られず、その逆も同じなので、相互情報量は0である。 - Alternatively, if is an invertible function of , then and share all information and
英語のヒント
あるいは、がの可逆な関数なら、とはすべての情報を共有し、次が成り立つ。(22.11.19)
22.11.3.5. Pointwise Mutual Information22.11.3.5 点ごとの相互情報量
When we worked with entropy at the beginning of this chapter, we were able to provide an interpretation of as how surprised we were with the particular outcome. We may give a similar interpretation to the logarithmic term in the mutual information, which is often referred to as the pointwise mutual information:
英語のヒント
この章の初めにエントロピーを扱ったときには、を、特定の結果にどれだけ驚いたかとして解釈できた。相互情報量の中の対数の項にも同じような解釈を与えられる。これは点ごとの相互情報量とよく呼ばれる。
(22.11.20)
We can think of (22.11.20) as measuring how much more or less likely the specific combination of outcomes and are compared to what we would expect for independent random outcomes. If it is large and positive, then these two specific outcomes occur much more frequently than they would compared to random chance (note: the denominator is which is the probability of the two outcomes were independent), whereas if it is large and negative it represents the two outcomes happening far less than we would expect by random chance.
英語のヒント
式(22.11.20)は、結果との特定の組み合わせが、独立なランダムな結果について予想されるのと比べて、どれだけ起こりやすいか、あるいは起こりにくいかを測るものと考えられる。それが大きく正なら、この二つの特定の結果は、ランダムな偶然と比べてはるかに頻繁に起きる(注:分母はであり、これは二つの結果が独立である場合の確率である)。一方、それが大きく負なら、二つの結果はランダムな偶然から予想されるよりもはるかに少なくしか起きないことを表す。
This allows us to interpret the mutual information (22.11.18) as the average amount that we were surprised to see two outcomes occurring together compared to what we would expect if they were independent.
英語のヒント
これにより、相互情報量(式(22.11.18))は、二つの結果がいっしょに起きるのを見て、それらが独立だった場合に予想されるのと比べて驚いた量の平均として解釈できる。
22.11.3.6. Applications of Mutual Information22.11.3.6 相互情報量の応用
Mutual information may be a little abstract in it pure definition, so how does it related to machine learning? In natural language processing, one of the most difficult problems is the ambiguity resolution, or the issue of the meaning of a word being unclear from context. For example, recently a headline in the news reported that “Amazon is on fire”. You may wonder whether the company Amazon has a building on fire, or the Amazon rain forest is on fire.
英語のヒント
相互情報量は、その純粋な定義では少し抽象的かもしれない。では、機械学習とどう関係するのだろうか。自然言語処理では、最も難しい問題の一つが曖昧性の解消、つまり単語の意味が文脈からはっきりしないという問題である。たとえば、最近、ニュースの見出しで「Amazon is on fire」と報じられた。Amazonという会社の建物が火事なのか、アマゾンの熱帯雨林が燃えているのか、疑問に思うかもしれない。
In this case, mutual information can help us resolve this ambiguity. We first find the group of words that each has a relatively large mutual information with the company Amazon, such as e-commerce, technology, and online. Second, we find another group of words that each has a relatively large mutual information with the Amazon rain forest, such as rain, forest, and tropical. When we need to disambiguate “Amazon”, we can compare which group has more occurrence in the context of the word Amazon. In this case the article would go on to describe the forest, and make the context clear.
英語のヒント
この場合、相互情報量がこの曖昧さを解消するのに役立つ。まず、電子商取引、技術、オンラインのような、それぞれがAmazonという会社と比較的大きな相互情報量をもつ単語のグループを見つける。次に、雨、森林、熱帯のような、それぞれがアマゾンの熱帯雨林と比較的大きな相互情報量をもつ別の単語のグループを見つける。「Amazon」の曖昧さを解消する必要があるときは、Amazonという単語の文脈の中でどちらのグループのほうが多く現れるかを比べればよい。この場合、記事は続けて森林について記述し、文脈をはっきりさせるだろう。