SlideShare ist ein Scribd-Unternehmen logo
1 von 33
Downloaden Sie, um offline zu lesen
Deep Reinforcement Learning
CS294-112, 2017 Fall
Lec18 Meta Learning & Parallelism in RL
손규빈

고려대학교 산업경영공학과
/ 33
목차
1. Meta learning
A. What is meta learning
B. Meta learning with Supervised learning
C. Meta learning with Memory
D. Contextual policies
E. Model agnostic meta learning
2. Parallelism in RL
1. High level scheme & decisions
2. Stochastic Gradient descent
3. Policy gradient
4. Actor critic
5. Online learning
!2
/ 33
Meta Learning
!3
/ 33
What is meta-learning?
!4
- Meta learning = learning to learn

이전에 수 십, 수 백개의 task를 학습했으면 이를 바탕으로

다음 task를 더 효율적으로 학습할 수 있을까
- Multi task learning과 연관성 높음
- 서로 다른 두 커뮤니티에서 사용되는 용어
- Deep learning: learning to learn
- Meta optimization : hyperparams 선택하는 Auto-ML 관련
- 다양한 형태와 방법들이 존재한다.
- Learning an optimizer
- Learning RNN that ingests experiences : 이전 경험들을 학습하는 듯한 모양새
- Learning a representation
/ 33
- Deep RL에서, 특히 model free 알고리즘은 많은 양의 샘플이 필요

“RL 알고리즘을 배우는 것”을 학습할 수 있다면 다른 새로운 task도 더 빨리 학습 가능
- 우리 인간 역시 태어나자마자 뭔갈 잘할 순 없음
- 기존의 경험을 토대로 더 효과적인 학습이 가능한 것이고

역시 먼저 경험을 해야하므로 많은 양의 데이터가 필요하다는 것은 같음
- Meta-learner가 배우는 것
- 더 지능적으로 explore 하는 것
- 가치 없다고 알고 있는 action들은 시도조차 하지 않음(자동차가 박는것)
- 올바른 feature를 더 빠르게 캐치: 다른 task에서 input 특정 부분을 더 주의깊게 봤
다면 이 부분을 이번 task에서도 더 자세히 보는 것. 더 잘 할 가능성 존재
Why is meta-learning is a good idea?
!5
/ 33
Meta-learning with supervised learning
!6
- 일반적인 supervised learning
- supervised meta learning(train set 1-5개)
- 회색 묶음 하나가 하나의 task. 하나의 task를 해
결할 때 meta learning에 대한 parameter 역
시 학습. 아래로 내려갈수록 빠르게 학습
- 즉 전체 train set과 함께 공통적으로 함께 학습
되는 f 함수가 존재. 이 f 함수가 meta-learner
- Classification도 잘해야하고, 전체 데이터셋도
잘 해석해야 함 -> ex) RNN
f(x) → y
f(Dtrain, x) → y
<Image classification, Few shot learning>
/ 33
The meta-learning problem in RL
!7
- Supervised meta-learning:
- reinforcement meta-learning:
f(Dtrain, x) → y
f(Dexperiences, state) → action
Dexperiences = {s1, a1, r1, …, sn, an, rn}
/ 33
Meta-learning in RL with memory
!8
- Agent: 2d agent, 무한하게 넓은 평면에서의 한 점
- Reward : 빨강 동그라미로 이동하면 reward, 다른 지역은 reward 0
- agent는 빨강 동그라미가 어딨는지 모르면서 시작

episode 수는 제한이 있고, 끝나기 전에 목적지에 도달해야 함
- memory가 있는 것이 다음 시도 때 더 나은 성능을 보임. 없는 것은 항상 Chaos.
with memory without memory
1st attempt
2nd attempt
3rd attempt
< water maze >
/ 33
RL2
!9
- Trial : Memory가 공유되는 Meta trial 공간(ex. 빨강 동그라미 위치가 여러개 존재)
- Episode : water maze에서 빨강 동그라미가 한 번 정해지고 그를 찾아가는 하나의 과정

Trial 안에 속해있고, episode 간 memory 공유
- Policy gradient에서 sample들은 서로 독립이고 정보 공유 안됨

여기서 Trial은 Policy gradient의 각 sample과 매칭(에피소드 때문에 헷갈릴 수 있음)
hidden state of RNN
/ 33
RL2
!10
- 각 미로의 모양과 출발점, 목표지점 모두가 random
- RNN policy가 미로를 탐색하는 방법을 학습해야함
- 각 trial 내에선 memory가 공유되므로, trial 내에서 에피소드가 넘어갈 수록

더 나은 성능을 보여야 함
- Trial1에선 잘 학습됨을 볼 수 있고,

Trial2에선 첫 번째 에피소드의 좋은 행동을 다시 이용하지 못함
Trial 1 Trial 2
/ 33
Connection to contextual policies
!11
contextual policy : πθ(a|s, ω)
ω: stack location ω : walking direction
- multi task learning에서 contextual policy는
먼저 무엇을 해야할지 알아내야함
- 가정용 로봇이라면 빨래를 해야할지, 설거지
를 해야할지 판단해야 함
- : context information이자, experience.ω
- context는 이전의 모든 input tuple들을 포괄
하고, 매우 복잡하고 큰 experience 정보임
- context를 가지고 현재 agent가 무엇을 하고
있는지, 뭘 해야하는지 insight를 얻을 수 있음
/ 33
Back to representations
!12
- ImageNet 데이터를 활용한 pre-training은 transfer learning의 가장 대표적인 예제
- Meta learning의 일종이라 이야기할 수 있음
- ImageNet pre-training을 통해 만들어진 feature map이 fine-tuning에 적합할거란 보장 X
pre-training
feature maps other sub-tasks
/ 33
Preparing a model for faster learning
!13
- Model-agnostic meta-learning: 모델에 구애받지 않는 ML
- policy gradient 알고리즘으로 개미가 걷는 것을 학습
- single task learning은 같은 방향으로 걷는 것만 학습하는 것이
고, multi task로 확장하면 여러 방향으로 걷는 것을 의미
- 특정 방향(task)에 대해 학습할 땐 해당 방향에 더 많은 reward
- task i에 대한 reward를 줄 때는 해당 task에 gradient step을 한
번 밟은 후에만 가능. 모든 방향에 대해 동시에 학습할 수 없고,
gradient가 의미하는 것이 얼마나 잘 했냐는 것이므로.
- 매 스텝마다 L1, L2, L3

