๐ง๐ป๐ป์ฉ์ด ์ ๋ฆฌ
Neural Networks
RNN
LSTM
Attention
CNN
Sequential Data Modeling
- Sequential Data
- Most of data are sequential
- Speech, Text, Image, ...
- Deep Learnings for Sequential Data
- Convolutional Neural Networks (CNN)
- Try to find local features from a sequence
- Recurrent Neural Networks : LSTM, GRU
- Try to capture the feature of the past
- Convolutional Neural Networks (CNN)
์ง๊ธ๊น์ง ์ ๋ ฅ์ ๋ํด ์ดํด๋ณด์์ฃ .
๊ทธ๋ฐ๋ฐ, ๊ทธ ์ ๋ ฅ์ ๋ํด์ ๋ค output์ด ์กด์ฌํฉ๋๋ค.
์ฐ๋ฆฌ๋ ๊ทธ output์ ์ฐ๋ฆฌ๊ฐ ์ํ๋๋๋ก ์ฌ์ฉํ ์๋ ์์ต๋๋ค.
๊ทธ๋์ ์๋์ ๊ฐ์ Task์ ์ฌ์ฉ๋ ์ ์์ต๋๋ค.
๊ทธ๋์ ์๋์ ๊ฐ์ Sequence Generation์ task๋ ์ฐ๋ฆฌ๊ฐ ํ์ด๋ณผ ์ ์์ต๋๋ค.
Sequence๊ฐ ๋์ค๋ฉด Sequence๋ฅผ ๋ฑ๋ ํ์์ ๋๋ค.
์ฐ๋ฆฌ๋ ๋ค์๊ณผ ๊ฐ์ ์ข ๋ฅ์ Task๋ก ๊ตฌ๋ถํ ์ ์์ต๋๋ค.
- One to Many
- Image Captioning
- Image -> Sequence of words
- caption model
- Many to One
- Sentiment Classification
- sentence -> sentiment
- classification ๋ชจ๋ธ
- encoder์์ ๋ง์ด, ์ฃผ์ด์ง ๊ฒ์ผ๋ก output์ ๋ง๋ ๋ค.
- input์ ์ด๋ฏธ ์๋ ๊ฐ.
- Many to Many
- Machine Translation
- sentence -> sentence
- ๋ฒ์ญ ๋ชจ๋ธ
- decoder๋ ์์ธกํ ๊ฒ์ ๋งค time ๋ง๋ค ์๋ก์ด ๊ฒ์ ๊ฐ์ง๊ณ ๋ฃ์ด์ ์์ ์จ์ผํ๋ ๊ฒ์.
- synched Many to Many
- Stock Price Prediction
- Prediction of next word
- language model
- ๋ฐ๋ก ๋ฐ๋ก ๋ค์ ๋ฌธ์ฅ ์์ธกํ๋ language model
๋ค์๊ณผ ๊ฐ์ ๋ชจ๋ธ์ด ์๋ค๊ณ ๋ด ์๋ค.
๋ค์์ ์ด๋ค ๋ชจ๋ธ์ผ๊น์?
Many to Many ์ ๋๋ค.
๊ทธ๋ฆฌ๊ณ ์ฐ๋ฆฌ๋ ์ ๋ต์ ์๊ณ ์์ผ๋, ์์ธก๊ฐ๊ณผ ์ค์ ๊ฐ ์ฌ์ด์ MSE๋ฅผ ์ฌ์ฉํฉ๋๋ค.
๊ทธ๋ฆฌ๊ณ , ๊ฐ๊ฐ์ ๋ํด MSE๋ฅผ ์ ์ฉํฉ๋๋ค.
๊ทธ๋ ๋ค๋ฉด Testํ ๋๋ ์ด๋ป๊ฒ ํ ๊น์?
training์ ์ ๋ ฅ ๋ค์ ๋ญ๊ฐ ์ค๋์ง ์์ง๋ง, Test๋ ์์ง ๋ชปํฉ๋๋ค.
๊ณ์ํด์ ์์ธกํ์ฌ ์ ๋ ฅ์ผ๋ก ๋ค์ ๋ฃ๊ณ , ์์ธกํ์ฌ ๋ฃ๊ณ ๋ฅผ ๋ฐ๋ณตํฉ๋๋ค.
๊ทธ๋์ Training๊ณผ Test๋ ๊ตฌ์กฐ๊ฐ ๋ค๋ฅด๋ค๋ ๊ฒ์ ์ ์ ์์ต๋๋ค.
Many to One
classification์์ ์ด๋จ๊น์?
๊ธ์ /๋ถ์ ์ ์์ ๊ฐ์ด ๋ง์ง๋ง์์ ์์ธกํ๋๋ก ํฉ๋๋ค.
๊ทธ๋ฆฌ๊ณ ,
Many to Many
๋ฒ์ญ ๋ชจ๋ธ์ ๋ชจ๋ ์ ๋ ฅ์ ์๊ณ ์์ต๋๋ค.
๊ทธ๋ ๋ค๋ฉด, ๋ช ๊ฐ์ ๋จ์ด๋ฅผ ๋ฃ๊ณ , ๊ทธ๊ฒ์ ๋ํ output์ด ๋์ค๋๋ก ํ์ตํฉ๋๋ค.
๋ค์ ํ๋์ฉ ์ดํด๋ด ๋๋ค.
- One to Many
- Caption Generation
- Image is represented by a CNN
- Word Embedding at the input layer
- Softmax at the output layer
- Caption Generation
encoder์ decoder๋ฅผ ์ ์ดํด๋ด ์๋ค.
encoder๋ ์ฐ๋ฆฌ๊ฐ ๊ฐ์ง ์ฃผ์ด์ง input์ ๊ฐ์ง๊ณ output์ ๋ง์ถ๋ ๊ฒ์ ๋๋ค.
decoder๋ ์์ธกํ ๊ฒ์ธ output์ ๊ฐ์ง๊ณ ๋งค time๋ง๋ค ๋ค์ ๋ฃ์ด์ ์๋ก์ด ์์ธก์ ํฉ๋๋ค.
- Many to Many
- Word Embedding
์๋์ ๊ฐ์ด ๋ฒ์ญ์ ํ์ฌ,
Encoder๋ ์ฃผ์ด์ง input์ ์ง์ด ๋ฃ์ ๋ถ๋ถ์ ๋๋ค.
์๋ก์ด RNN์ ๋ฃ์ ์ ๋ถ๋ถ์ด Decoder์ ๋๋ค.
๊ฒฐ๊ตญ ์ ๋ฆฌํ๋ฉด ๋ค์๊ณผ ๊ฐ์ต๋๋ค.
Encoder๋ input sequence๋ฅผ ๋ฃ๋ ๋ถ๋ถ,
Decoder๋ ์ด๊ฒ์ ๋ํ ์ embedding ๊ฐ์ ๊ฐ์ง๊ณ ๋ท output์ ์์ฑํ๋ ๋ถ๋ถ์ ๋๋ค.
RNN ๊ตฌ์กฐ๊ฐ encoder, decoder ๋ ๋ค ๋ ์ ์์ต๋๋ค.
๊ฒฐ๊ตญ, input์ด ์ด๋ค ๊ตฌ์กฐ, output ์ด sequence ๊ตฌ์กฐ๋ผ๋ฉด encoder - decoder ๊ตฌ์กฐ๋ก modelingํด์ผ๊ฒ ๋ค๊ณ ์๊ฐํ๋ฉด ๋ฉ๋๋ค.
Attention์ ์ฐ๋ ์ด์ ?
๊ต์ฅํ ๊ธด ๋ฌธ์ฅ์ด ๋ค์ด์๋ค๊ณ ๋ด ์๋ค.
100๊ฐ์ hidden state๊ฐ ์์ด์, ๋งจ ๋ง์ง๋ง์ sentense embedding์ด output ์์ฑํ ๋, ๋ชจ๋ ๋จ์ด์ ์ ๋ณด๋ฅผ ๋ค ํฌํจํ๊ณ ์์๊น์?
output์ ์์ฑํ ๋, ๊ฐ๊ฐ์ ๋จ์ด๋ฅผ ๋ค ๋ณด๋ฉด์, ํ์ฌ hidden state์ ๊ฐ 100๊ฐ์ hidden state๊ฐ์ ๊ด๊ณ๋ฅผ ๊ตฌํ๋ฉฐ ๊ฐ์ฅ attention score๊ฐ ๋์ ๊ฒ์ ์ ํ์ ํฉ๋๋ค.
๊ฒฐ๊ตญ, encoder๊ฐ source sentence๋ฅผ ํ๋์ vector๋ก encodingํ๊ธฐ ์ด๋ ต๋ค.
๊ทธ๋์ ์ด๋ฌํ seq2seq task ์์๋ ๊ธธ์ด๊ฐ ๊ธธ ๋, ์ฑ๋ฅ์ด ๋จ์ด์ง๋ ๋ฌธ์ ๊ฐ ์๋ค.
๊ทธ๋์ Attention์ด ๋ฑ์ฅํ์์ต๋๋ค.
'Artificial Intelligence > Natural Language Processing' ์นดํ ๊ณ ๋ฆฌ์ ๋ค๋ฅธ ๊ธ
[NLP] Transformer (0) | 2023.05.21 |
---|---|
[NLP] Attention (0) | 2023.04.12 |
[NLP] RNN - LSTM, GRU (0) | 2023.04.04 |
[NLP] RNN (0) | 2023.04.04 |
[NLP] Word Embedding - GloVe [practice] (0) | 2023.03.31 |