Lecture 2. Imitation Learning Part 3 ~ Lecture 3. PyTorch

Lecture 2. Part 3

https://rail.eecs.berkeley.edu/deeprlcourse/deeprlcourse/static/slides/lec-2.pdf

Addressing the problem in practice

μ•žμ„œ behavioral cloning μ—μ„œ λ°œμƒν•œ λ¬Έμ œλ“€μ„ μ‹€μ œλ‘œλŠ” μ–΄λ–€ μ‹μœΌλ‘œ ν•΄κ²°ν•˜λŠ”μ§€ 닀뀄본닀.

μ•žμ„œ μž‘μ€ mistake κ°€ 생기면 μ–΄λ–»κ²Œ ν•΄μ•Όν• μ§€ λͺ¨λ₯΄λŠ” 문제둜 인해 mistake 이 λˆ„μ λ˜κ³  κ²°κ΅­μ—λŠ” 큰 차이가 생겼닀고 μ–ΈκΈ‰ν–ˆμ—ˆλ‹€.

Be smart about how we collect (and augment) our data

ν•™μŠ΅ 데이터에 mistake κ°€ ν¬ν•¨λ˜μ–΄ μžˆλ‹€λ©΄, 이λ₯Ό μˆ˜μ •ν•˜λŠ” 방법을 μ•Œλ €μ€„ 수 μžˆμ„ 것이닀. κ·Έλž˜μ„œ μ˜λ„μ μœΌλ‘œ mistake 와 μˆ˜μ •μ‚¬ν•­μ„ 데이터셋에 넣을 μˆ˜λ„ μžˆλ‹€. (λ¬Όλ‘  데이터셋이 μ’‹μ§€λŠ” μ•Šμ§€λ§Œ 였히렀 μˆ˜μ •μ‚¬ν•­μ΄ 더해져 μžˆλŠ” 것이 쒋은 κ²½μš°λ„ 있음.)

또 λ‹€λ₯Έ 방법은 data augmentation 이닀. κ°€μ§œ 데이터λ₯Ό μΆ”κ°€ν•˜μ—¬ μœ„μ™€ μœ μ‚¬ν•œ 효과λ₯Ό 얻을 수 μžˆλ‹€.

  • Case study 1: trail following as classification: μ‚¬λžŒμ΄ 직접 μ •λ©΄, 쒌/우츑면 카메라λ₯Ό μž₯μ°©ν•˜κ³  μˆ²μ†μ„ κ±°λ‹Œ 데이터λ₯Ό ν™œμš©
  • Case study 2: imitation with a cheap robot

Use very powerful models that make very few mistakes

데이터λ₯Ό 잘 λ‹€λ£¨λŠ” 것도 μ€‘μš”ν•˜μ§€λ§Œ μ΄κ²ƒλ§ŒμœΌλ‘œ μΆ©λΆ„νžˆ μ‹ λ’°ν•  μˆ˜λŠ” μ—†κ³ , 근본적인 원인을 ν•΄κ²°ν•  ν•„μš”μ„±μ΄ μžˆλ‹€.

Why might we fail to fit the expert?

본질적으둜 μ™œ μ „λ¬Έκ°€μ˜ 행동과 μΌμΉ˜ν•˜κ²Œ λ§Œλ“€κΈ° μ–΄λ €μš΄μ§€ μ•Œμ•„λ³΄μž.

  1. Non-markovian behavior

μš°λ¦¬κ°€ κ΅¬μ„±ν•œ policy λŠ” ν˜„μž¬μ˜ observation λ₯Ό 기반으둜 ν•œλ‹€.

ν•˜μ§€λ§Œ μ‹€μ œλ‘œ μ „λ¬Έκ°€κ°€ μ–΄λ–€ 행동을 ν•  λ•ŒλŠ” 이전에 μ§„ν–‰ν•œ λ‚΄μš©λ“€μ„ λͺ¨λ‘ κΈ°μ–΅ν•˜κ³  행동을 μ·¨ν•œλ‹€. 우리의 policy 에 λ”°λ₯΄λ©΄ 이전에 μ–΄λ–€ 일이 μΌμ–΄λ‚¬λŠ”μ§€μ™€ 관계없이 같은 것을 λ³Έλ‹€λ©΄ 같은 행동을 ν•˜λ„λ‘ λ˜μ–΄μžˆκ³ , μ΄λŠ” 맀우 λΆ€μžμ—°μŠ€λŸ½λ‹€.

