20. 인공지능과 딥러닝
[PyTorch로 시작하는 딥러닝] Lab-11-2 RNN hihello and charseq
WE DONE IT.
2020. 3. 29. 20:07
edwith의 파이토치로 시작하는 딥러닝 기초 중 <11-2 RNN hihello and charseq> 수업을 듣고 정리하였습니다. 잘못된 부분이 있으면 말씀해 주세요!
'Hihello' example
'hihello' problem
h가 들어오면 i를 예측하고, i가 들어오면 h, h가 들어오면 e (...) 를 예측하는 문제이다. 이렇게 character가 들어오면 다음 character를 예측하는 모델을 만들고자 한다. 'h'가 들어왔을 때, 'i', 'e' 중 어떤 게 출력되는지 올바르게 결정할 수 있도록 hidden state의 역할이 중요하게 된다.
How can we represent charaters?
One-hot encodding
continuous하지 않고 categorical한 데이터를 표현할 때 주로 one-hot encodding을 사용한다. 이 모델은 다음 문자를 예측하는 모델이기 때문에, ‘o’는 제일 마지막이므로 x_one_hot에서는 고려하지 않는다.
Cross Entropy Loss
이 예제에서는 CEL(cross entropy loss)라는 loss를 사용한다. Cross entropy loss는 categorical한 output을 예측하는 모델에서 많이 쓰인다.
Code run through (hihello)
Code run through (charseq)
Code run through (hihello) 코드보다 범용적으로 사용할 수 있다.