Upgrade to Pro — share decks privately, control downloads, hide ads and more …

handout of RNN camp #2

Shin Asakawa
September 10, 2016

handout of RNN camp #2

Shin Asakawa

September 10, 2016
Tweet

More Decks by Shin Asakawa

Other Decks in Science

Transcript

  1. ご注意 • TensorFlow 0.10 から RNN パッケージは tf.models.rnn から tf.nn

    に移動しまし た。tf.nn.rnn_cell 以下にあるファイルを 使ってください。 • TensorFlow 0.10 moved the recurrent network operations from tf.models.rnn into the tf.nn package where they live along the other neural network operations now. Cells can now be found in tf.nn.rnn_cell.
  2. (やや古い)リンク集 • Olah さんのブログ,2015年の一時期ほぼ世界中の人が彼女のブログで紹介されている RNN の 仕組みを話題にしていた。http://colah.github.io/posts/2015-08-Understanding-LSTMs/ • WildML の

    Python/Theano チュートリアルも定評がある。http://www.wildml.com/2015/09/recurrent- neural-networks-tutorial-part-1-introduction-to-rnns/ • Cho さんは Nividia の記事として投稿。GRU の発案者だし,NLP, NMT の第一人者なので説得力 がある。 https://devblogs.nvidia.com/parallelforall/introduction-neural-machine-translation-with-gpus/ • Danijar Hafner さんは TensorFlow に特化したチュートリアル https://danijar.com/introduction-to- recurrent-networks-in-tensorflow/ • Jiwon Kim さんと Myungsub Choi さんが管理している GitHub 上の awesome RNN https://github.com/kjw0612/awesome-rnn本当に awesome! • Karpathy のブログ
  3. h0 y0 x0 h1 y1 x1 Digits subscripted indicate time

    t:= 0... 下付き添字は時刻を表す。 カッコで表記する流儀もある (e.g. x(t))
  4. デカルトの劇場 Cartesian Theater デカルトの劇場 wikipedia より Consciousness Explained, D. Dennet(1991)

    「解明される意識」 (1997) デネット著, 山口(訳) ホムンクルス 問題の本質 的解決
  5. h0 y0 x0 h1 y1 x1 h1 y1 x1 h2

    y2 x2 h3 y3 x3 h4 y4 x4 h4 y4 x4 h5 y5 x5 https://github.com/ShinAsakawa/rnncamp2
  6. h0 y0 x0 h1 y1 x1 h1 y1 x1 h2

    y2 x2 h3 y3 x3 h4 y4 x4 h4 y4 x4 h5 y5 x5 teacher error Loss(t,y) Wh Wh Wh Wh Wh
  7. h0 y0 x0 h1 y1 x1 h1 y1 x1 h2

    y2 x2 h3 y3 x3 h4 y4 x4 h4 y4 x4 h5 y5 x5 teacher error Loss(t,y) Wh Wh Wh Wh Wh
  8. h0 y0 x0 h1 y1 x1 h1 y1 x1 h2

    y2 x2 h3 y3 x3 h4 y4 x4 h4 y4 x4 h5 y5 x5 teacher error Loss(t,y) Wh Wh Wh Wh Wh
  9. h0 y0 x0 h1 y1 x1 h1 y1 x1 h2

    y2 x2 h3 y3 x3 h4 y4 x4 h4 y4 x4 h5 y5 x5 teacher error Loss(t,y) Wh Wh Wh Wh Wh teacher
  10. h0 y0 x0 h1 y1 x1 h1 y1 x1 h2

    y2 x2 h3 y3 x3 h4 y4 x4 h4 y4 x4 h5 y5 x5 teacher error Loss(t,y) Wh Wh Wh Wh Wh
  11. 完全(Full) BPTT h0 y0 x0 h1 y1 x1 h1 y1

    x1 h2 y2 x2 h3 y3 x3 h4 y4 x4 h4 y4 x4 h5 y5 x5 teacher error Loss(t,y) Wh Wh Wh Wh Wh
  12. 切断(trancated) BPTT(window width=5) ht+0 yt+0 xt+0 h1 y1 x1 ht+1

    yt+1 xt+1 ht+2 yt+2 xt+2 ht+3 yt+3 xt+3 h4 y4 x4 ht+4 yt+4 xt+4 ht+5 yt+5 xt+5 teacher error Loss(t,y) Wh Wh Wh Wh Wh
  13. ゲートの導入 introducing gates to control hidden state h t-1 y

    t-1 x t-1 h1 y1 x1 h t y t x t gate でも, なぜゲート? Why gates?
  14. 忘却ゲートの導入 ht-1 yt-1 xt-1 h1 y1 x1 ht yt xt

    gate Who can control gates? 誰がどうやって ゲート制御?
  15. 忘却ゲートの導入 ht-1 yt-1 xt-1 h1 y1 x1 ht yt xt

    gate Who can control gates? 誰がどうやって ゲート制御? Who can tell me how can I control myself?
  16. 忘却ゲートの導入 ht yt xt h1 y1 x1 ht+1 yt+1 xt+1

    gate who can control gates? 誰がどうやって ゲートを制御? 3つ候補
  17. 忘却ゲートの導入 ht yt xt h1 y1 x1 ht+1 yt+1 xt+1

    gate who can control gates? 誰がどうやって ゲートを制御? 3つ候補 1. ht
  18. It’s me 忘却ゲートの導入 ht yt xt h1 y1 x1 ht+1

    yt+1 xt+1 gate who can control gates? 誰がどうやって ゲートを制御? 3つ候補 1. ht
  19. Me, too 忘却ゲートの導入 ht yt xt h1 y1 x1 ht+1

    yt+1 xt+1 gate who can control gates? 誰がどうやって ゲートを制御? 3つ候補 1. ht 2. yt
  20. I can, too 忘却ゲートの導入 ht yt xt h1 y1 x1

    ht+1 yt+1 xt+1 gate who can control gates? 誰がどうやって ゲートを制御? 3つ候補 1. ht 2. yt 3. x t+1
  21. 忘却ゲートの導入 ht yt xt h1 y1 x1 ht+1 yt+1 xt+1

    gate ゲート制御 1. ht 2. yt 3. x t+1 ht+1 = ht s(x) • s(x) = (1+e-x)-1 • x = Wf (yt + ht + xt+1)
  22. 入力ゲートの導入 ht yt xt ht+1 yt+1 xt+1 gate gate h

    t+1 = h t s(w(ht + x t+1 )) • s(x) = (1+e-x)-1 • x = yt + ht + xt+1
  23. 出力ゲートの導入 ht yt xt ht+1 yt+1 xt+1 gate gate gate

    ht+1 = ht s(w(ht + x t+1 + y t+1 )) • s(x) = (1+e-x)-1 • x = yt + ht + xt+1
  24. LSTM + + + + 忘却ゲート 入力ゲート ブロックへの入力 セル +

    出力ゲート ピープホール ブロックからの出力 g h 入力 再帰入力 入力 再帰入力 入力 再帰入力 入力 再帰入力 出力 再帰入力へ 1.0 g c i f y o • 入力ゲート i = s ( ) • 忘却ゲート f = s ( ) • 出力ゲート o = s ( ) • 入力全体 g = f ( ) • セル c = f @ c + i @ g • 出力 y = o @ f ( ) https://github.com/ShinAsakawa/rnncamp2
  25. LSTM + + + + 忘却ゲート 入力ゲート ブロックへの入力 セル +

    出力ゲート ピープホール ブロックからの出力 g h 入力 再帰入力 入力 再帰入力 入力 再帰入力 入力 再帰入力 出力 再帰入力へ 1.0 g c i f y o
  26. How does LSTM work? 1. LSTM replaces logistic or tanh

    hidden units with “memory cells” that can store an analog value. 2. Each memory cell has its own input and output gates that control. 3. There is a forget gate which the analog value stored in the memory cell decays. 4. For periods when the input and output gates are off and the forget gate is not causing decay, a memory cell simply holds its value over time. Le, Jaitly, & Hinton (2015)
  27. 別モデル GRU(An alternative of the LSTM) h ~ h x

    y r: reset gate input output uupdate gate u t = s (W u + u u ) h t = f (W h + u h (u t @ ) r t = s (W r + u r h t-1 ) tilde(h) = (1- r t ) h t + r t tilde(h t-1 ) y t = W y tilde(h t )
  28. 別モデル GRU(An alternative of the LSTM) h ~ h x

    y r: reset gate input output uupdate gate ut = σ (Wu xt + Uu ht−1 ) . ht = ϕ(Wxt + Uh (ut ⊙ht−1 )) , rt = σ (Wr xt + Ur ht−1 ) , ˜ ht = ( 1 − rt) ht + rt ˜ ht−1 , yt = Wy ˜ ht
  29. 深層 LSTM (Depth Gated LSTM) ht− 1 ( a ) 直 前

    ( b ) 生 成 ( c ) 再 帰 ( d ) 推 論 ( e ) 全関与 ht zt xt ht− 1 ht zt xt ht− 1 ht zt xt ht− 1 ht zt xt ht− 1 ht zt xt 図 4.31 種々の LSTM 変種
  30. Pascanu (2014) より y( t ) h( t ) h(

    t − 1) x ( t ) y( t ) h( t ) h( t − 1) x ( t ) y( t ) h( t ) h( t − 1) x ( t ) ( a ) ( b ) ( c ) y( t ) h( t ) h( t − 1) x ( t ) y( t ) h( t − 1) x ( t ) z( t ) z( t ) h( t ) ( d ) ( e ) 図 4.27 パスカヌらの文献 108) の図 2 を改変
  31. Pascanu (2014) より するセルどうしをつないで 2 次元格子状,3 次元格子状に配列することを提案 している。 図 4.33

    はコウトニック(J.Koutonik)の時計状 LSTM である116) 。 I * xi m h m ′1 h′1 m ′2 h′2 m 1 h1 m 2 h2 m ′ h′ h′ 2 次元格子状 LSTM ブロック 標準の LSTM ブロック 1 次元格子状 LSTM ブロック 3 次元格子状 LSTM ブロック 図 4.32 格 子 状 LSTM 出力層