プリンキピア

第4章分類のための線形ニューラルネットワーク

4.1.5. Exercises4.1.5 練習問題

  1. We can explore the connection between exponential families and softmax in some more depth.
    英語のヒント
    指数型分布族とソフトマックスのつながりを、もう少し深く探ってみよう。
    1. Compute the second derivative of the cross-entropy loss l(𝐲,𝐲ˆ) for softmax.
      英語のヒント
      ソフトマックスについて、交差エントロピー損失l(𝐲,𝐲ˆ)の2階導関数を計算せよ。
    2. Compute the variance of the distribution given by softmax(𝐨) and show that it matches the second derivative computed above.
      英語のヒント
      softmax(𝐨)で与えられる分布の分散を計算し、それが上で計算した2階導関数と一致することを示せ。
  2. Assume that we have three classes which occur with equal probability, i.e., the probability vector is (13,13,13).
    英語のヒント
    同じ確率で起こる三つのクラスがあるとする。つまり、確率ベクトルは(13,13,13)である。
    1. What is the problem if we try to design a binary code for it?
      英語のヒント
      これに二進符号を設計しようとすると何が問題か。
    2. Can you design a better code? Hint: what happens if we try to encode two independent observations? What if we encode n observations jointly?
      英語のヒント
      よりよい符号を設計できるか。ヒント:二つの独立な観測を符号化しようとすると何が起きるか。n個の観測をまとめて符号化したらどうか。
  3. When encoding signals transmitted over a physical wire, engineers do not always use binary codes. For instance, PAM-3 uses three signal levels {−1,0,1} as opposed to two levels {0,1}. How many ternary units do you need to transmit an integer in the range {0,…,7}? Why might this be a better idea in terms of electronics?
    英語のヒント
    物理的な配線で送られる信号を符号化するとき、技術者はいつも二進符号を使うわけではない。たとえばPAM-3は、二つの水準{0,1}ではなく、三つの信号水準{−1,0,1}を使う。範囲{0,…,7}の整数を送るには、三進の単位がいくつ必要か。電子工学の観点で、これがよりよい考えでありうるのはなぜか。
  4. The Bradley–Terry model uses a logistic model to capture preferences. For a user to choose between apples and oranges one assumes scores oapple and oorange. Our requirements are that larger scores should lead to a higher likelihood in choosing the associated item and that the item with the largest score is the most likely one to be chosen (Bradley and Terry, 1952).
    英語のヒント
    ブラッドリー–テリーモデルは、ロジスティックモデルを使って好みをとらえる。利用者がリンゴとオレンジのどちらかを選ぶとき、得点oappleとoorangeを仮定する。要件は、得点が大きいほど対応する品物を選ぶ可能性が高くなること、そして最大の得点をもつ品物が最も選ばれやすいことである(Bradley and Terry, 1952)。
    1. Prove that softmax satisfies this requirement.
      英語のヒント
      ソフトマックスがこの要件を満たすことを証明せよ。
    2. What happens if you want to allow for a default option of choosing neither apples nor oranges? Hint: now the user has three choices.
      英語のヒント
      リンゴもオレンジも選ばないという既定の選択肢を許したいとしたら、どうなるか。ヒント:今度は利用者に選択肢が三つある。
  5. Softmax gets its name from the following mapping: RealSoftMax(a,b)=log⁡(exp⁡(a)+exp⁡(b)).
    英語のヒント
    ソフトマックスという名前は、次の写像RealSoftMax(a,b)=log⁡(exp⁡(a)+exp⁡(b))に由来する。
    1. Prove that RealSoftMax(a,b)>max(a,b).
      英語のヒント
      RealSoftMax(a,b)>max(a,b)を証明せよ。
    2. How small can you make the difference between both functions? Hint: without loss of generality you can set b=0 and a≥b.
      英語のヒント
      両方の関数の差をどれほど小さくできるか。ヒント:一般性を失うことなく、b=0かつa≥bとしてよい。
    3. Prove that this holds for λ−1RealSoftMax(λa,λb), provided that λ>0.
      英語のヒント
      λ>0であれば、これがλ−1RealSoftMax(λa,λb)についても成り立つことを証明せよ。
    4. Show that for λ→∞ we have λ−1RealSoftMax(λa,λb)→max(a,b).
      英語のヒント
      λ→∞のとき、λ−1RealSoftMax(λa,λb)→max(a,b)となることを示せ。
    5. Construct an analogous softmin function.
      英語のヒント
      同様のソフトミン関数を作れ。
    6. Extend this to more than two numbers.
      英語のヒント
      これを三つ以上の数に拡張せよ。
  6. The function g(𝐱)=deflog⁡∑iexp⁡xi is sometimes also referred to as the log-partition function.
    英語のヒント
    関数g(𝐱)=deflog⁡∑iexp⁡xiは、対数分配関数と呼ばれることもある。
    1. Prove that the function is convex. Hint: to do so, use the fact that the first derivative amounts to the probabilities from the softmax function and show that the second derivative is the variance.
      英語のヒント
      この関数が凸であることを証明せよ。ヒント:そのためには、1階導関数がソフトマックス関数の確率になることを使い、2階導関数が分散であることを示せ。
    2. Show that g is translation invariant, i.e., g(𝐱+b)=g(𝐱).
      英語のヒント
      gが平行移動に対して不変であること、つまりg(𝐱+b)=g(𝐱)であることを示せ。
    3. What happens if some of the coordinates xi are very large? What happens if they’re all very small?
      英語のヒント
      座標xiの一部がとても大きいと何が起きるか。すべてがとても小さいとどうなるか。
    4. Show that if we choose b=maxixi we end up with a numerically stable implementation.
      英語のヒント
      b=maxixiを選べば、数値的に安定した実装になることを示せ。
  7. Assume that we have some probability distribution P. Suppose we pick another distribution Q with Q(i)∝P(i)α for α>0.
    英語のヒント
    何らかの確率分布Pがあるとする。α>0についてQ(i)∝P(i)αとなる、別の分布Qを選ぶとしよう。
    1. Which choice of α corresponds to doubling the temperature? Which choice corresponds to halving it?
      英語のヒント
      αをどう選べば、温度を2倍にすることに対応するか。どう選べば半分にすることに対応するか。
    2. What happens if we let the temperature approach 0?
      英語のヒント
      温度を0に近づけると何が起きるか。
    3. What happens if we let the temperature approach ∞?
      英語のヒント
      温度を∞に近づけると何が起きるか。