LoginSignup
0
0

More than 1 year has passed since last update.

『ゼロから作るDeepLearning 2』メモ

Last updated at Posted at 2021-05-08

前回

p.31 MatMulノード

$\dfrac{\partial y_i}{\partial x_i} = W_{ij}$ となるのは、 $z=xy$ の乗算の逆伝播で $\dfrac{\partial z}{\partial x} = y$ となるのと同じ。

p.72 共起行列

def create_co_matrix(corpus, vocab_size, window_size=1):
    corpus_size = len(corpus) # 8
    co_matrix = np.zeros((vocab_size, vocab_size), dtype=np.int32)

    for idx, word_id in enumerate(corpus):
        for i in range(1, window_size + 1):
            left_idx = idx - i
            right_idx = idx + i

            if left_idx >= 0:
                left_word_id = corpus[left_idx]
                co_matrix[word_id, left_word_id] += 1

            if right_idx < corpus_size:
                right_word_id = corpus[right_idx]
                co_matrix[word_id, right_word_id] += 1

    return co_matrix

print(create_co_matrix([0, 1, 2, 3, 4, 1, 5, 6], 7))

# [[0 1 0 0 0 0 0]
#  [1 0 1 0 1 1 0]
#  [0 1 0 1 0 0 0]
#  [0 0 1 0 1 0 0]
#  [0 1 0 1 0 0 0]
#  [0 1 0 0 0 0 1]
#  [0 0 0 0 0 1 0]]

p.74 類似単語のランキング表示

コサイン類似度が高い = ウィンドウサイズ内に現れる同じ単語の数が多い

p.81 次元削減

p.84 SVDによる次元削減

>>> import numpy as np
>>> x = np.arange(1, 11).reshape(2, 5)
>>> print(x)
[[ 1  2  3  4  5]
 [ 6  7  8  9 10]]
>>> print(x[:, 1])
[2 7]
>>> print(x[:, 3])
[4 9]

p.103 CBOWモデルの推論処理

図3-10は図3-8のWと等しく、抜き出されるから各単語の重みとなっており、それを各単語の分散表現という

p.150 多値分類から二値分類へ(実装編)

sayを抜き出すならidxは複数いらなくない?

p.186 ループの展開

p.202 Time RNNレイヤの実装

p.303 Decoderクラス

図7-19の入力は教師データとして与えられており、図7-11の出力を想定している

p.369 Transformer

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0