プリンキピア

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

3.4.6. Exercises3.4.6 練習問題

  1. What would happen if we were to initialize the weights to zero. Would the algorithm still work? What if we initialized the parameters with variance 1000 rather than 0.01?
    英語のヒント
    重みをゼロに初期化したら何が起きるか。アルゴリズムはそれでも動くか。分散を0.01ではなく1000にしてパラメータを初期化したらどうか。
  2. Assume that you are Georg Simon Ohm trying to come up with a model for resistance that relates voltage and current. Can you use automatic differentiation to learn the parameters of your model?
    英語のヒント
    あなたがゲオルク・ジーモン・オームで、電圧と電流を関係づける抵抗のモデルを考え出そうとしているとする。自動微分を使って、モデルのパラメータを学習できるか。
  3. Can you use Planck’s Law to determine the temperature of an object using spectral energy density? For reference, the spectral density B of radiation emanating from a black body is B(λ,T)=2hc2λ5⋅(exp⁡hcλkT−1)−1. Here λ is the wavelength, T is the temperature, c is the speed of light, h is Planck’s constant, and k is the Boltzmann constant. You measure the energy for different wavelengths λ and you now need to fit the spectral density curve to Planck’s law.
    英語のヒント
    プランクの法則を使って、分光エネルギー密度から物体の温度を求められるか。参考までに、黒体から放たれる放射の分光密度BはB(λ,T)=2hc2λ5⋅(exp⁡hcλkT−1)−1である。ここでλは波長、Tは温度、cは光の速さ、hはプランク定数、kはボルツマン定数である。異なる波長λについてエネルギーを測定したので、分光密度の曲線をプランクの法則に当てはめる必要がある。
  4. What are the problems you might encounter if you wanted to compute the second derivatives of the loss? How would you fix them?
    英語のヒント
    損失の2階導関数を計算したいとき、どんな問題に出会うかもしれないか。それをどう直すか。
  5. Why is the reshape method needed in the loss function?
    英語のヒント
    loss関数でreshapeメソッドが必要なのはなぜか。
  6. Experiment using different learning rates to find out how quickly the loss function value drops. Can you reduce the error by increasing the number of epochs of training?
    英語のヒント
    異なる学習率を使って実験し、損失関数の値がどれほど速く下がるかを調べよ。訓練のエポック数を増やして誤差を減らせるか。
  7. If the number of examples cannot be divided by the batch size, what happens to data_iter at the end of an epoch?
    英語のヒント
    事例の数がバッチの大きさで割り切れないとき、エポックの終わりにdata_iterはどうなるか。
  8. Try implementing a different loss function, such as the absolute value loss (y_hat - d2l.reshape(y, y_hat.shape)).abs().sum().
    英語のヒント
    絶対値損失(y_hat - d2l.reshape(y, y_hat.shape)).abs().sum()のような、別の損失関数を実装してみよ。
    1. Check what happens for regular data.
      英語のヒント
      通常のデータで何が起きるかを確かめよ。
    2. Check whether there is a difference in behavior if you actively perturb some entries, such as y5=10000, of 𝐲.
      英語のヒント
      𝐲のいくつかの成分、たとえばy5=10000を積極的に乱すと、振る舞いに違いがあるかを確かめよ。
    3. Can you think of a cheap solution for combining the best aspects of squared loss and absolute value loss? Hint: how can you avoid really large gradient values?
      英語のヒント
      二乗損失と絶対値損失のいちばんよいところを組み合わせる安上がりな解決策を考えられるか。ヒント:本当に大きな勾配の値をどう避けられるか。
  9. Why do we need to reshuffle the dataset? Can you design a case where a maliciously constructed dataset would break the optimization algorithm otherwise?
    英語のヒント
    データセットを再シャッフルする必要があるのはなぜか。そうしなかった場合に、悪意をもって構成したデータセットが最適化アルゴリズムを壊すような場合を設計できるか。