How can we use the whole history?

μ—¬λŸ¬ 개의 ν”„λ ˆμž„μ„ μ‚¬μš©ν•˜μ—¬ μ΄μ „μ˜ κΈ°μ–΅(history of observation)을 포함할 수 μžˆλŠ” policy λ₯Ό μ„Έμš΄λ‹€. 이λ₯Ό μ²˜λ¦¬ν•˜κΈ° μœ„ν•΄ sequence model 을 ν™œμš©ν•œλ‹€. (Transformer, LSTM cells, etc.)

μ΄λŸ¬ν•œ 방식도 잘 μž‘λ™ν•˜μ§€ μ•Šμ„ 수 μžˆλ‹€. μ—¬λŸ¬ ν”„λ ˆμž„μ„ μ‚¬μš©ν•˜μ—¬ ν•™μŠ΅μ„ ν•˜κΈ° λ•Œλ¬Έμ— 사건에 따라 각 ν”„λ ˆμž„ κ°„μ˜ 상관관계λ₯Ό 잘λͺ» νŒŒμ•…ν•˜λŠ” causal confusion 이 μƒκΈ°λŠ” 것이닀.

κ°•μ˜μ—μ„œλŠ” 브레이크 ν‘œμ‹œλ“±κ³Ό μ „λ©΄λΆ€κ°€ 같이 μžˆλŠ” 이미지λ₯Ό μ˜ˆμ‹œλ‘œ λ“€μ—ˆλ‹€. λ§Œμ•½ μ‚¬λžŒμ΄ λ‚˜νƒ€λ‚˜μ„œ 브레이크 ν‘œμ‹œλ“±μ΄ μΌœμ‘Œλ‹€λ©΄, 이것은 ν‘œμ‹œλ“±μ΄ 원인이 μ•„λ‹ˆλΌ μ‚¬λžŒμ΄ λ‚˜νƒ€λ‚œ 것이 μ§„μ§œ 원인이닀.

κ·ΈλŸ¬λ‚˜ 이후에 ν‘œμ‹œλ“±μ΄ 계속 μΌœμ§€λ©΄μ„œ λͺ¨λΈμ€ ν‘œμ‹œλ“±κ³Ό 감속 κ°„μ˜ 인과관계에 μ§‘μ€‘ν•˜κ²Œ λœλ‹€. κ·Έλž˜μ„œ μ΄λŸ¬ν•œ 방식은 보쑰μž₯μΉ˜μ™€ μ§„μ§œ 원인과 ν˜Όλ™μ„ μ•ΌκΈ°ν•˜κ³  잘λͺ»λœ 상관관계λ₯Ό μœ λ„ν•  수 μžˆλ‹€.

Question

  • Q 1: Does including history mitigate casual confusion?
  • Q 2: Can DAgger mitigate causal confusion?
  1. Multimodal behavior

μ™Όμͺ½, 였λ₯Έμͺ½κ³Ό 직선과 같이 이산적인 νŒλ‹¨μ„ 내릴 λ•ŒλŠ” λ¬Έμ œκ°€ λ˜μ§€ μ•Šμ§€λ§Œ 연속적인 행동을 μˆ˜ν–‰ν•  λ•ŒλŠ” λ¬Έμ œκ°€ μžˆλ‹€.

μœ„μ™€ 같이, 직선을 μ œμ™Έν•œ 쒌우츑으둜 이동해야 ν•˜λŠ” 경우 좜λ ₯을 κ°€μš°μ‹œμ•ˆ λΆ„ν¬λ‘œ ν‘œν˜„ν•˜λ©΄ ν•˜λ‚˜μ˜ 평균과 λΆ„μ‚°μœΌλ‘œ 이루어져 있기 λ•Œλ¬Έμ΄λ‹€.

