본문 바로가기

취업준비/인공지능

[AI Tech] 6주차 27-1차시 Sequential Models - RNN

27차시: Recurrent Neural Networks (RNN)

27-1. Sequential Models - RNN

RNN은 주어진 입력 자체가 Sequential 하다.

1. Sequential Model

Naive sequence model

Naive Sequence Model

입력이 여러 개 들어왔을 때 다음 입력을 예측하는 것

예) 음성을 인식할 때 다음에 올 단어를 예측하는 서비스

고려해야 하는 정보량이 점점 증가한다.

Autoregressive model

Autoregressive Model

Markov model (first-order autoregressive model)

Markov model

많은 정보를 버릴 수밖에 없다.

장점: joint distribution을 표현하기 쉽다.

단점: 과거의 많은 정보를 고려할 수 없다.

Latent autoregressive model

Latent autoregressive model

중간에 hidden state를 하나 끼워 넣음으로써 과거 정보를 요약한다.

hidden state를 추가한다.

 

2. Recurrent Neural Network

콘셉트들을 잘 설명할 수 있는 네트워크

자기 자신으로 돌아오는 구조가 있다는 것이 위의 것과 다른 점이다.

Recurrent Neural Network
구조도

RNN도 사실 풀어서 표현하면 입력이 매우 많은 Fully Content layer로 표현할 수 있다.

Short-term dependencies

과거에 얻어진 정보들이 취합되어 미래에 반영되어야 하지만, 값이 계속 늘어나기에 먼 미래까지 영향을 주는 것은 어렵다.

쉽게 말해, 가까운 정보는 반영이 쉽지만, 먼 정보는 반영이 어렵다.

Long-term dependencies

Long-term dependencies

멀리 있는 정보는 반영되기 어렵다.

RNN

 

3. Long Short Term Memory

tanh
LSTM
LSTM부분만 본 사진

h_t: Output(hidden state)

X_t : Input

여기에 Previous cell state가 취합하는 데 사용된다.

아래 화살표는 Previous hidden state가 들어온다.

오른쪽 위 화살표는 Next cell state, 아래 화살표는 Next hidden state로 연결된다.

Gate and several inputs and outputs

LSTM은 또한 여러 개의 gate로 구성되어 있는데, 각각 Forget gate, Input gate, Output gate이다.

Core idea of LSTM

Forget Gate

Forget Gate

Input Gate

Input Gate

Update cell

Update cell

Output Gate

Output Gate

결과적으로,

input, previous hidden state, previous cell state가 들어오면

이전 cell state의 데이터 중 어떤 것을 지워버릴지 정하고

previous hidden state와 input으로 어떤 값을 올릴지 c\tilda를 정하고,

업데이트된 cell state와 올릴 예정인 candidate cell state를 다시 조합하여 새로운 cell state를 만들고,

최종적으로 얼마큼 이 정보를 밖으로 빼낼지 정하는 것이다.

 

4. Gated Recurrent Unit

Gated Recurrent Unit

- Simpler architecture with two gates (reset gate and update gate).

- No cell state, just hidden state.

이렇게 하면서 reset gate와 update gate가 합쳐졌다.

 

 

 

 

 

©️NAVER Connect Foundation. All Rights Reserved.