Feeedforward Neural Networks (FFNN)
= 다층 퍼셉트론(MLP)과 같이 입력층에서 출력층 방향으로 연산이 전개되는 방향
- Is a function approximator where the output depends on a single input -> y=f(x)
- The inputs are assumed to be independent from each other
Limitations of feedforward neural network
1. input size should be fixed -> 반드시 same size여야 함. 이게 단점인 것이, NLP에서는 input 값 길이가 다 다르므로 단점, 제한점이 생긴다.
2. All the input instances should have the same length
Language properties 고려해야할 사항
1. Contextual: river bank VS bank branch -> leximal ambiguous : 중의적 표현이 있는 경우, word embedding을 이용하면 문장의 context를 이해할 수 있다.
2. Long-term Dependency : I was born in the US but grew up in Italy and moved back to the US when I was 18 for college, so I can speak ______ and English. : _____은 italy가 되겠지.
3. Order of words is important: "This is a good book, but I do not like it" vs "this is not a good book, but I like it"
Recuurent Neural Networks
: 은닉층의 출력값을 출력층으로도 값을 보내지만, 동시에 은닉층의 출력값이 다시 입력으로도 사용됨
- We can consider NL data as sequntial data points, where the current word depends on the previous words in the sequence
- Core Idea : The function approximator can receive the input word by word such that its output depend on the history. i.e., relying on a notation of memory. 함수 근사기는 출력이 기록에 따라 달라지도록 단어별로 입력을 받을 수 있습니다. 즉, 메모리 표기법에 의존합니다.
- 일반 NN에 비해서, 데이터의 이전 상태정보를 "메모리 (memory)" 형태로 저장할 수 있다는 장점이 있다.
(** cf. 데이터 이전과 이후를 모두 저장하는 모델은 bidirectional RNN)
- Output이 multi-output일 수 도 있고, single-output이 될 수도 있다
Backpropagation Through Time (BPTT)
: 기존의 backpropagation은 시간을 고려하지 않고 그때의 입, 출력 교차 신호로 모델을 수정하였지만, BPTT는 과거의 시간을 고려해준다.
ex) 시간 t의 hidden layer는 시간 t의 입력시간 t-1의 hidden layer뿐만아니라, t-2 이전의 hidden layer 값에도 영향을 주기 때문에 좀 더 시간을 거슬러 올라가서 수정하자는 것!
- Issue : 가중치 occurs each timestep
- Every Path from 가중치 to 결과 is one dependency for differentiation/ W에서 L까지의 모든 경로는 차별화를 위한 하나의 종속성입니다.
- We need to find all paths from W to L
BPTT 문제점
1. Computationally expensive 계산량 많다
2. Vanishing / Exploding gradients challenge : 역전파하면서 입력층에 가까울수록 기울기 소실. -> 앞쪽 단어는 반영이 잘 안 됨
-> Context가 커질수록 RNN에서 정의하는 hidden layer 개수가 늘어나고, 따라서 loss function에 대한 변수 W나 b의 gradient 값이 작아진다.
BPTT는 모든 타임 스텝마다 처음부터 끝까지 역전파.
그러니까 신경망이 깊어지고, vanishing gradient로 인해 문장 초반부의 단어가 결과에 미치는 영향이 작아진다. = RNN은 가까운 곳에 있는 입력에 영향을 더 받는다.
Bidirection RNN
- RNN is devloped for temproal data, so bidirectional is effectively.
- We can use two RNNs that process the input in opposite directions
- 이전과 이후의 Memory를 모두 지닌다.
Gated RNN : update 게이트와 reset 게이트 2개 존재
- Gated recurrent unit
- can learn long-range dependencies
- Reset and Update gates are often close to either 0 or 1 due to using sigmoid
- New gate is used as a preliminary candidate to update the state variable
- 과거나 현재의 정보 최신화 비율을 결정. sigmoid로 출력된 결과(ut)는 현시점의 정보 양을 결정하고, (1-ut)는 직전 시점의 은닉층 정보에 곱한다.
- Reset gate : 과거의 정보를 적당히 리셋시키는 것이 목표로 sigmoid함수를 출력으로 이용해 (0,1) 값을 이전 은닉층에 곱해준다. 직전 시점의 은닉층 값과 현시점 정보에 가중치를 곱하여 얻을 수 있다.
Skip-Thought Vectors
- Encoder-decoder model
- Encoder : maps a sentence into a vector (문자를 벡터 형태로)
- Decoder : conditions on this vector to generate surrounding sentences : 벡터를 이용해 주변 문장을 생성
- 구조 : RNN encoder with GRU activations , RNN decoder with conditioned GRU
- Benefit : Skip-throughts sentence representations lead to robust performance across inportant NLP tasks
댓글