第22章付録:深層学習のための数学
22.11.1. Information22.11.1 情報
Let’s start with the “soul” of information theory: information. Information can be encoded in anything with a particular sequence of one or more encoding formats. Suppose that we task ourselves with trying to define a notion of information. What could be our starting point?
英語のヒント
情報理論の「魂」である情報から始めよう。情報は、一つ以上の符号化形式による特定の系列によって、何にでも符号化できる。情報という概念を定義しようと試みる仕事を自分たちに課したとしよう。出発点は何になりうるだろうか。
Consider the following thought experiment. We have a friend with a deck of cards. They will shuffle the deck, flip over some cards, and tell us statements about the cards. We will try to assess the information content of each statement.
英語のヒント
次の思考実験を考えよう。トランプを1組持った友人がいる。その友人はトランプを切り、何枚かのカードをめくり、カードについての言明を告げる。それぞれの言明の情報量を評価してみよう。
First, they flip over a card and tell us, “I see a card.” This provides us with no information at all. We were already certain that this was the case so we hope the information should be zero.
英語のヒント
まず、友人がカードを1枚めくって「カードが見える」と言う。これはまったく情報を与えない。それが事実であることはすでに確実だったので、情報は0であってほしい。
Next, they flip over a card and say, “I see a heart.” This provides us some information, but in reality there are only different suits that were possible, each equally likely, so we are not surprised by this outcome. We hope that whatever the measure of information, this event should have low information content.
英語のヒント
次に、友人がカードを1枚めくって「ハートが見える」と言う。これはいくらかの情報を与えるが、実際にはありうるスートは種類しかなく、それぞれ同じくらい起こりやすいので、この結果に驚きはしない。情報の尺度が何であれ、この事象の情報量は低いはずだと期待する。
Next, they flip over a card and say, “This is the of spades.” This is more information. Indeed there were equally likely possible outcomes, and our friend told us which one it was. This should be a medium amount of information.
英語のヒント
次に、友人がカードを1枚めくって「これはスペードのだ」と言う。これはもっと多くの情報である。実際、同じくらい起こりやすいありうる結果は通りあり、友人はそれがどれだったかを教えてくれた。これは中くらいの量の情報のはずである。
Let’s take this to the logical extreme. Suppose that finally they flip over every card from the deck and read off the entire sequence of the shuffled deck. There are different orders to the deck, again all equally likely, so we need a lot of information to know which one it is.
英語のヒント
これを論理的な極端まで進めよう。最後に、友人がトランプのすべてのカードをめくり、切られたトランプの系列全体を読み上げるとする。トランプの並び順は通りあり、やはりどれも同じくらい起こりやすいので、それがどれかを知るには多くの情報が必要である。
Any notion of information we develop must conform to this intuition. Indeed, in the next sections we will learn how to compute that these events have , , , and of information respectively.
英語のヒント
築く情報の概念はどんなものでも、この直観に合っていなければならない。実際、次の節では、これらの事象がそれぞれ、、、の情報をもつことを計算する方法を学ぶ。
If we read through these thought experiments, we see a natural idea. As a starting point, rather than caring about the knowledge, we may build off the idea that information represents the degree of surprise or the abstract possibility of the event. For example, if we want to describe an unusual event, we need a lot information. For a common event, we may not need much information.
英語のヒント
これらの思考実験を読み通すと、自然な考えが見えてくる。出発点として、知識を気にするのではなく、情報は事象の驚きの度合い、あるいは抽象的な可能性を表すという考えから築いていける。たとえば、珍しい事象を記述したいなら、多くの情報が必要である。ありふれた事象なら、あまり多くの情報は必要ないかもしれない。
In 1948, Claude E. Shannon published A Mathematical Theory of Communication (Shannon, 1948) establishing the theory of information. In his article, Shannon introduced the concept of information entropy for the first time. We will begin our journey here.
英語のヒント
1948年、クロード・E・シャノンは「通信の数学的理論」(Shannon, 1948)を発表し、情報の理論を確立した。その論文でシャノンは、情報エントロピーの概念を初めて導入した。ここから旅を始めよう。
22.11.1.1. Self-information22.11.1.1 自己情報量
Since information embodies the abstract possibility of an event, how do we map the possibility to the number of bits? Shannon introduced the terminology bit as the unit of information, which was originally created by John Tukey. So what is a “bit” and why do we use it to measure information? Historically, an antique transmitter can only send or receive two types of code: and . Indeed, binary encoding is still in common use on all modern digital computers. In this way, any information is encoded by a series of and . And hence, a series of binary digits of length contains bits of information.
英語のヒント
情報は事象の抽象的な可能性を体現しているので、その可能性をビット数にどう写せばよいだろうか。シャノンは、情報の単位としてビットという用語を導入した。この用語はもともとジョン・テューキーが作ったものである。では、「ビット」とは何で、なぜそれを使って情報を測るのだろうか。歴史的には、古い送信機はとの2種類の符号しか送受信できなかった。実際、二値の符号化は、現代のすべてのデジタルコンピュータで今も広く使われている。このようにして、どんな情報もとの系列で符号化される。したがって、長さの2進数字の系列はビットの情報を含む。
Now, suppose that for any series of codes, each or occurs with a probability of . Hence, an event with a series of codes of length , occurs with a probability of . At the same time, as we mentioned before, this series contains bits of information. So, can we generalize to a mathematical function which can transfer the probability to the number of bits? Shannon gave the answer by defining self-information
英語のヒント
さて、どんな符号の系列についても、各やが確率で現れるとする。すると、長さの符号の系列をもつ事象は確率で起きる。同時に、前に述べたように、この系列はビットの情報を含む。では、確率をビット数に変換できる数学的な関数へと一般化できるだろうか。シャノンは、自己情報量を次のように定義することで答えを与えた。
(22.11.1)
as the bits of information we have received for this event . Note that we will always use base-2 logarithms in this section. For the sake of simplicity, the rest of this section will omit the subscript 2 in the logarithm notation, i.e., always refers to . For example, the code “0010” has a self-information
英語のヒント
これを、この事象について受け取った情報のビット数とする。この節ではいつも底が2の対数を使うことに注意しよう。簡単にするため、この節の残りでは対数の記法で添字の2を省く。つまり、はいつもを指す。たとえば、符号「0010」の自己情報量は次のとおりである。
(22.11.2)
We can calculate self information as shown below. Before that, let’s first import all the necessary packages in this section.
英語のヒント
自己情報量は以下のように計算できる。その前に、まずこの節で必要なパッケージをすべてインポートしよう。
import torch
from torch.nn import NLLLoss
def nansum(x):
# Define nansum, as pytorch does not offer it inbuilt.
return x[~torch.isnan(x)].sum()
def self_information(p):
return -torch.log2(torch.tensor(p)).item()
self_information(1 / 64)6.0