κ·Έλž˜μ„œ 연속적인 뢄포λ₯Ό μ„€λͺ…κ°€λŠ₯ν•œ λ‹€λ₯Έ 방식을 μ‚¬μš©ν•˜κ±°λ‚˜, 이산화λ₯Ό μ—¬μ „νžˆ μ‚¬μš©ν•˜λ˜ 더 κ³ μ°¨μ›μ˜ κ³΅κ°„μ—μ„œ μ‚¬μš©ν•˜λŠ” 방법이 μžˆλ‹€.

Expressive continuous distributions

  1. Mixture of Gaussians
  2. Latent variable models
  3. Diffusion models

discretization

μ΄μ‚°ν™”λŠ” λ³΅μž‘ν•œ 뢄포λ₯Ό ν‘œν˜„ν•˜λŠ”λ° 쒋은 λ°©λ²•μ΄μ§€λ§Œ κ³ μ°¨μ›μ˜ space λ₯Ό μ΄μ‚°ν™”λ‘œ λ°”λ‘œ ν‘œν˜„ν•˜λŠ” 것은 μ–΄λ ΅λ‹€.

μ™œλƒν•˜λ©΄ 차원이 λ†’μ•„μ§ˆ 수둝 ν‘œν˜„ν•΄μ•Ό ν•˜λŠ”λ° ν•„μš”ν•œ κ΅¬κ°„μ˜ μˆ˜κ°€ κΈ°ν•˜κΈ‰μˆ˜μ μœΌλ‘œ λŠ˜μ–΄λ‚œλ‹€.

λ”°λΌμ„œ, ν•œ 번의 ν•œ μ°¨μ›λ§Œ ν‘œν˜„ν•˜λŠ” autoregressive discretization 을 μ‚¬μš©ν•œλ‹€.

LSTM μ΄λ‚˜ Transformer 와 같은 sequence model 둜 μΈμ½”λ”©ν•˜μ—¬ μ΄μ‚°ν™”λœ κ²°κ³Όλ₯Ό μ–»μœΌλ©΄ 이λ₯Ό μ—°μ†μ μœΌλ‘œ λ„£μ–΄ λ‹€μŒ μ˜ˆμΈ‘μ„ μ–»μ–΄λ‚Έλ‹€.

이λ₯Ό μˆ˜μ‹μ μœΌλ‘œ ν‘œν˜„ν•˜λ©΄ κ²°κ΅­ λͺ¨λ“  에 λŒ€ν•œ ν™•λ₯ λΆ„포λ₯Ό μ–»κΈ° λ•Œλ¬Έμ΄λ‹€. λ”°λΌμ„œ autoregressive discretization λŠ” 맀우 쒋은 λ°©μ‹μ΄μ§€λ§Œ λ¬΄κ²λ‹€λŠ” 단점이 μžˆλ‹€.

  • Case study 3: imitation with diffusion model (Chi et al, Diffusion Policy: Visuomotor Policy Learning via Action Diffusion)
  • Case study 4: imitation with latent variable (Zhao et al. Learning Fine-Graned Bimanual Manipulation with Low-Cost Hardward)
  • Case study 5: imitation with Transformeres (Brohan et al. RT-1: Robotics Transformer), transfomersλ₯Ό ν™œμš©ν•œ discretization 방법

Use multi-task learning

Does learning many tasks become easier?

μ΄μ „μ²˜λŸΌ ν•˜λ‚˜μ˜ μœ„μΉ˜ 을 λ„λ‹¬ν•˜κΈ° μœ„ν•œ μ „λ¬Έκ°€μ˜ ν•™μŠ΅ 데이터λ₯Ό κ΅¬μ„±ν•˜λŠ” 것이 μ•„λ‹ˆλΌ μ—¬λŸ¬ 개의 λ₯Ό λ„λ‹¬ν•˜λŠ” 과정을 ν•™μŠ΅ν•˜λŠ” 것이닀.

μ΄λŸ¬ν•œ 방법은 μ˜λ„μ μœΌλ‘œ μ‹€μˆ˜λ₯Ό λ„£κ±°λ‚˜ augmentation 없이 λ‹€μ–‘ν•œ state μ—μ„œ 데이터λ₯Ό 얻을 수 있게 λœλ‹€. 즉, μ „λ¬Έκ°€κ°€ 으둜 κ°€κΈ° μœ„ν•œ 졜적의 κ²½λ‘œμ—μ„œ λ°©λ¬Έν•˜μ§€ μ•Šμ€ λ‹€λ₯Έ state 듀이 λ‹€λ₯Έ λ₯Ό λ„λ‹¬ν•˜κΈ° μœ„ν•œ κ²½λ‘œμ—μ„œ μ–»κ²Œ λ˜λŠ” 것이닀.

