# Seq2Seq with Attention ==ここからが本番!!== いよいよ ==Attention== の登場 ## 過去回 [第1回:NLP Outline](https://hackmd.io/uD2hEISAShqVHD6IRtceUw) [第2回:Word2Vec](https://hackmd.io/T2QJsuwsROSQluklguDOow) [第3回:Doc2Vec](https://hackmd.io/LIT2hp_jQ56Dvn-imOVemg) [第4回:Seq2Seq](https://hackmd.io/UGLHXO6-RweY_Bys2Dp4mA) ## 要点 * **Seq2Seq の Encoder のRNN隠れ層を全て Decoder のRNN隠れ層と連結させる** * **Decoder のRNN隠れ層に対する関連度(weight)を計算し、そのベクトルを加える** ## Seq2Seq の弱点 * 文章が長くなると、初めの情報が失われる  上図の通り、EncoderでのHidden層の出力は、次の時系列への入力には使っているが、実質的にはDecoder側に入力されておらず、使っていない。勿体ないからこれらも使ってみようというのがAttention. ## Seq2Seq Attention 元祖Attention. Transformer の Attention のベースである。考え方は同じ 1. Encoder の隠れ層を全て使う  2. 内積を計算し、Softmaxで規格化する. 規格化した値は==Attention weight==と呼ばれるものである  3. Encoder の隠れ層を再びもってきて、Attention Weightと掛ける。  4. 全てのベクトルを足す。これは、==Context vector==と呼ばれるものである  5. Decoderの隠れ層にくっつけて、学習を進める  全体でまとめるとこう  Attention で出てくる Query, Key, Value はこうなる  ## Seq2Seq Attention の弱点 精度は良くなったが、言語の長さだけSequentialな計算を行う必要がある。 つまり、==並列計算できない== ## Transformer へ... * 並列計算できないならRNNをなくしちゃおう! * Attentionは非常に強力だよ!
×
Sign in
Email
Password
Forgot password
or
By clicking below, you agree to our
terms of service
.
Sign in via Facebook
Sign in via Twitter
Sign in via GitHub
Sign in via Dropbox
Sign in with Wallet
Wallet (
)
Connect another wallet
New to HackMD?
Sign up