서로 다른 task에 대한

gradient 구하고,

그 다음 스텝에서

어느 방향으로 갈지 결정.
θ′
θ
θ ← θ + αΔθR(θ)
Single task
θ ← θ + α
∑
i
ΔθRi[θ + αΔθRi(θ)]
Multi task
방향 의미
/ 33
What did we just do?
!14
supervised meta-learning
reinforcement meta-learning
model-agnostic meta-learning
f(Dtrain, x) → y
f(Dtrain, x) → y
fMAML(Dtrain, x) → y
fMAML(Dtrain, x) = fθ′(x)
- MAML 함수는 Neural network로 구성
- Update rule은 기존 방식과 크게 다르지 않다.

Loss를 구할 때 function MAML에 해당하는

Neural net을 사용하는 것 뿐 모든 내용이 비슷하다.
- Inductive bias가 더 심해질 수는 있다.

MAML 방식이 더 나은 것이라고 가정하기 때문
θ′ = θ − α
∑
(x,y)∈Dtrain
ΔθL(fθ(x), y)
/ 33
Meta-learning summary & open problems
!15
- Meta-learning : learning to learn
- Supervised meta-learning : 전체 데이터를 계속적으로 사용. experience.
- RL meta-learning with RNN policies
- 기존 지나온 경험을 RNN으로 해석
- 학습하는 것을 배우기 위해 test time 때 RNN forward 시킴
- Context 정보를 활용만 할 뿐 실질적 학습이라고 볼 순 없음
- Model-agnostic meta-learning
- 익숙한 Gradient descent 방법을 사용
- 기존 모델, 학습방법들과 비슷한 방식
- 기존 RL 알고리즘보다 더 빠르게 학습 가능
/ 33
Meta-learning summary & open problems
!16
- 전망: 이전 경험을 토대로 더 나은 모델 학습 가능
- 현실: 작은 문제들에 대해선 더 나은 성능을 보이고 있고, 다른 task들에도 대체로 우월
- 한계
- RNN은 학습하기가 어렵고, 규모를 확장하기가 어려움
- Model agnostic 방식은 optimization이 잘 안되는 경우 존재
- Designing the right task distribution is hard

Supervised task에서 training, test set의 distribution이 같다고 가정.

집 안의 개로 학습해서 풀밭의 개를 테스트하면 성능이 좋을까?

Meta learning에서도 task를 바꾸는 것이 이와 같은 문제를 야기할 가능성 높음
- Task distribution에 매우 민감

meta-overfitting = overfitting to training task
/ 33
Parallelism in RL
!17
/ 33
Overview
!18
- Policy를 찾는 다양한 학습 방법을 배워옴
- 모든 알고리즘들이 sequential 했다.
- RL 알고리즘을 병렬적으로 처리할 수 있을까?
- Multiple learning threads
- Multiple experience collection threads
/ 33
High-level RL schematic
!19
estimate : fitting the model, dynamicsp(s′|s, a)
compute : sum of rewardŝQ =
T
∑
t′=t
γt′−t
rt′
fit (actor-critic, Q-learning)Qϕ(s, a)
optimize πθ(a|s)
θ ← θ + αΔθJ(θ)
π(s) = argmaxQϕ(s, a)
/ 33
Which parts are slow?
!20
Generate samples
- 물리적으로 존재하는
simulator를 사용한다면
매우 느리다.
- MuJoCo simulator 같
은 소프트웨어를 사용하
면 실제 시간보다 1만배
더 빠르게 가능
Fitting a model
- reward를 계산하는 것은

매우 싸고 빠름
- Q function을 fitting하는 것
은 계산비용이 높지만 해결
가능한 트릭들 존재
Improve the policy
- Q function 값을 최대화하는
policy를 찾는 것은 빠름.
- policy를 최적화하는 것은 계
산비용 높음
/ 33
Which parts can we parallelize?
!21
모든 부분
parallelize 가능
/ 33
High-level decisions
!22
- Online learning : 데이터를 모으는 즉시 바로바로 알고리즘 학습