Related works

  • Learning Latent Plans from Play, C. Lynch et al. Google Brain
  • Unsupervised Visuomotor Control through Distributional Planning Networks, Yu, Tianhe, et al.
  • Learning to Reach Goals via Iterated Supervised Learning, D. Ghosh et al., UCB
  • GNM: A General Navigation Model to Drive Any Robot, Shah et al.
  • Hindsight Experience Replay, Marin Andrychowicz et al., OpenAI

Change the algorithm (DAgger)

μ•žμ„œ ν•™μŠ΅ν•œ κ²½λ‘œμ™€ κ°€ μ§„ν–‰ν•œ κ²½λ‘œκ°€ μ°¨μ΄λ‚¬λ˜ 것을 뢄포 μ΄λ™μ˜ 문제둜 μ„€λͺ…ν•  수 μžˆλ‹€. 즉 와 κ°€ λ‹€λ₯΄λ‹€λŠ” 것이닀.

κ·Έλ ‡λ‹€λ©΄ policy λ₯Ό μˆ˜μ •ν•˜λŠ” (μ΄μ „μ˜ λ‚΄μš©)λŒ€μ‹  데이터λ₯Ό μˆ˜μ •ν•˜μ—¬ 을 λ§Œλ“€ 수 μžˆμ„κΉŒ?

DAgger κ°€ 이 λ¬Έμ œμ— λŒ€ν•œ 닡을 μ–»κΈ° μœ„ν•œ 방법이닀.

DAgger (Datset Aggregation)은 policy λ₯Ό μ‹€μ œ ν™˜κ²½μ—μ„œ μˆ˜ν–‰ν•΄μ„œ state κ°€ μ–΄λ–»κ²Œ λ°”λ€ŒλŠ”μ§€ 보고, 직접 μ‚¬λžŒλ“€μ—κ²Œ 라벨링을 μš”μ²­ν•˜λŠ” 것이닀.

μ΄λ ‡κ²Œ λ₯Ό 계속 μˆ˜ν–‰ν•˜μ—¬ μœ μ‚¬ν•œ 뢄포λ₯Ό κ°€μ§€κ²Œ 되며 의 뢄포가 데이터 μ„ΈνŠΈλ₯Ό μ§€λ°°ν•˜κ²Œ λœλ‹€.

DAgger 의 λ¬Έμ œμ μ€ μ‚¬λžŒμ΄ 직접 λΌλ²¨λ§ν•˜λŠ” 것이 일이 μΌμ–΄λ‚œ 후에 κ²€ν† ν•˜λŠ” κ²ƒμ΄λ―€λ‘œ λΆ€μžμ—°μŠ€λŸ½κ³ , λ§€ μˆœκ°„ λΉ λ₯΄κ²Œ 결정을 λ‚΄λ €μ•Ό ν•˜λŠ” κ²½μš°μ— λͺ¨λ“  것을 λ‹€μ‹œ λΌλ²¨λ§ν•˜λ―€λ‘œ ν•΄κ²°ν•˜κΈ΄ μ–΄λ ΅λ‹€.

μ–΄μ¨Œλ“  좔가적인 데이터λ₯Ό 얻을 수 μžˆλ‹€λŠ” κ°•ν•œ μ „μ œ ν•˜μ— 의 μ„ ν˜•μ μΈ λ³΅μž‘λ„λ₯Ό κ°€μ§ˆ 수 μžˆκ²Œλœλ‹€.

Lecture 3. PyTorch Tutorial

https://rail.eecs.berkeley.edu/deeprlcourse/deeprlcourse/static/slides/lec-3.pdf

https://colab.research.google.com/drive/12nQiv6aZHXNuCfAAuTjJenDWKQbIt2Mz

RL Connection: You would want to be doing simulator-related tasks with numpy, convert to torch when doing model-related tasks, and convert back to feed output into simulator.