Diffusion models beat gans on image synthesisBeerenSahu
Diffusion models have recently been shown to produce higher quality images than GANs while also offering better diversity and being easier to scale and train. Specifically, a 2021 paper by OpenAI demonstrated that a diffusion model achieved an FID score of 2.97 on ImageNet 128x128, beating the previous state-of-the-art held by BigGAN. Diffusion models work by gradually adding noise to images in a forward process and then learning to remove noise in a backward denoising process, allowing them to generate diverse, high fidelity images.
The document discusses chapter 7 of a software engineering textbook which covers design and implementation. It begins by outlining the topics to be covered, including object-oriented design using UML, design patterns, and implementation issues. It then discusses the software design and implementation process, considerations around building versus buying systems, and approaches to object-oriented design using UML.
발표자: 이활석(NAVER)
발표일: 2017.11.
최근 딥러닝 연구는 지도학습에서 비지도학습으로 급격히 무게 중심이 옮겨 지고 있습니다. 본 과정에서는 비지도학습의 가장 대표적인 방법인 오토인코더의 모든 것에 대해서 살펴보고자 합니다. 차원 축소관점에서 가장 많이 사용되는Autoencoder와 (AE) 그 변형 들인 Denoising AE, Contractive AE에 대해서 공부할 것이며, 데이터 생성 관점에서 최근 각광 받는 Variational AE와 (VAE) 그 변형 들인 Conditional VAE, Adversarial AE에 대해서 공부할 것입니다. 또한, 오토인코더의 다양한 활용 예시를 살펴봄으로써 현업과의 접점을 찾아보도록 노력할 것입니다.
1. Revisit Deep Neural Networks
2. Manifold Learning
3. Autoencoders
4. Variational Autoencoders
5. Applications
[GomGuard] 뉴런부터 YOLO 까지 - 딥러닝 전반에 대한 이야기JungHyun Hong
뉴런, perceptron, cnn, r-cnn, fast r-cnn, faster r-cnn 및
backpropagation, activation function, batch normalization, cost function, optimizer 등 전반적인 딥뉴럴 네트워크에 대한 지식을 다루고 있습니다.
mail : [email protected]
blog : gomguard.tistory.com
[우리가 데이터를 쓰는 법] 좋다는 건 알겠는데 좀 써보고 싶소. 데이터! - 넘버웍스 하용호 대표Dylan Ko
Gonnector(고넥터) 고영혁 대표가 주최한 스타트업 데이터 활용 세미나 '우리가 데이터를 쓰는 법' 의 첫 번째 발표 자료
세미나 : 우리가 데이터를 쓰는 법 (How We Use Data)
일시 : 2016년 4월 12일 화요일 10:00 ~ 18:00
장소 : 마루180 (Maru180) B1 Think 홀
제목 : 좋다는 건 알겠는데 좀 써보고 싶소. 데이터!
연사 : 넘버웍스 하용호 대표
책 읽어주는 딥러닝: 배우 유인나가 해리포터를 읽어준다면 DEVIEW 2017Taehoon Kim
발표 영상 : https://youtu.be/klnfWhPGPRs
코드 : https://github.com/carpedm20/multi-speaker-tacotron-tensorflow
음성 합성 데모 : http://carpedm20.github.io/tacotron
발표 소개 : https://deview.kr/2017/schedule/182
딥러닝을 활용한 음성 합성 기술을 소개하고 개발 경험과 그 과정에서 얻었던 팁을 공유하고자 합니다.
This document discusses techniques for recommender systems including multi-armed bandit (MAB), Thompson sampling, user clustering, and using item features. It provides examples of how MAB works using the ε-greedy approach and explores the tradeoff between exploration and exploitation. User clustering is presented as a way to group users based on click-through rate to improve targeting. Finally, it suggests using different item features like images, text, and collaborative filtering data as inputs to recommendation models.
One-stage Network(YOLO, SSD 등)의 문제점 예를 들어 근본적인 문제인 # of Hard positives(object) << # of Easy negatives(back ground) 또는 large object 와 small object 를 동시에 detect하는 경우 등과 같이 극단적인 Class 간 unbalance나 난이도에서 차이가 나는 문제가 동시에 존재함으로써 발생하는 문제를 해결하기 위하여 제시된 Focal loss를 class간 아주 극단적인 unbalance data에 대한 classification 문제(예를 들어 1:10이나 1:100)에 적용한 실험결과가 있어서 정리해봤습니다. 결과적으로 hyper parameter의 설정에 매우 민감하다는 실험결과와 잘만 활용할 경우, class간 unbalance를 해결하기 위한 data level의 sampling 방법이나 classifier level에서의 특별한 고려 없이 좋은 결과를 얻을 수 있다는 내용입니다.
This document introduces artificial intelligence (AI) and discusses examples of AI being used in everyday life. It defines AI as machines that mimic human intelligence, and notes most current AI is specialized or "weak AI" that can only perform specific tasks rather than general human-level intelligence. Examples discussed include voice recognition, chatbots, facial recognition, image recognition for medical diagnosis, recommendation systems, AI in games like Go, and applications in business like sharing economies and customer monitoring.
'꿈꾸는 데이터 디자이너' 과정의 학생들에게 소개한
'직업의 세계(?)' 강의 자료 입니다.
https://www.facebook.com/datadesigner2015
데이터를 다루기 위한 스킬과
보면 유용한 책들을 간단히 소개하였습니다.
알파고의 작동 원리를 설명한 슬라이드입니다.
English version: http://www.slideshare.net/ShaneSeungwhanMoon/how-alphago-works
- 비전공자 분들을 위한 티저: 바둑 인공지능은 과연 어떻게 만들까요? 딥러닝 딥러닝 하는데 그게 뭘까요? 바둑 인공지능은 또 어디에 쓰일 수 있을까요?
- 전공자 분들을 위한 티저: 알파고의 main components는 재밌게도 CNN (Convolutional Neural Network), 그리고 30년 전부터 유행하던 Reinforcement learning framework와 MCTS (Monte Carlo Tree Search) 정도입니다. 새로울 게 없는 재료들이지만 적절히 활용하는 방법이 신선하네요.
[야생의 땅: 듀랑고]의 식물 생태계를 담당하는 21세기 정원사의 OpenCL 경험담Sumin Byeon
이 발표는 넥슨의 신규 개발 게임인 듀랑고의 생태계에 대한 간략한 소개와 OpenCL 을 이용한 병렬 처리에 관한 전반적인 기술적 내용을 다룹니다. 게임 속의 세계에서 지형과 기후, 지질 조건에 맞게 여러 종류의 식물과 광물들을 알맞은 곳에 배치시키는 것이 생태계 시뮬레이터의 역할인데, 이 시뮬레이터는 방대한 양의 계산을 수행합니다. 초기에 만들어진 프로토타입은 이러한 계산을 수행하는데 30분이 넘게 걸렸지만, 병렬처리, 알고리즘 시간복잡도 개선 등의 여러가지 방법들을 통해 그 시간을 11초까지 단축시켰습니다. 구체적으로 어떤 방법들을 시도했었고, 어떤 방법들이 효과가 있었는지 여러분과 그 경험담을 공유하고자 합니다.
발표자: 이활석(NAVER)
발표일: 2017.11.
최근 딥러닝 연구는 지도학습에서 비지도학습으로 급격히 무게 중심이 옮겨 지고 있습니다. 본 과정에서는 비지도학습의 가장 대표적인 방법인 오토인코더의 모든 것에 대해서 살펴보고자 합니다. 차원 축소관점에서 가장 많이 사용되는Autoencoder와 (AE) 그 변형 들인 Denoising AE, Contractive AE에 대해서 공부할 것이며, 데이터 생성 관점에서 최근 각광 받는 Variational AE와 (VAE) 그 변형 들인 Conditional VAE, Adversarial AE에 대해서 공부할 것입니다. 또한, 오토인코더의 다양한 활용 예시를 살펴봄으로써 현업과의 접점을 찾아보도록 노력할 것입니다.
1. Revisit Deep Neural Networks
2. Manifold Learning
3. Autoencoders
4. Variational Autoencoders
5. Applications
[GomGuard] 뉴런부터 YOLO 까지 - 딥러닝 전반에 대한 이야기JungHyun Hong
뉴런, perceptron, cnn, r-cnn, fast r-cnn, faster r-cnn 및
backpropagation, activation function, batch normalization, cost function, optimizer 등 전반적인 딥뉴럴 네트워크에 대한 지식을 다루고 있습니다.
mail : [email protected]
blog : gomguard.tistory.com
[우리가 데이터를 쓰는 법] 좋다는 건 알겠는데 좀 써보고 싶소. 데이터! - 넘버웍스 하용호 대표Dylan Ko
Gonnector(고넥터) 고영혁 대표가 주최한 스타트업 데이터 활용 세미나 '우리가 데이터를 쓰는 법' 의 첫 번째 발표 자료
세미나 : 우리가 데이터를 쓰는 법 (How We Use Data)
일시 : 2016년 4월 12일 화요일 10:00 ~ 18:00
장소 : 마루180 (Maru180) B1 Think 홀
제목 : 좋다는 건 알겠는데 좀 써보고 싶소. 데이터!
연사 : 넘버웍스 하용호 대표
책 읽어주는 딥러닝: 배우 유인나가 해리포터를 읽어준다면 DEVIEW 2017Taehoon Kim
발표 영상 : https://youtu.be/klnfWhPGPRs
코드 : https://github.com/carpedm20/multi-speaker-tacotron-tensorflow
음성 합성 데모 : http://carpedm20.github.io/tacotron
발표 소개 : https://deview.kr/2017/schedule/182
딥러닝을 활용한 음성 합성 기술을 소개하고 개발 경험과 그 과정에서 얻었던 팁을 공유하고자 합니다.
This document discusses techniques for recommender systems including multi-armed bandit (MAB), Thompson sampling, user clustering, and using item features. It provides examples of how MAB works using the ε-greedy approach and explores the tradeoff between exploration and exploitation. User clustering is presented as a way to group users based on click-through rate to improve targeting. Finally, it suggests using different item features like images, text, and collaborative filtering data as inputs to recommendation models.
One-stage Network(YOLO, SSD 등)의 문제점 예를 들어 근본적인 문제인 # of Hard positives(object) << # of Easy negatives(back ground) 또는 large object 와 small object 를 동시에 detect하는 경우 등과 같이 극단적인 Class 간 unbalance나 난이도에서 차이가 나는 문제가 동시에 존재함으로써 발생하는 문제를 해결하기 위하여 제시된 Focal loss를 class간 아주 극단적인 unbalance data에 대한 classification 문제(예를 들어 1:10이나 1:100)에 적용한 실험결과가 있어서 정리해봤습니다. 결과적으로 hyper parameter의 설정에 매우 민감하다는 실험결과와 잘만 활용할 경우, class간 unbalance를 해결하기 위한 data level의 sampling 방법이나 classifier level에서의 특별한 고려 없이 좋은 결과를 얻을 수 있다는 내용입니다.
This document introduces artificial intelligence (AI) and discusses examples of AI being used in everyday life. It defines AI as machines that mimic human intelligence, and notes most current AI is specialized or "weak AI" that can only perform specific tasks rather than general human-level intelligence. Examples discussed include voice recognition, chatbots, facial recognition, image recognition for medical diagnosis, recommendation systems, AI in games like Go, and applications in business like sharing economies and customer monitoring.
'꿈꾸는 데이터 디자이너' 과정의 학생들에게 소개한
'직업의 세계(?)' 강의 자료 입니다.
https://www.facebook.com/datadesigner2015
데이터를 다루기 위한 스킬과
보면 유용한 책들을 간단히 소개하였습니다.
알파고의 작동 원리를 설명한 슬라이드입니다.
English version: http://www.slideshare.net/ShaneSeungwhanMoon/how-alphago-works
- 비전공자 분들을 위한 티저: 바둑 인공지능은 과연 어떻게 만들까요? 딥러닝 딥러닝 하는데 그게 뭘까요? 바둑 인공지능은 또 어디에 쓰일 수 있을까요?
- 전공자 분들을 위한 티저: 알파고의 main components는 재밌게도 CNN (Convolutional Neural Network), 그리고 30년 전부터 유행하던 Reinforcement learning framework와 MCTS (Monte Carlo Tree Search) 정도입니다. 새로울 게 없는 재료들이지만 적절히 활용하는 방법이 신선하네요.
[야생의 땅: 듀랑고]의 식물 생태계를 담당하는 21세기 정원사의 OpenCL 경험담Sumin Byeon
이 발표는 넥슨의 신규 개발 게임인 듀랑고의 생태계에 대한 간략한 소개와 OpenCL 을 이용한 병렬 처리에 관한 전반적인 기술적 내용을 다룹니다. 게임 속의 세계에서 지형과 기후, 지질 조건에 맞게 여러 종류의 식물과 광물들을 알맞은 곳에 배치시키는 것이 생태계 시뮬레이터의 역할인데, 이 시뮬레이터는 방대한 양의 계산을 수행합니다. 초기에 만들어진 프로토타입은 이러한 계산을 수행하는데 30분이 넘게 걸렸지만, 병렬처리, 알고리즘 시간복잡도 개선 등의 여러가지 방법들을 통해 그 시간을 11초까지 단축시켰습니다. 구체적으로 어떤 방법들을 시도했었고, 어떤 방법들이 효과가 있었는지 여러분과 그 경험담을 공유하고자 합니다.
Variational Auto Encoder, Generative Adversarial ModelSEMINARGROOT
Generative Model(Variational Auto Encoder, Generative Adversarial Model)
References:
오토인코더의 모든 것 by 이활석 (NAVER)
Youtube: https://youtu.be/rNh2CrTFpm4, Slideshare: https://www.slideshare.net/NaverEngineering/ss-96581209
1시간만에 GAN(Generative Adversarial Network) 완전 정복하기 by 최윤제 (NAVER)
Youtube: https://youtu.be/odpjk7tGY0, Slideshare: https://www.slideshare.net/NaverEngineering/1-gangenerative-adversarial-network
Theory and Application of Generative Adversarial Networks by Ming-Yu Liu, Julie Bernauer, Jan Kautz (NVIDIA)
Youtube: https://youtu.be/KudkR-fFu_8, Slideshare: https://www.slideshare.net/mlreview/tutorial-on-theory-and-application-of-generative-adversarial-networks
Tutorial on Variational Autoencoders by Carl Doersch (Carnegie Mellon / UC Berkeley)
Arxiv: https://arxiv.org/pdf/1606.05908.pdf
Generative Adversarial Nets (2014) NIPS by Goodfellow et al
https://papers.nips.cc/paper/5423-generative-adversarial-nets.pdf
딥러닝과 강화 학습으로 나보다 잘하는 쿠키런 AI 구현하기 DEVIEW 2016Taehoon Kim
발표 영상 : https://goo.gl/jrKrvf
데모 영상 : https://youtu.be/exXD6wJLJ6s
Deep Q-Network, Double Q-learning, Dueling Network 등의 기술을 소개하며, hyperparameter, debugging, ensemble 등의 엔지니어링으로 성능을 끌어 올린 과정을 공유합니다.
** 해당 자료는 외부 공유 인가 되었습니다.
1. 딥러닝의 동작 방식에 대한 기초 가이드
2. 네트워크를 통한 공간 변환 개괄
"다음을 꼭 기억하세요. 지금까지 딥러닝의 실제 성공은 연속된 기하학적 변환을 사용하여 공간 X 에서 공간 Y 로 매핑하는 능력에 기인합니다."
프랑소와 숄레, 케라스 창시자에게 배우는 딥러닝 가운데.
딥 러닝 자연어 처리 학습을 위한 PPT! (Deep Learning for Natural Language Processing)
1. 이 문서는 파워포인트로 자연어 처리의 여러 기법들을
이해하기 위한 ‘이미지’들을 만들어놓은 파일입니다.
발표용 자료가 아니므로 설명이 거의 없습니다.
각 페이지에 대한 설명은 오른쪽 하단 링크에 있습니다.
링크 : https://wikidocs.net/book/2155
3. 𝛴𝑡 𝑉𝑡
𝑇
Full SVD
Truncated SVD
=
=
𝐴 𝑈 𝛴 𝑉𝑇
𝐴′ 𝑈𝑡
잠재 의미 분석(LSA)는 텍스트의 잠재된 의미를 도출하기 위해
차원 축소를 실행하는데, 이때 사용하는 것이 Truncated SVD이다.
SVD(Singular Value Decomposition)
5. word apple banana apple dog dog
topic B B ??? A A
word cute book king apple apple
topic B B B B B
word apple banana apple dog dog
topic B B ??? A A
word cute book king apple apple
topic B B B B B
word apple banana apple dog dog
topic B B ??? A A
word cute book king apple apple
topic B B B B B
LDA 알고리즘은 모든 문서의 각 단어들에 대해서 루프를 돌리면서
토픽을 체크하고 업데이트합니다. 각 단어에 대해서 토픽은
아래의 두 가지 기준으로 할당됩니다.
1. How prevalent is that word across topics?
2. How prevalent are topics in the document?
1. How prevalent is that word across topics?
‘사과’라는 단어는 두 문서 전체에서 토픽 B의 약 절반을
차기합니다. 반면에, 토픽 A에서는 아무 지분도 차지하지
않습니다. 이 기준에 따르면 토픽 B에 할당될 가능성이 높
습니다.
2. How prevalent are topics in the document?
Doc 1에서 토픽 A와 토픽 B는 50:50 비율입니다.
이 기준에 따르면 ‘사과'라는 단어는 절반의 확률을
가집니다.
doc1
doc2
doc1
doc2
doc1
doc2
10. 룰 베이스로 이미지 인식과 같은 문제를 풀고자하면?
규칙을 일일히 나열하는 것만으로는 해결 불가능한 문제들이 있다.
(여기 고양이 사진은 현 PPT 공유자의 것이 아님.)
11. Data
def predection(Data):
... program ...
return 해답
해답
Data
Data : 해답
1번 사진 : 강아지
2번 사진 : 고양이
3번 사진 : 강아지
4번 사진 : 고양이
5번 사진 : 강아지
...
규칙성
해답
전통적인 프로그래밍의 접근 방법
머신 러닝의 접근 방법
13. 배포
수집
점검 및
탐색
머신 러닝 워크플로우
전처리 및
정제
모델링 및
훈련
평가
테스트
데이터
전체 데이터(Original Data)
훈련(Training)
테스트
(Testing)
테스트
(Testing)
훈련(Training)
검증
(Validation)
훈련 데이터와 검증 데이터의 분할
14. 선형 회귀와 경사 하강법
링크 : https://wikidocs.net/21670
25. 1 bias
𝑦1
𝑦2
…
𝑦𝑚
…
𝑥1
𝑥2
𝑥3
𝑥𝑛
현재 다룬 소프트맥스 회귀는
사실 얕은 인공 신경망으로도 볼 수 있다.
Softmax
𝑧1
SepalWidthCm
PetalLegnthCm
PetalWidthCm
0.26
0.71
0.04
𝑥1
𝑥2
𝑥3
𝑥4
예측값 실제값
0
1
0
setosa의 원-핫 벡터
오차로부터 가중치와 편향 업데이트
bias
SepalLengthCm
26. softmax
( )
× =
예측값𝑡
c × 1
𝑥1
𝑊
𝑥
+
𝑏
c × 1
f × 1
c × f
소프트맥스 회귀를 벡터와 행렬 연산으로 표현하면?
f : 특성(feature)의 수
c : 클래스(class)의 수
40. 순방향 신경망(Feed-Forward Neural Network)
(또는 피드 포워드 신경망이라고도 한다.)
순환 신경망(Recurrent Neural Network)
Vs.
RNN(순환 신경망)은 은닉층에 사이클이 존재하는 신경망이라는 점에서
앞서 본 신경망들과 다르다.
41. 순환 신경망(Recurrent Neural Network)의 표현 방법
time step 1 time step 2
=
𝑥𝑡
𝑦𝑡 unit 또는 뉴런이라는 단위
셀이라는 단위
벡터라는 단위
RNN의 셀을 다층 퍼셉트론의 뉴런과 동일한 단위로 이해하면
그때부터 RNN에 대한 무한 혼란이 일어난다.
RNN에 대한 여러 그림은 뒤에 RNN 챕터에서 확인하자.
42. 인공신경망의 학습
링크 : https://wikidocs.net/36033
43. 200
200
200
200
200
200
200
200
200
200
Total data : 2,000
Batch size : 200
Iteration : 10
+ 1 epoch
Epoch와 batch size와 iteration의 관계
𝑋𝑚 x 𝑛 × 𝑊? x ? + 𝐵? x ? = 𝑌𝑚 x 𝑗
𝑋𝑚 x 𝑛 × 𝑊𝑛 x ? + 𝐵𝑚 x 𝑗 = 𝑌𝑚 x 𝑗
같아야 한다
𝑋𝑚 x 𝑛 × 𝑊? x ? + 𝐵𝑚 x 𝑗 = 𝑌𝑚 x 𝑗
같아야 한다
𝑋𝑚 x 𝑛 × 𝑊𝑛 x 𝑗 + 𝐵𝑚 x 𝑗 = 𝑌𝑚 x 𝑗
같아야 한다
인공 신경망의 가중치 행렬과 편향 행렬의 크기 계산
52. 다양한 단어의 표현 방법
링크 : https://wikidocs.net/31767
53. Word Representation
Local Representation Continuous Representation
Count Based
One-hot Vector
Bag of Words
(DTM, TF-IDF)
N-gram Count Based
Prediction Based
Full Document
LSA, LDA
Windows
GloVe
Word2Vec
(FastText)
54. NNLM
(Neural Network Language Model)
N-gram 언어 모델의 sparsity problem을 해결하기 위해
인공 신경망 언어 모델 NNLM이 제안되다.
이 NNLM은 향후 Word2Vec으로 발전한다.
링크 : https://wikidocs.net/45609
인공 신경망 언어 모델의 등장!
55. n개의 이전 단어 예측 단어
[1, 0, 0, 0, 0, 0, 0], [0, 1, 0, 0, 0, 0, 0],
[0, 0, 1, 0, 0, 0, 0], [0, 0, 0, 1, 0, 0, 0].
[0, 0, 0, 0, 1, 0, 0]
[0, 1, 0, 0, 0, 0, 0], [0, 0, 1, 0, 0, 0, 0]
[0, 0, 0, 1, 0, 0, 0], [0, 0, 0, 0, 1, 0, 0]
[0, 0, 0, 0, 0, 1, 0]
[0, 0, 1, 0, 0, 0, 0] [0, 0, 0, 1, 0, 0, 0],
[0, 0, 0, 0, 1, 0, 0], [0, 0, 0, 0, 0, 1, 0].
[0, 0, 0, 0, 0, 0, 1]
what will the fat cat sit on
what will the fat cat sit on
what will the fat cat sit on
예측할 다음 단어
이전 단어
window size=4. 앞의 단어 4개만을 참고
결과적으로 앞의 n개의 단어를 참고하는 셈이다.
56. will(one-hot vector)
the(one-hot vector)
fat(one-hot vector)
cat(one-hot vector)
sit(one-hot vector)
Projection layer
(linear) Hidden layer
(nonlinear) Output layer
Input layer
NNLM(2003)은 총 4개의 layer로 구성된다.
n × V
n × m
500 < h < 1000
(typically)
V
57. Input layer
우선 Projection layer 단계에서는
각 원-핫 벡터는 테이블 룩업을 진행한다.
will(one-hot vector)
the(one-hot vector)
fat(one-hot vector)
cat(one-hot vector)
58. 0.5 2.1 1.9 1.5 0.8
0.8 1.2 2.8 1.8 2.1
0.1 0.8 1.2 0.9 0.7
2.1 1.8 1.5 1.7 2.7
0 0 0 1 0 0 0 × = 2.1 1.8 1.5 1.7 2.7
lookup table
𝑥𝑓𝑎𝑡 × 𝑊𝑉×𝑀 = 𝑒𝑓𝑎𝑡
테이블 룩-업이란?
V가 vocabular의 크기, M을 embedding vecto의 차원이면
원-핫 벡터가 V x M 행렬을 곱해서 더 작은 차원의 벡터가 된다.
59. Input layer
Projection layer
(linear)
concatenate
n × V
n × m
테이블 룩-업으로 차원이 축소된 각 단어 벡터들이
모두 연결이 되면 projection layer의 결과물이다.
will(one-hot vector)
the(one-hot vector)
fat(one-hot vector)
cat(one-hot vector)
60. Projection layer
(linear) Hidden layer
(nonlinear)
Input layer
n × m
h
will(one-hot vector)
the(one-hot vector)
fat(one-hot vector)
cat(one-hot vector)
63. 중심 단어 주변 단어
[1, 0, 0, 0, 0, 0, 0] [0, 1, 0, 0, 0, 0, 0], [0, 0, 1, 0, 0, 0, 0]
[0, 1, 0, 0, 0, 0, 0]
[1, 0, 0, 0, 0, 0, 0], [0, 0, 1, 0, 0, 0, 0],
[0, 0, 0, 1, 0, 0, 0]
[0, 0, 1, 0, 0, 0, 0]
[1, 0, 0, 0, 0, 0, 0], [0, 1, 0, 0, 0, 0, 0],
[0, 0, 0, 1, 0, 0, 0], [0, 0, 0, 0, 1, 0, 0]
[0, 0, 0, 1, 0, 0, 0]
[0, 1, 0, 0, 0, 0, 0], [0, 0, 1, 0, 0, 0, 0],
[0, 0, 0, 0, 1, 0, 0], [0, 0, 0, 0, 0, 1, 0]
[0, 0, 0, 0, 1, 0, 0]
[0, 0, 1, 0, 0, 0, 0], [0, 0, 0, 1, 0, 0, 0],
[0, 0, 0, 0, 0, 1, 0], [0, 0, 0, 0, 0, 0, 1]
[0, 0, 0, 0, 0, 1, 0]
[0, 0, 0, 1, 0, 0, 0], [0, 0, 0, 0, 1, 0, 0],
[0, 0, 0, 0, 0, 0, 1]
[0, 0, 0, 0, 0, 0, 1] [0, 0, 0, 0, 1, 0, 0], [0, 0, 0, 0, 0, 1, 0]
The fat cat sat on the mat
The fat cat sat on the mat
The fat cat sat on the mat
The fat cat sat on the mat
The fat cat sat on the mat
The fat cat sat on the mat
The fat cat sat on the mat
중심 단어
주변 단어
window size=2. 좌, 우 단어 2개씩을 참고.
64. fat(one-hot vector)
cat(one-hot vector)
on(one-hot vector)
the(one-hot vector)
sat(one-hot vector)
Output layer
Projection layer
Input layer
Word2Vec은 총 3개의 layer로 구성된다.
가운데 층을 hidden layer라고 하는 그림도 있지만
중요한 건 은닉층에 활성화 함수가 없다는 것이다.
이를 일반적인 은닉층과 구분하기 위해
projection layer라고도 부른다.
70. NNLM vs Word2Vec
링크 : https://wikidocs.net/22660
NNLM이 발전되어 Word2Vec이 등장한다.
71. Input layer
Projection layer
Hidden layer
Output layer V
n × m
V
n × m
h
Feed forward NNLM Word2Vec(CBOW)
n : 학습에 사용되는 단어의 수
m : 임베딩 벡터의 크기
h : 은닉층의 크기
V : 단어 집합의 크기
73. 중심 단어 주변 단어
cat The
cat Fat
cat sat
cat on
sat fat
sat cat
sat on
sat the
The fat cat sat on the mat
The fat cat sat on the mat
중심 단어
주변 단어
window size=2. 좌, 우 단어 2개씩을 참고.
74. sat
The fat cat sat on the mat
중심 단어
주변 단어
cat sat
Skip-gram
Skip-gram
(Negative Sampling)
0.88
cat
75. 입력 레이블
cat The
cat fat
cat sat
cat on
sat fat
sat cat
sat on
sat the
… …
The fat cat sat on the mat
The fat cat sat on the mat
중심 단어
주변 단어
입력1 입력2 레이블
cat The 1
cat fat 1
cat sat 1
cat on 1
sat fat 1
sat cat 1
sat on 1
sat the 1
… … …
입력과 레이블의 변화
76. 입력1 입력2 레이블
cat The 1
cat fat 1
cat sat 1
cat on 1
입력1 입력2 레이블
cat The 1
cat fat 1
cat pizza 0
cat computer 0
cat sat 1
cat on 1 단어 집합에서 랜덤으로
선택된 단어들을
레이블 0의 샘플로 추가.
Negative Sampling
입력과 레이블의 변화
77. 입력1 입력2 레이블
cat The 1
cat fat 1
cat pizza 0
cat computer 0
cat sat 1
cat on 1
cat cute 1
cat mighty 0
… … …
Embedding layer Embedding layer
93. No. of samples
= batch_size
input_length
= timeseries
= timesteps
input_dim
= Dimensionality of word representation
RNN의 입출력 이해를 위해서는 3D 텐서를 이해해야한다.
99. 𝑥1 𝑥2 𝑥3 𝑥4
𝑦1 𝑦2 𝑦3 𝑦4
what will the fat
will the fat cat
다음 단어 예측 Task.
언어 모델링이라고도 부른다.
예측된 단어는 다음 time step의
입력이 된다.
…
100. ‘cat’의 원-핫 벡터
t=1 t=2 t=3 t=4
softmax
실제값 0 0 0 0 1 0 0
예측값 0.1 0.05 0.05 0.1 0.7 0.03 0.07
cross-entropy
embedding
Dense
what will the fat
소프트맥스 함수를 인공 신경망의
출력층으로 사용하는 경우
다음과 같이 표현하기도 한다.
Dense + softmax
Fully connected N units + softmax
FFNN + softmax
여기서는 첫번째 표기를 사용한다.
embedding embedding
embedding
101. fat(one-hot vector) cat(one-hot vector)
Embedding layer
(linear)
Hidden layer
(nonlinear)
Output layer
Input layer
RNNLM은 총 4개의 layer로 구성된다.
time step=4일 경우
102. 𝑾′𝑴×𝑽× 𝒗 = 𝒛
𝒚 = 𝒔𝒐𝒇𝒕𝒎𝒂𝒙(𝒛)
0
0
0
0
1
0
0
0.1
0.05
0.05
0.1
0.7
0.03
0.07
cross entropy
Output layer
V
𝑦𝑡𝑝𝑟𝑒𝑑𝑖𝑐𝑡𝑒𝑑
𝑥𝑡𝑝𝑟𝑒𝑑𝑖𝑐𝑡𝑒𝑑
lookup table
0
0
0
1
0
0
0
Input layer Embedding layer
(linear)
𝑒𝑡𝑝𝑟𝑒𝑑𝑖𝑐𝑡𝑒𝑑
ℎ𝑡−1𝑝𝑟𝑒𝑑𝑖𝑐𝑡𝑒𝑑
RNN
Cell
ℎ𝑡
Hidden layer
(nonlinear) 𝑦𝑡
앞의 그림을 좀 더 자세히 보자!
103. 0.5 2.1 1.9 1.5 0.8
0.8 1.2 2.8 1.8 2.1
0.1 0.8 1.2 0.9 0.7
2.1 1.8 1.5 1.7 2.7
0 0 0 1 0 0 0 × = 2.1 1.8 1.5 1.7 2.7
lookup table
𝑥𝑡 × 𝑊𝑉×𝑀 = 𝑒𝑡
테이블 룩-업이란?
V가 vocabular의 크기, M을 embedding vecto의 차원이면
원-핫 벡터가 V x M 행렬을 곱해서 더 작은 차원의 벡터가 된다.
104. 𝑦1 𝑦2 𝑦3 𝑦4
𝑥1 𝑥2 𝑥3 𝑥4
주의할 점!
양방향 RNN으로는 RNNLM을 만들 수 없다.
RNNLM은 이전 단어로부터 다음 단어를 예측하는데
양방향 RNN은 이미 다음 단어를 컨닝하고 있다.
언어 모델에서 양방향으로 참고할 수 있게 하려면?
이것이 BERT에서 나오는 Masked Language Model
105. Char RNN
링크 : https://wikidocs.net/48649
RNN의 입력 단위를 글자로 했을 때,
다대일 RNN과 RNN 언어 모델을 구현해보자.
115. 출력 게이트와 은닉 상태
σ
tan h
σ
𝑥𝑡
ℎ𝑡−1
𝐶𝑡−1
tan h
ℎ𝑡
σ
ℎ𝑡
𝑜𝑡
116. 태깅 작업
RNN의 다 대 다 문제
링크 : https://wikidocs.net/33805
117. 일 대 다(one-to-many) 다 대 일(many-to-one) 다 대 다(many-to-many)
return_sequences = True
케라스에서 return_sequences=True를 하면
모든 time step에서 hidden state를 출력
시퀀스 레이블링 작업(ex) 태깅 작업)은 다 대 다 RNN으로 구현한다.
입력 시퀀스로부터 하나의 결론을 내는 작업(ex) 텍스트 분류)는
다 대 일 RNN으로 구현한다.
118. EU rejects GERMAN
B-ORG O B-MISC
𝑥1
𝑦1
𝑥2
𝑦2
𝑥3
𝑦3
O
x2
y2
𝑥4
𝑦4
call
단방향 RNN으로
태깅 작업을 할 경우
119. EU rejects GERMAN call
B-ORG O B-MISC O
𝑦1 𝑦2 𝑦3 𝑦4
𝑥1 𝑥2 𝑥3 𝑥4
양방향 RNN으로 태깅 작업을 할 경우.
앞의 단어들도 참고하고 뒤의 단어들도 참고한다.
120. B-Org
O
𝒘𝒐𝒓𝒅𝟏 𝒘𝒐𝒓𝒅𝟐 𝒘𝒐𝒓𝒅𝟑 𝒘𝒐𝒓𝒅𝟒
Activation
Dense
Activation
Dense
Activation
Dense
Activation
Dense
0.7
0.12
0.08
0.04
0.06
I-Org
B-Per
I-Per
embedding embedding embedding embedding
0.02
0.6
0.12
0.08
0.18
0.02
0.01
0.78
0.05
0.14
0.01
0.02
0.06
0.9
0.01
B-Per I-Per B-Org I-Org
양방향 RNN 개체명 인식 모델! 성능이 꽤 좋다.
그런데 아직도 개선할 것은 남아있다.
121. B-Org
O
0.04
0.12
0.08
0.7
0.06
I-Org
B-Per
I-Per
embedding embedding embedding embedding
0.02
0.6
0.12
0.08
0.18
0.02
0.01
0.14
0.05
0.78
0.01
0.02
0.06
0.9
0.01
I-Org I-Per O I-Org
양방향 RNN이 BIO 규칙을 제대로 반영하지 못 할 경우가 있다.
양방향 RNN은 이전 ‘레이블‘ 자체를 다음 ‘레이블'을 결정하는 일에
직접적으로 반영하지는 못 한다. 이전 ‘단어’를 참고는 하지만 예를 들어 I-Per을 결정할 때
앞에 I-Org라는 레이블이 등장했다는 사실에 대한 정보가 충분히 반영되지 못 한다.
Activation
Dense
Activation
Dense
Activation
Dense
Activation
Dense
𝒘𝒐𝒓𝒅𝟏 𝒘𝒐𝒓𝒅𝟐 𝒘𝒐𝒓𝒅𝟑 𝒘𝒐𝒓𝒅𝟒
124. Broadway play produced by
embedding embedding embedding embedding
softmax
0.1 0.05 … 0.7 0.1
cat it … him unity
Dense
ELMo는 사전 훈련된 언어 모델을 사용
125. Broadway play produced
embedding embedding embedding embedding embedding embedding
순방향 언어 모델
(Forward Language Model)
역방향 언어 모델
(Backward Language Model)
Broadway play produced
ELMo는 사전 훈련된 양방향 언어 모델을 사용
(기존의 BiLSTM하고는 다른데, ELMo에서는 양방향으로 분리해서 훈련하는 것에 가깝다.)
여기서는 순방향 언어 모델의 RNN 셀을 초록색,
역방향 언어 모델의 RNN 셀들을 초록색으로 표현하겠다.
126. embedding embedding embedding embedding embedding embedding
순방향 언어 모델
(Forward Language Model)
역방향 언어 모델
(Backward Language Model)
Broadway play produced Broadway play produced
Residual connection을 표현
127. embedding embedding embedding embedding embedding embedding
순방향 언어 모델
(Forward Language Model)
역방향 언어 모델
(Backward Language Model)
Broadway play produced Broadway play produced
128. × s1
× s2
× s3
× s1
× s2
× s3
+
+
=
γ × =
ELMo 표현 연산 과정
1) 각 층의 출력값을 연결(concatenate)한다.
2) 각 층의 출력값 별로 가중치를 준다.
이 가중치를 여기서는 s1, s2, s3라고 합시다.
3) 각 층의 출력값을 모두 더한다.
2)번과 3)번의 단계를 요약하여 가중합(Weighted Sum)을
한다고 할 수 있습니다.
4) 벡터의 크기를 결정하는 스칼라 매개변수를 곱한다.
이 스칼라 매개변수를 여기서는 γ이라고 합시다.
129. ELMo 표현을 NLP 태스크에서 사용하는 방법의 예제
ELMo representation
NLP Tasks
Corpus
biLMs
Embedding vector
embedding
131. je suis étudiant
기계 번역기
(SEQUENCE TO SEQUENCE)
인코더
(Encoder)
디코더
(Decoder)
SEQ2SEQ 모델
CONTEXT
I am a student
je suis étudiant
I am a student
기계 번역은 대표적으로 seq2seq 구조를 가지는 예이다.
여기서는 인코더의 RNN 셀들을 주황색
디코더의 RNN 셀들을 초록색으로 표현하겠다.
132. CONTEXT
LSTM LSTM LSTM LSTM
디코더(Decoder)
0.15
0.21
-0.11
0.91
CONTEXT
I am a student
je suis étudiant <eos>
<sos> je suis étudiant
LSTM LSTM LSTM LSTM
인코더(Encoder)
0.157
-0.25
0.478
-0.78
I
0.78
0.29
-0.96
0.52
am
0.75
-0.81
0.96
0.12
a
0.88
0.17
-0.29
0.48
student
위의 벡터들은 임베딩 벡터들을 나타낸다.
위 벡터는 컨텍스트 벡터를 나타낸다.
133. CONTEXT
LSTM LSTM LSTM LSTM
디코더(Decoder)
0.15
0.21
-0.11
0.91
CONTEXT
I am a student
je suis étudiant <eos>
<sos> je suis étudiant
0.15
0.21
-0.11
0.91
I
0.15
0.21
-0.11
0.91
am
0.15
0.21
-0.11
0.91
a
0.15
0.21
-0.11
0.91
student
embedding layer
LSTM LSTM LSTM LSTM
인코더(Encoder)
embedding embedding embedding embedding embedding embedding embedding embedding
아래의 벡터는 인코더의 hidden state를 의미한다.
134. 현재 time step t에서의 입력 벡터
현재 time step t에서의 은닉 상태
time step t-1에서의
은닉 상태
time step t에서의
은닉 상태
RNN 셀의 입, 출력을 보여준다.
LSTM 셀으로 생각할 경우에는 cell state는 그림에서 생략되었다고 봐야한다.
135. LSTM LSTM LSTM LSTM
디코더(Decoder)
je suis étudiant <eos>
<sos> je suis étudiant
embedding embedding embedding embedding
softmax softmax softmax softmax
Dense Dense Dense Dense
디코더는 기본적으로 RNN 언어모델이다.
이전 time step의 출력을 다음 time step의 입력으로 사용하는
Generation 모델이기 때문이다.
Decoder RNN: A language model that generates the
target sentence conditioned with the encoding created
by the encoder.
136. LSTM LSTM LSTM LSTM
디코더(Decoder)
<sos> je suis étudiant
embedding embedding embedding embedding
CONTEXT
I am a student
LSTM LSTM LSTM LSTM
인코더(Encoder)
embedding embedding embedding embedding
je suis étudiant <eos>
softmax softmax softmax softmax
Dense Dense Dense Dense
완전체 그림
139. étudiant
softmax
LSTM LSTM LSTM
<sos> je suis
embedding embedding embedding
I am a student
LSTM LSTM LSTM LSTM
embedding embedding embedding embedding
softmax
Dense
seq2seq + attention의 완전체 그림
140. LSTM LSTM LSTM
<sos> je suis
embedding embedding embedding
I am a student
LSTM LSTM LSTM LSTM
embedding embedding embedding embedding
dot product
ℎ1 ℎ2 ℎ3 ℎ4
𝑠𝑡−1
𝑇
Attention
Score
𝑒𝑡 = [𝑠𝑡−1
𝑇
ℎ1, . . . , 𝑠𝑡−1
𝑇
ℎ𝑁]
score(𝑠𝑡−1, ℎ𝑖) = 𝑠𝑡−1
𝑇
ℎ𝑖
1. 우선 어텐션 스코어를 구한다.
141. ℎ𝑖
𝑠𝑡−1
𝑇
×
이름 어텐션 스코어 함수
1. 어텐션 스코어를 구하는 방법을
여기서는 dot product(내적)을 사용하였지만
사실 어텐션 스코어 함수를 무엇을 사용하는지에 따라 다르다.
142. LSTM LSTM LSTM
<sos> je suis
embedding embedding embedding
I am a student
LSTM LSTM LSTM LSTM
embedding embedding embedding embedding
softmax
Attention
Distribution
2. 어텐션 분포를 구한다.
𝑒𝑡 = 𝑠𝑡−1
𝑇
ℎ1, . . . , 𝑠𝑡−1
𝑇
ℎ𝑁
𝑒𝑡에 소프트맥스 함수를 사용한다.
143. LSTM LSTM LSTM
<sos> je suis
embedding embedding embedding
I am a student
LSTM LSTM LSTM LSTM
embedding embedding embedding embedding
softmax
Attention Value 𝒂𝒕
ℎ1 ℎ2 ℎ3 ℎ4
3. 가중합한다.
144. LSTM LSTM LSTM
<sos> je suis
embedding embedding embedding
softmax
concatenate
Attention Value 𝒂𝒕
𝒔𝒕−𝟏
𝑣𝑡
4. 연결한다.
155. 트랜스포머(Transformer)
I am a student
je suis étudiant
인코더들
(Encoders)
디코더들
(Decoders)
트랜스포머 모델
I am a student
je suis étudiant
인코더 #1
트랜스포머 모델
I am a student
je suis étudiant
인코더 #2
인코더 #3
인코더 #4
인코더 #5
인코더 #6
디코더 #1
디코더 #2
디코더 #3
디코더 #4
디코더 #5
디코더 #6
156. I am a student
embedding embedding embedding embedding
je suis étudiant <eos>
<sos> je suis étudiant
embedding embedding embedding embedding
Encoders Decoders
Positional Encoding
I am a student
embedding embedding embedding embedding
Positional Encoding
je suis étudiant <eos>
<sos> je suis étudiant
embedding embedding embedding embedding
Encoders Decoders 포지셔널
인코딩이란?
157. I am a student
embedding vector :
positional encoding :
+ + + +
I
am
a
student
+
임베딩 벡터에 값을 더해준다. 그런데 사실 이는 행렬 연산으로도 이해 가능하다.
160. 인코더(Encoder)
FFNN
Multi-head
Self-Attention
I am a student
embedding embedding embedding embedding
Positional Encoding
I am a student
LSTM LSTM LSTM LSTM
embedding embedding embedding embedding
Attention
Distribution
softmax
LSTM 관점에서 생각해보는 셀프 어텐션
175. Decoder Masked Input
Positional Encoding
I am a student
embedding embedding embedding embedding
Positional Encoding
je suis étudiant <eos>
<sos> je suis étudiant
embedding embedding embedding embedding
Encoders Decoders
<sos> je suis étudiant
<sos> je suis étudiant
<sos> je suis étudiant
178. Semi-Supervised Sequence Learning, Google, 2015
<SOS> I am
I am a student
x2
y2
a
LSTM LSTM LSTM
LSTM
I Iove you
positive
x2
y2
3000
LSTM LSTM LSTM
LSTM
LSTM 언어 모델을 사전 훈련 분류 문제에 파인 튜닝
179. ELMo: Deep Contextual Word Embedding, AI2 & University of Washington, 2017
<SOS> I am
I am a student
x2
y2
a
LSTM LSTM LSTM
LSTM
<SOS> I am
I am a student
x2
y2
a
LSTM LSTM LSTM
LSTM
180. ELMo: Deep Contextual Word Embedding, AI2 & University of Washington, 2017
NLP Tasks
biLMs
<SOS> I am
I am a student
x2
y2
a
LSTM LSTM LSTM
LSTM
<SOS> I am
I am a student
x2
y2
a
LSTM LSTM LSTM LSTM
순방향 언어 모델과 역방향 언어 모델을 각각 훈련 사전 훈련된 임베딩에 사용
181. Improving Language Understanding by Generative Pre-training, OpenAI, 2018
<SOS> I am
I am a student
x2
y2
a
Trm Trm Trm
I Iove you
positive
x2
y2
3000
Trm Trm Trm
Trm
Deep(12-layer) Trm 언어 모델을 사전 훈련 분류 문제에 파인 튜닝
Trm
182. 단방향 언어모델 양방향 언어모델
순차적으로 단어를 생성한다. 단어들이 자기 자신을 본다.
<SOS> I am a
I am a student
<SOS> I am a
I am a student