Batch learning : Policy gradient가 작동하는 방식. Big bucket of experience.
- Synchronous or Asynchronous
Parallelize Policy gradient
- 대량의 sample을 병렬로 동시에 생성
- Batch + Synchronous
Parallelize Q-learning
- Sample 생성, SGD fitting 각각 병렬화
- Synchronous point.
/ 33
Relationship to parallelized SGD
!23
1. 병렬 처리를 한다는 말은 SGD를 병렬화하겠다는 의미
2. Simple parallel SGD
1. 각각의 worker는 서로 다른 부분의 데이터를 가지고 있음
2. worker 별로 gradient들을 계산하고 server로 보냄
3. Server는 들어온 worker들의 gradient들을 합하고, 새로운 parameter를
worker들에게 내보냄
3. 수학적으로 SGD와 동일하지만, asynchronous는 아님(전송 속도 delay)
1. 각 worker가 server로 전송하는 시간, server가 합산하고 다시 내보내는 시간
2. 이러한 연산 및 전송 시간에는 worker가 synchronous 해야함
4. 즉 SGD는 완벽하게 병렬화를 할 순 없지만, 만약 old state를 가지고 update할 수
있도록 느슨하게 허용한다면 학습 속도는 훨씬 빨라질 수 있음
5. 어떤 task, 어떤 problem이냐에 따라서 달라짐
/ 33
Simple example: sample parallelism with PG (1)
!24
1. Collect samples by running N times
2. Compute
3. Compute
4. Update :
τi = {si
1, ai
1, …, si
T, ai
T} πθ(at |st)
ri = r(τi)
Δi = (
∑
t
Δθlogπθ(ai
t |si
t))(ri − b)
θ ← θ + α
∑
i
Δi
Sample은 서로 완전히 독립이므로
Sample을 생성하는 1번 과정을 병렬화하는 것이
가장 쉬운 방법
/ 33
Simple example: sample parallelism with PG (2)
!25
1. Collect samples by running N times
2. Compute
3. Compute
4. Update :
τi = {si
1, ai
1, …, si
T, ai
T} πθ(at |st)
ri = r(τi)
Δi = (
∑
t
Δθlogπθ(ai
t |si
t))(ri − b)
θ ← θ + α
∑
i
Δi
Reward를 계산하는 과정도
독립이므로 병렬화 가능
/ 33
1. Collect samples by running N times
2. Compute
3. Compute
4. Update :
Simple example: sample parallelism with PG (3)
!26
τi = {si
1, ai
1, …, si
T, ai
T}
ri = r(τi)
Δi = (
∑
t
Δθlogπθ(ai
t |si
t))(ri − b)
θ ← θ + α
∑
i
Δi
역시 독립 -> 병렬화
πθ(at |st)
SGD와
동일한 방식
/ 33
1. Collect samples by running N times
2. Compute
3. Update with regression to target values
4. Compute
5. Update :
What if we add a critic?
!27
τi = {si
1, ai
1, …, si
T, ai
T}
ri = r(τi)
̂Aϕ(si
t, ai
t)
θ ← θ + α
∑
i
Δi
πθ(at |st)
Δi = (
∑
t
Δθlogπθ(ai
t |si
t)) ̂Aϕ(si
t, ai
t)
Synchronization point
4번 PG 과정 수행하려면 Critic에 접근 필요
3번이 완료되어야 가능한 작업
/ 33
What if we add a critic?
!28
1. Collect samples by running N times
2. Compute
3. Update with regression to target values
4. Compute
5. Update :
τi = {si
1, ai
1, …, si
T, ai
T}
ri = r(τi)
̂Aϕ(si
t, ai
t)
θ ← θ + α
∑
i
Δi
πθ(at |st)
Δi = (
∑
t
Δθlogπθ(ai
t |si
t)) ̂Aϕ(si
t, ai
t)
Practical way: Drop the sync point
실제로는 asynchronous SGD trick을 사용
Critic이 완전히 업데이트되지 않더라도 그냥 사용
/ 33
What if we run online?
!29
1. Collect samples by running N times
2. Compute
3. Update with regression to target values
4. Compute
5. Update :
τi = {si
1, ai
1, …, si
T, ai
T}
ri = r(τi)
̂Aϕ(si
t, ai
t)
θ ← θ + α
∑
i
Δi
πθ(at |st)
Δi = (
∑
t
Δθlogπθ(ai
t |si
t)) ̂Aϕ(si
t, ai
t)
Synchronization point
parameter를 업데이트하는 5번 과정만 sync
이전 drop-sync critic과 동일
/ 33
Asynchronous Actor-Critic Agents (A3C)
!30
1. Collect samples by running for 1 step
2. Compute
3. Update with regression to target values
4. Compute
5. Update :
(si, ai, s′i)
ri = r(τi)
̂Aϕ(si
t, ai
t)
θ ← θ + α
∑
i
Δi
πθ(at |st)
Δi = Δθlogπθ(ai
|si
) ̂Aϕ(si
, ai
)
Asynchronous SGD in the actor-critic
- 여러 worker threads가 experience 수집
- Update policy, critic
- Server로 update된 parameter 전송
- Server가 parameter 합산해서 다시 back
알고리즘의 특징
- workers 마다 exploration 의 다양성 존재(다른 parameter) -> bootstrap과 비슷한 효과
- 장점 : 전체 소요 시간 관점에선 Fully synchronous 알고리즘보다 훨씬 빠름
- 단점 : sample의 개수의 관점에선 확실히 느림
/ 33
Actor-critic algorithm: A3C
!31
노란색 그래프가 A3C
worker 마다 조금 다른 parameter -> exploration benefit
- A3C 20M step

+ 절대적 학습 시간은 빠르지만

+ step, sample 수 관점에선 느림
- DDPG 1M step
/ 33
Multiple experience collection threads
!32
/ 33
Questions
감사합니다.
!33

Weitere ähnliche Inhalte

Was ist angesagt?

딥러닝 자연어처리 - RNN에서 BERT까지
딥러닝 자연어처리 - RNN에서 BERT까지딥러닝 자연어처리 - RNN에서 BERT까지
딥러닝 자연어처리 - RNN에서 BERT까지deepseaswjh
 
