Deep Learning 6

Attention in RNN (Bahadanau, Luong)

Attention 어느 시점 정보가 RNN의 최종 출력 값에 영향을 미치는지를 알려줄 수 있는 메커니즘 ① 각각의 hidden state가 어느 정도의 중요도를 갖는지(=attention score) 산출하는 NN ② α = attention score ③ 기존 hidden state를 그대로 가져오는게 아니라, 현재 시점의 output을 만드는데 중요하게 역할을 하는 시점이 어느 시점인지를 scalar 값으로 산출하고, 이렇게 산출된 scalar 값(α)과 hidden state 들을 선형 결합해서 하나의 vector로 표현함 → context vector Luong attention은 attention score를 따로 학습하지는 않지만, Bahdanau attention 의 성능과 크게 차이가 나지..

RNN, LSTM

ratsgo.github.io/natural%20language%20processing/2017/03/09/rnnlstm/ RNN과 LSTM을 이해해보자! · ratsgo's blog 이번 포스팅에서는 Recurrent Neural Networks(RNN)과 RNN의 일종인 Long Short-Term Memory models(LSTM)에 대해 알아보도록 하겠습니다. 우선 두 알고리즘의 개요를 간략히 언급한 뒤 foward, backward compute pass를 천천 ratsgo.github.io dgkim5360.tistory.com/entry/understanding-long-short-term-memory-lstm-kr Long Short-Term Memory (LSTM) 이해하기 이 글은 Ch..

tf.nn.softmax_cross_entropy_with_logits_v2

tf.nn.softmax_cross_entropy_with_logits_v2 가 수행하는 3가지 연산 logits인 (y_hat)에 softmax 함수 적용 (정규화를 위해) : y_hat_softmax = softmax(y_hat) cross-entropy loss 계산 : y_cross = y_true * tf.log(y_hat_softmax) 각 데이터로부터 각각 loss 값 계산 : -tf.reduce_sum(y_cross, reduction_indices=[1]) 아래의 코드는 이것을 완벽하게 보여준다. 코드 : y_true = tf.convert_to_tensor(np.array([[0.0, 1.0, 0.0],[0.0, 0.0, 1.0]])) y_hat = tf.convert_to_tensor..