Variational Autoencoder를 여러 가지 각도에서 이해하기 (Understanding Variational Autoencod...
Variational Autoencoder를 여러 가지 각도에서 이해하기 (Understanding Variational Autoencod...Variational Autoencoder를 여러 가지 각도에서 이해하기 (Understanding Variational Autoencod...
Variational Autoencoder를 여러 가지 각도에서 이해하기 (Understanding Variational Autoencod...Haezoom Inc.
 
인공 신경망 구현에 관한 간단한 설명
인공 신경망 구현에 관한 간단한 설명인공 신경망 구현에 관한 간단한 설명
인공 신경망 구현에 관한 간단한 설명Woonghee Lee
 
Bag of Tricks for Image Classification with Convolutional Neural Networks (C...
Bag of Tricks for Image Classification  with Convolutional Neural Networks (C...Bag of Tricks for Image Classification  with Convolutional Neural Networks (C...
Bag of Tricks for Image Classification with Convolutional Neural Networks (C...gohyunwoong
 
2017 tensor flow dev summit
2017 tensor flow dev summit2017 tensor flow dev summit
2017 tensor flow dev summitTae Young Lee
 
Pretrained summarization on distillation
Pretrained summarization on distillationPretrained summarization on distillation
Pretrained summarization on distillationgohyunwoong
 
Ml for 정형데이터
Ml for 정형데이터Ml for 정형데이터
Ml for 정형데이터JEEHYUN PAIK
 
Machine translation survey vol2
Machine translation survey   vol2Machine translation survey   vol2
Machine translation survey vol2gohyunwoong
 
Machine learning linearregression
Machine learning linearregressionMachine learning linearregression
Machine learning linearregressionHaYoungChoi17
 
랩탑으로 tensorflow 도전하기 - tutorial
랩탑으로 tensorflow 도전하기 - tutorial랩탑으로 tensorflow 도전하기 - tutorial
랩탑으로 tensorflow 도전하기 - tutorialLee Seungeun
 
PYCON KR 2017 - 구름이 하늘의 일이라면 (윤상웅)
PYCON KR 2017 - 구름이 하늘의 일이라면 (윤상웅)PYCON KR 2017 - 구름이 하늘의 일이라면 (윤상웅)
PYCON KR 2017 - 구름이 하늘의 일이라면 (윤상웅)Haezoom Inc.
 
Tensorflow for Deep Learning(SK Planet)
Tensorflow for Deep Learning(SK Planet)Tensorflow for Deep Learning(SK Planet)
Tensorflow for Deep Learning(SK Planet)Tae Young Lee
 
딥러닝의 기본
딥러닝의 기본딥러닝의 기본
딥러닝의 기본deepseaswjh
 
Siamese neural networks for one shot image recognition paper explained
Siamese neural networks for one shot image recognition paper explainedSiamese neural networks for one shot image recognition paper explained
Siamese neural networks for one shot image recognition paper explainedtaeseon ryu
 
Variational inference intro. (korean ver.)
Variational inference intro. (korean ver.)Variational inference intro. (korean ver.)
Variational inference intro. (korean ver.)Kiho Hong
 
Chapter 15 Representation learning - 1
Chapter 15 Representation learning - 1Chapter 15 Representation learning - 1
Chapter 15 Representation learning - 1KyeongUkJang
 
딥러닝 기본 원리의 이해
딥러닝 기본 원리의 이해딥러닝 기본 원리의 이해
딥러닝 기본 원리의 이해Hee Won Park
 
A Beginner's guide to understanding Autoencoder
A Beginner's guide to understanding AutoencoderA Beginner's guide to understanding Autoencoder
A Beginner's guide to understanding AutoencoderLee Seungeun
 

Was ist angesagt? (20)

딥러닝 자연어처리 - RNN에서 BERT까지
딥러닝 자연어처리 - RNN에서 BERT까지딥러닝 자연어처리 - RNN에서 BERT까지
딥러닝 자연어처리 - RNN에서 BERT까지
 
Variational Autoencoder를 여러 가지 각도에서 이해하기 (Understanding Variational Autoencod...
Variational Autoencoder를 여러 가지 각도에서 이해하기 (Understanding Variational Autoencod...Variational Autoencoder를 여러 가지 각도에서 이해하기 (Understanding Variational Autoencod...
Variational Autoencoder를 여러 가지 각도에서 이해하기 (Understanding Variational Autoencod...
 
인공 신경망 구현에 관한 간단한 설명
인공 신경망 구현에 관한 간단한 설명인공 신경망 구현에 관한 간단한 설명
인공 신경망 구현에 관한 간단한 설명
 
Bag of Tricks for Image Classification with Convolutional Neural Networks (C...
Bag of Tricks for Image Classification  with Convolutional Neural Networks (C...Bag of Tricks for Image Classification  with Convolutional Neural Networks (C...
Bag of Tricks for Image Classification with Convolutional Neural Networks (C...
 
2017 tensor flow dev summit
2017 tensor flow dev summit2017 tensor flow dev summit
2017 tensor flow dev summit
 
Pretrained summarization on distillation
Pretrained summarization on distillationPretrained summarization on distillation
Pretrained summarization on distillation
 
Ml for 정형데이터
Ml for 정형데이터Ml for 정형데이터
Ml for 정형데이터
 
Machine translation survey vol2
Machine translation survey   vol2Machine translation survey   vol2
Machine translation survey vol2
 
Machine learning linearregression
Machine learning linearregressionMachine learning linearregression
Machine learning linearregression
 
랩탑으로 tensorflow 도전하기 - tutorial
랩탑으로 tensorflow 도전하기 - tutorial랩탑으로 tensorflow 도전하기 - tutorial
랩탑으로 tensorflow 도전하기 - tutorial
 
PYCON KR 2017 - 구름이 하늘의 일이라면 (윤상웅)
PYCON KR 2017 - 구름이 하늘의 일이라면 (윤상웅)PYCON KR 2017 - 구름이 하늘의 일이라면 (윤상웅)
PYCON KR 2017 - 구름이 하늘의 일이라면 (윤상웅)
 
Tensorflow for Deep Learning(SK Planet)
Tensorflow for Deep Learning(SK Planet)Tensorflow for Deep Learning(SK Planet)
Tensorflow for Deep Learning(SK Planet)
 
딥러닝의 기본
딥러닝의 기본딥러닝의 기본
딥러닝의 기본
 
Siamese neural networks for one shot image recognition paper explained
Siamese neural networks for one shot image recognition paper explainedSiamese neural networks for one shot image recognition paper explained
Siamese neural networks for one shot image recognition paper explained
 
GPT-X
GPT-XGPT-X
GPT-X
 
Variational inference intro. (korean ver.)
Variational inference intro. (korean ver.)Variational inference intro. (korean ver.)
Variational inference intro. (korean ver.)
 
Chapter 15 Representation learning - 1
Chapter 15 Representation learning - 1Chapter 15 Representation learning - 1
Chapter 15 Representation learning - 1
 
딥러닝 기본 원리의 이해
딥러닝 기본 원리의 이해딥러닝 기본 원리의 이해
딥러닝 기본 원리의 이해
 
A Beginner's guide to understanding Autoencoder
A Beginner's guide to understanding AutoencoderA Beginner's guide to understanding Autoencoder
A Beginner's guide to understanding Autoencoder
 
MiniFlow
MiniFlowMiniFlow
MiniFlow
 

Ähnlich wie CS294-112 18

Introduction to SAC(Soft Actor-Critic)
Introduction to SAC(Soft Actor-Critic)Introduction to SAC(Soft Actor-Critic)
Introduction to SAC(Soft Actor-Critic)Suhyun Cho
 
Metric Learning 세미나.pptx
Metric Learning 세미나.pptxMetric Learning 세미나.pptx
Metric Learning 세미나.pptxDongkyunKim17
 
Metric learning 세미나
Metric learning 세미나Metric learning 세미나
Metric learning 세미나ssuser198c901
 
Transfer learning usage
Transfer learning usageTransfer learning usage
Transfer learning usageTae Young Lee
 
Guided policy search
Guided policy searchGuided policy search
Guided policy searchJaehyeon Park
 
Chapter 11 Practical Methodology
Chapter 11 Practical MethodologyChapter 11 Practical Methodology
Chapter 11 Practical MethodologyKyeongUkJang
 
Coursera Machine Learning (by Andrew Ng)_강의정리
Coursera Machine Learning (by Andrew Ng)_강의정리Coursera Machine Learning (by Andrew Ng)_강의정리
Coursera Machine Learning (by Andrew Ng)_강의정리SANG WON PARK
 
Improving Language Understanding by Generative Pre-Training
Improving Language Understanding by Generative Pre-TrainingImproving Language Understanding by Generative Pre-Training
Improving Language Understanding by Generative Pre-Trainingpko89403
 
개발자를 위한 공감세미나 tensor-flow
개발자를 위한 공감세미나 tensor-flow개발자를 위한 공감세미나 tensor-flow
개발자를 위한 공감세미나 tensor-flow양 한빛
 
Deep neural networks for You-Tube recommendations
Deep neural networks for You-Tube recommendationsDeep neural networks for You-Tube recommendations
Deep neural networks for You-Tube recommendationsseungwoo kim
 
Automated program corrector for programming assignments using Deep Learning
Automated program corrector for programming assignments using Deep LearningAutomated program corrector for programming assignments using Deep Learning
Automated program corrector for programming assignments using Deep LearningSoo Kim
 
딥러닝을 위한 Tensor flow(skt academy)
딥러닝을 위한 Tensor flow(skt academy)딥러닝을 위한 Tensor flow(skt academy)
딥러닝을 위한 Tensor flow(skt academy)Tae Young Lee
 
220112 지승현 mauve
220112 지승현 mauve220112 지승현 mauve
220112 지승현 mauvessuser23ed0c
 
211223 지승현 text generation survey
211223 지승현 text generation survey211223 지승현 text generation survey
211223 지승현 text generation surveyssuser23ed0c
 
Chapter 8 - optimization for training deep models
Chapter 8 - optimization for training deep modelsChapter 8 - optimization for training deep models
Chapter 8 - optimization for training deep modelsKyeongUkJang
 
Ch.5 machine learning basics
Ch.5  machine learning basicsCh.5  machine learning basics
Ch.5 machine learning basicsJinho Lee
 
Chapter 17 monte carlo methods
Chapter 17 monte carlo methodsChapter 17 monte carlo methods
Chapter 17 monte carlo methodsKyeongUkJang
 
[홍대 머신러닝 스터디 - 핸즈온 머신러닝] 1장. 한눈에 보는 머신러닝
[홍대 머신러닝 스터디 - 핸즈온 머신러닝] 1장. 한눈에 보는 머신러닝[홍대 머신러닝 스터디 - 핸즈온 머신러닝] 1장. 한눈에 보는 머신러닝
[홍대 머신러닝 스터디 - 핸즈온 머신러닝] 1장. 한눈에 보는 머신러닝Haesun Park
 
Survey of activation functions
Survey of activation functionsSurvey of activation functions
Survey of activation functions창기 문
 

Ähnlich wie CS294-112 18 (20)

Introduction to SAC(Soft Actor-Critic)
Introduction to SAC(Soft Actor-Critic)Introduction to SAC(Soft Actor-Critic)
Introduction to SAC(Soft Actor-Critic)
 
PaLM Paper Review
PaLM Paper ReviewPaLM Paper Review
PaLM Paper Review
 
Metric Learning 세미나.pptx
Metric Learning 세미나.pptxMetric Learning 세미나.pptx
Metric Learning 세미나.pptx
 
Metric learning 세미나
Metric learning 세미나Metric learning 세미나
Metric learning 세미나
 
Transfer learning usage
Transfer learning usageTransfer learning usage
Transfer learning usage
 
Guided policy search
Guided policy searchGuided policy search
Guided policy search
 
Chapter 11 Practical Methodology
Chapter 11 Practical MethodologyChapter 11 Practical Methodology
Chapter 11 Practical Methodology
 
Coursera Machine Learning (by Andrew Ng)_강의정리
Coursera Machine Learning (by Andrew Ng)_강의정리Coursera Machine Learning (by Andrew Ng)_강의정리
Coursera Machine Learning (by Andrew Ng)_강의정리
 
Improving Language Understanding by Generative Pre-Training
Improving Language Understanding by Generative Pre-TrainingImproving Language Understanding by Generative Pre-Training
Improving Language Understanding by Generative Pre-Training
 
개발자를 위한 공감세미나 tensor-flow
개발자를 위한 공감세미나 tensor-flow개발자를 위한 공감세미나 tensor-flow
개발자를 위한 공감세미나 tensor-flow
 
Deep neural networks for You-Tube recommendations
Deep neural networks for You-Tube recommendationsDeep neural networks for You-Tube recommendations
Deep neural networks for You-Tube recommendations
 
Automated program corrector for programming assignments using Deep Learning
Automated program corrector for programming assignments using Deep LearningAutomated program corrector for programming assignments using Deep Learning
Automated program corrector for programming assignments using Deep Learning
 
딥러닝을 위한 Tensor flow(skt academy)
딥러닝을 위한 Tensor flow(skt academy)딥러닝을 위한 Tensor flow(skt academy)
딥러닝을 위한 Tensor flow(skt academy)
 
220112 지승현 mauve
220112 지승현 mauve220112 지승현 mauve
220112 지승현 mauve
 
211223 지승현 text generation survey
211223 지승현 text generation survey211223 지승현 text generation survey
211223 지승현 text generation survey
 
Chapter 8 - optimization for training deep models
Chapter 8 - optimization for training deep modelsChapter 8 - optimization for training deep models
Chapter 8 - optimization for training deep models
 
Ch.5 machine learning basics
Ch.5  machine learning basicsCh.5  machine learning basics
Ch.5 machine learning basics
 
Chapter 17 monte carlo methods
Chapter 17 monte carlo methodsChapter 17 monte carlo methods
Chapter 17 monte carlo methods
 
[홍대 머신러닝 스터디 - 핸즈온 머신러닝] 1장. 한눈에 보는 머신러닝
[홍대 머신러닝 스터디 - 핸즈온 머신러닝] 1장. 한눈에 보는 머신러닝[홍대 머신러닝 스터디 - 핸즈온 머신러닝] 1장. 한눈에 보는 머신러닝
[홍대 머신러닝 스터디 - 핸즈온 머신러닝] 1장. 한눈에 보는 머신러닝
 
Survey of activation functions
Survey of activation functionsSurvey of activation functions
Survey of activation functions
 

CS294-112 18

  • 1. Deep Reinforcement Learning CS294-112, 2017 Fall Lec18 Meta Learning & Parallelism in RL 손규빈 고려대학교 산업경영공학과
  • 2. / 33 목차 1. Meta learning A. What is meta learning B. Meta learning with Supervised learning C. Meta learning with Memory D. Contextual policies E. Model agnostic meta learning 2. Parallelism in RL 1. High level scheme & decisions 2. Stochastic Gradient descent 3. Policy gradient 4. Actor critic 5. Online learning !2
  • 4. / 33 What is meta-learning? !4 - Meta learning = learning to learn
 이전에 수 십, 수 백개의 task를 학습했으면 이를 바탕으로
 다음 task를 더 효율적으로 학습할 수 있을까 - Multi task learning과 연관성 높음 - 서로 다른 두 커뮤니티에서 사용되는 용어 - Deep learning: learning to learn - Meta optimization : hyperparams 선택하는 Auto-ML 관련 - 다양한 형태와 방법들이 존재한다. - Learning an optimizer - Learning RNN that ingests experiences : 이전 경험들을 학습하는 듯한 모양새 - Learning a representation
  • 5. / 33 - Deep RL에서, 특히 model free 알고리즘은 많은 양의 샘플이 필요
 “RL 알고리즘을 배우는 것”을 학습할 수 있다면 다른 새로운 task도 더 빨리 학습 가능 - 우리 인간 역시 태어나자마자 뭔갈 잘할 순 없음 - 기존의 경험을 토대로 더 효과적인 학습이 가능한 것이고
 역시 먼저 경험을 해야하므로 많은 양의 데이터가 필요하다는 것은 같음 - Meta-learner가 배우는 것 - 더 지능적으로 explore 하는 것 - 가치 없다고 알고 있는 action들은 시도조차 하지 않음(자동차가 박는것) - 올바른 feature를 더 빠르게 캐치: 다른 task에서 input 특정 부분을 더 주의깊게 봤 다면 이 부분을 이번 task에서도 더 자세히 보는 것. 더 잘 할 가능성 존재 Why is meta-learning is a good idea? !5
  • 6. / 33 Meta-learning with supervised learning !6 - 일반적인 supervised learning - supervised meta learning(train set 1-5개) - 회색 묶음 하나가 하나의 task. 하나의 task를 해 결할 때 meta learning에 대한 parameter 역 시 학습. 아래로 내려갈수록 빠르게 학습 - 즉 전체 train set과 함께 공통적으로 함께 학습 되는 f 함수가 존재. 이 f 함수가 meta-learner - Classification도 잘해야하고, 전체 데이터셋도 잘 해석해야 함 -> ex) RNN f(x) → y f(Dtrain, x) → y <Image classification, Few shot learning>
  • 7. / 33 The meta-learning problem in RL !7 - Supervised meta-learning: - reinforcement meta-learning: f(Dtrain, x) → y f(Dexperiences, state) → action Dexperiences = {s1, a1, r1, …, sn, an, rn}
  • 8. / 33 Meta-learning in RL with memory !8 - Agent: 2d agent, 무한하게 넓은 평면에서의 한 점 - Reward : 빨강 동그라미로 이동하면 reward, 다른 지역은 reward 0 - agent는 빨강 동그라미가 어딨는지 모르면서 시작
 episode 수는 제한이 있고, 끝나기 전에 목적지에 도달해야 함 - memory가 있는 것이 다음 시도 때 더 나은 성능을 보임. 없는 것은 항상 Chaos. with memory without memory 1st attempt 2nd attempt 3rd attempt < water maze >
  • 9. / 33 RL2 !9 - Trial : Memory가 공유되는 Meta trial 공간(ex. 빨강 동그라미 위치가 여러개 존재) - Episode : water maze에서 빨강 동그라미가 한 번 정해지고 그를 찾아가는 하나의 과정
 Trial 안에 속해있고, episode 간 memory 공유 - Policy gradient에서 sample들은 서로 독립이고 정보 공유 안됨
 여기서 Trial은 Policy gradient의 각 sample과 매칭(에피소드 때문에 헷갈릴 수 있음) hidden state of RNN
  • 10. / 33 RL2 !10 - 각 미로의 모양과 출발점, 목표지점 모두가 random - RNN policy가 미로를 탐색하는 방법을 학습해야함 - 각 trial 내에선 memory가 공유되므로, trial 내에서 에피소드가 넘어갈 수록
 더 나은 성능을 보여야 함 - Trial1에선 잘 학습됨을 볼 수 있고,
 Trial2에선 첫 번째 에피소드의 좋은 행동을 다시 이용하지 못함 Trial 1 Trial 2
  • 11. / 33 Connection to contextual policies !11 contextual policy : πθ(a|s, ω) ω: stack location ω : walking direction - multi task learning에서 contextual policy는 먼저 무엇을 해야할지 알아내야함 - 가정용 로봇이라면 빨래를 해야할지, 설거지 를 해야할지 판단해야 함 - : context information이자, experience.ω - context는 이전의 모든 input tuple들을 포괄 하고, 매우 복잡하고 큰 experience 정보임 - context를 가지고 현재 agent가 무엇을 하고 있는지, 뭘 해야하는지 insight를 얻을 수 있음
  • 12. / 33 Back to representations !12 - ImageNet 데이터를 활용한 pre-training은 transfer learning의 가장 대표적인 예제 - Meta learning의 일종이라 이야기할 수 있음 - ImageNet pre-training을 통해 만들어진 feature map이 fine-tuning에 적합할거란 보장 X pre-training feature maps other sub-tasks
  • 13. / 33 Preparing a model for faster learning !13 - Model-agnostic meta-learning: 모델에 구애받지 않는 ML - policy gradient 알고리즘으로 개미가 걷는 것을 학습 - single task learning은 같은 방향으로 걷는 것만 학습하는 것이 고, multi task로 확장하면 여러 방향으로 걷는 것을 의미 - 특정 방향(task)에 대해 학습할 땐 해당 방향에 더 많은 reward - task i에 대한 reward를 줄 때는 해당 task에 gradient step을 한 번 밟은 후에만 가능. 모든 방향에 대해 동시에 학습할 수 없고, gradient가 의미하는 것이 얼마나 잘 했냐는 것이므로. - 매 스텝마다 L1, L2, L3
 서로 다른 task에 대한
 gradient 구하고,
 그 다음 스텝에서
 어느 방향으로 갈지 결정. θ′ θ θ ← θ + αΔθR(θ) Single task θ ← θ + α ∑ i ΔθRi[θ + αΔθRi(θ)] Multi task 방향 의미
  • 14. / 33 What did we just do? !14 supervised meta-learning reinforcement meta-learning model-agnostic meta-learning f(Dtrain, x) → y f(Dtrain, x) → y fMAML(Dtrain, x) → y fMAML(Dtrain, x) = fθ′(x) - MAML 함수는 Neural network로 구성 - Update rule은 기존 방식과 크게 다르지 않다.
 Loss를 구할 때 function MAML에 해당하는
 Neural net을 사용하는 것 뿐 모든 내용이 비슷하다. - Inductive bias가 더 심해질 수는 있다.
 MAML 방식이 더 나은 것이라고 가정하기 때문 θ′ = θ − α ∑ (x,y)∈Dtrain ΔθL(fθ(x), y)
  • 15. / 33 Meta-learning summary & open problems !15 - Meta-learning : learning to learn - Supervised meta-learning : 전체 데이터를 계속적으로 사용. experience. - RL meta-learning with RNN policies - 기존 지나온 경험을 RNN으로 해석 - 학습하는 것을 배우기 위해 test time 때 RNN forward 시킴 - Context 정보를 활용만 할 뿐 실질적 학습이라고 볼 순 없음 - Model-agnostic meta-learning - 익숙한 Gradient descent 방법을 사용 - 기존 모델, 학습방법들과 비슷한 방식 - 기존 RL 알고리즘보다 더 빠르게 학습 가능
  • 16. / 33 Meta-learning summary & open problems !16 - 전망: 이전 경험을 토대로 더 나은 모델 학습 가능 - 현실: 작은 문제들에 대해선 더 나은 성능을 보이고 있고, 다른 task들에도 대체로 우월 - 한계 - RNN은 학습하기가 어렵고, 규모를 확장하기가 어려움 - Model agnostic 방식은 optimization이 잘 안되는 경우 존재 - Designing the right task distribution is hard
 Supervised task에서 training, test set의 distribution이 같다고 가정.
 집 안의 개로 학습해서 풀밭의 개를 테스트하면 성능이 좋을까?
 Meta learning에서도 task를 바꾸는 것이 이와 같은 문제를 야기할 가능성 높음 - Task distribution에 매우 민감
 meta-overfitting = overfitting to training task
  • 18. / 33 Overview !18 - Policy를 찾는 다양한 학습 방법을 배워옴 - 모든 알고리즘들이 sequential 했다. - RL 알고리즘을 병렬적으로 처리할 수 있을까? - Multiple learning threads - Multiple experience collection threads
  • 19. / 33 High-level RL schematic !19 estimate : fitting the model, dynamicsp(s′|s, a) compute : sum of rewardŝQ = T ∑ t′=t γt′−t rt′ fit (actor-critic, Q-learning)Qϕ(s, a) optimize πθ(a|s) θ ← θ + αΔθJ(θ) π(s) = argmaxQϕ(s, a)
  • 20. / 33 Which parts are slow? !20 Generate samples - 물리적으로 존재하는 simulator를 사용한다면 매우 느리다. - MuJoCo simulator 같 은 소프트웨어를 사용하 면 실제 시간보다 1만배 더 빠르게 가능 Fitting a model - reward를 계산하는 것은
 매우 싸고 빠름 - Q function을 fitting하는 것 은 계산비용이 높지만 해결 가능한 트릭들 존재 Improve the policy - Q function 값을 최대화하는 policy를 찾는 것은 빠름. - policy를 최적화하는 것은 계 산비용 높음
  • 21. / 33 Which parts can we parallelize? !21 모든 부분 parallelize 가능
  • 22. / 33 High-level decisions !22 - Online learning : 데이터를 모으는 즉시 바로바로 알고리즘 학습
 Batch learning : Policy gradient가 작동하는 방식. Big bucket of experience. - Synchronous or Asynchronous Parallelize Policy gradient - 대량의 sample을 병렬로 동시에 생성 - Batch + Synchronous Parallelize Q-learning - Sample 생성, SGD fitting 각각 병렬화 - Synchronous point.
  • 23. / 33 Relationship to parallelized SGD !23 1. 병렬 처리를 한다는 말은 SGD를 병렬화하겠다는 의미 2. Simple parallel SGD 1. 각각의 worker는 서로 다른 부분의 데이터를 가지고 있음 2. worker 별로 gradient들을 계산하고 server로 보냄 3. Server는 들어온 worker들의 gradient들을 합하고, 새로운 parameter를 worker들에게 내보냄 3. 수학적으로 SGD와 동일하지만, asynchronous는 아님(전송 속도 delay) 1. 각 worker가 server로 전송하는 시간, server가 합산하고 다시 내보내는 시간 2. 이러한 연산 및 전송 시간에는 worker가 synchronous 해야함 4. 즉 SGD는 완벽하게 병렬화를 할 순 없지만, 만약 old state를 가지고 update할 수 있도록 느슨하게 허용한다면 학습 속도는 훨씬 빨라질 수 있음 5. 어떤 task, 어떤 problem이냐에 따라서 달라짐
  • 24. / 33 Simple example: sample parallelism with PG (1) !24 1. Collect samples by running N times 2. Compute 3. Compute 4. Update : τi = {si 1, ai 1, …, si T, ai T} πθ(at |st) ri = r(τi) Δi = ( ∑ t Δθlogπθ(ai t |si t))(ri − b) θ ← θ + α ∑ i Δi Sample은 서로 완전히 독립이므로 Sample을 생성하는 1번 과정을 병렬화하는 것이 가장 쉬운 방법
  • 25. / 33 Simple example: sample parallelism with PG (2) !25 1. Collect samples by running N times 2. Compute 3. Compute 4. Update : τi = {si 1, ai 1, …, si T, ai T} πθ(at |st) ri = r(τi) Δi = ( ∑ t Δθlogπθ(ai t |si t))(ri − b) θ ← θ + α ∑ i Δi Reward를 계산하는 과정도 독립이므로 병렬화 가능
  • 26. / 33 1. Collect samples by running N times 2. Compute 3. Compute 4. Update : Simple example: sample parallelism with PG (3) !26 τi = {si 1, ai 1, …, si T, ai T} ri = r(τi) Δi = ( ∑ t Δθlogπθ(ai t |si t))(ri − b) θ ← θ + α ∑ i Δi 역시 독립 -> 병렬화 πθ(at |st) SGD와 동일한 방식
  • 27. / 33 1. Collect samples by running N times 2. Compute 3. Update with regression to target values 4. Compute 5. Update : What if we add a critic? !27 τi = {si 1, ai 1, …, si T, ai T} ri = r(τi) ̂Aϕ(si t, ai t) θ ← θ + α ∑ i Δi πθ(at |st) Δi = ( ∑ t Δθlogπθ(ai t |si t)) ̂Aϕ(si t, ai t) Synchronization point 4번 PG 과정 수행하려면 Critic에 접근 필요 3번이 완료되어야 가능한 작업
  • 28. / 33 What if we add a critic? !28 1. Collect samples by running N times 2. Compute 3. Update with regression to target values 4. Compute 5. Update : τi = {si 1, ai 1, …, si T, ai T} ri = r(τi) ̂Aϕ(si t, ai t) θ ← θ + α ∑ i Δi πθ(at |st) Δi = ( ∑ t Δθlogπθ(ai t |si t)) ̂Aϕ(si t, ai t) Practical way: Drop the sync point 실제로는 asynchronous SGD trick을 사용 Critic이 완전히 업데이트되지 않더라도 그냥 사용
  • 29. / 33 What if we run online? !29 1. Collect samples by running N times 2. Compute 3. Update with regression to target values 4. Compute 5. Update : τi = {si 1, ai 1, …, si T, ai T} ri = r(τi) ̂Aϕ(si t, ai t) θ ← θ + α ∑ i Δi πθ(at |st) Δi = ( ∑ t Δθlogπθ(ai t |si t)) ̂Aϕ(si t, ai t) Synchronization point parameter를 업데이트하는 5번 과정만 sync 이전 drop-sync critic과 동일
  • 30. / 33 Asynchronous Actor-Critic Agents (A3C) !30 1. Collect samples by running for 1 step 2. Compute 3. Update with regression to target values 4. Compute 5. Update : (si, ai, s′i) ri = r(τi) ̂Aϕ(si t, ai t) θ ← θ + α ∑ i Δi πθ(at |st) Δi = Δθlogπθ(ai |si ) ̂Aϕ(si , ai ) Asynchronous SGD in the actor-critic - 여러 worker threads가 experience 수집 - Update policy, critic - Server로 update된 parameter 전송 - Server가 parameter 합산해서 다시 back 알고리즘의 특징 - workers 마다 exploration 의 다양성 존재(다른 parameter) -> bootstrap과 비슷한 효과 - 장점 : 전체 소요 시간 관점에선 Fully synchronous 알고리즘보다 훨씬 빠름 - 단점 : sample의 개수의 관점에선 확실히 느림
  • 31. / 33 Actor-critic algorithm: A3C !31 노란색 그래프가 A3C worker 마다 조금 다른 parameter -> exploration benefit - A3C 20M step
 + 절대적 학습 시간은 빠르지만
 + step, sample 수 관점에선 느림 - DDPG 1M step
  • 32. / 33 Multiple experience collection threads !32