[Deep Reinforcement Learning] 24강 A3C 1

Woosci·2025년 7월 30일

👨‍🏫학습목표

오늘은 Asynchronous Advantage Actor-Critic의 구조, 학습방법에 대해 배워볼 예정이다.

👨‍🎓강의영상: https://www.youtube.com/watch?v=YJi3sBv2fRg
📃Asynchronous Method 논문: https://arxiv.org/pdf/1602.01783

1️⃣ Asynchronous Advantage Actor-Critic

🔷 Asynchronous Advantage Actor-Critic

🔻 기본적인 구조

  • Actor-Critic algorithm이다.
  • Multiple Network로 이루어져 있다.
  • Multiple Network는 global networkmultiple worker agent로 이루어져 있다.
  • multiple worker agent개별적으로 작동한 후, global network에서 통합되는 특징이 있다.
  • 각 Agent는 개별적으로 sample data를 수집한 후 파라미터를 업데이트한다.
  • 각 Agent는 자신의 업데이트를 마친 후 업데이트한 내용을 바탕으로 개별적으로 global network를 업데이트한다.

🔻 Parallelism의 장점

  • A3C에서 가장 중요한 것은 global network의 파라미터 업데이트이다.
  • 각 agenttemporal correlation을 가진다.
  • 하지만 agent 간에는 개별적으로 학습이 진행되기 때문에 temporal correlation이 크게 발생하지 않는다.
  • 따라서 global network 입장에서는 temporal correlation 문제가 심각하지 않다.
  • 일반적으로 temporal correlation 문제가 발생할 경우 DQN처럼 experience replay를 문제를 해결한다.
DQN에 대한 추가적인 내용은 아래 글에서 확인 가능하다.
📃자료: https://velog.io/@tina1975/Deep-Reinforcement-Learning-17강-DQN-1

🔻 Advantage의 의미

  • Actor-critic algorithmActor NetworkCritic Network로 나뉜다.
  • Critic Network는 value function을 출력하는데 이때 사용되는 value functionadvantage function이다.

🔸 Advantage를 구하는 방법

A(s,a)=Q(s,a; ϕ2)V(s;ϕ1)A(s,a) = Q(s,a;\ \phi_2) - V(s; \phi_1)
  • 일반적으로 Advantage function을 출력하기 위해서는 Q(s,a)Q(s,a)V(s)V(s)를 출력하는 Network가 필요한다.

🔸 실제 A3C 모델이 구하는 것

Gt(n)V(s;ϕ1)G^{(n)}_t - V(s; \phi_1)
  • 하지만 기술적인 이유Q(s,a; ϕ2)Q(s,a;\ \phi_2) 대신 n-step return Gt(n)G^{(n)}_t를 사용한다.
  • n-step return Gt(n)G^{(n)}_t은 수집한 데이터로 구하기 때문에 추가적인 Network가 필요하지 않다.

🔻 A3C의 특징

  • Actor-Criticpolicy gradient를 사용하기 때문에 continuous action space를 처리할 수 있다.
  • Atari game에서 Dueling, Prioritized, Double DQN보다좋은 성능을 발휘한다.
  • 로보틱스와 같은 모터 조작 task에서도 뛰어난 성능을 발휘한다.

🔸 대표적인 DRL 모델

  1. DQN : 입력으로 continuous state space를 처리할 수 있지만, output으로는 discrete action space를 처리한다.
  2. A3C : 입력으로 continuous state space를 처리할 수 있고, output으로도 continuous action space를 처리할 수 있다.


2️⃣ Asynchronous

🔷 Asynchronous

  • 하나의 Global Network여러 개의 worker agent를 가진다.
  • 각 agent는 자신만의 파라미터를 가지고 각자의 environment에서 학습을 수행한다.
  • 각자 학습을 마치면 개별적으로 Global Network를 업데이트한다.
  • 업데이트 방식은 각 worker agent가 일정 기간 동안 축적한 gradient를 전달하는 것이다.
  • 학습이 마친 후 실제 추론 단계에서는 Global Network만 사용한다.

🔷 Multiple Agent의 장점

🔻 Single Agent의 한계

  • Non-stationary : Target Network가 계속 움직이면 stationary하게 학습할 수 없다.
  • Temporal correlation : 국소적인 영역에서 적합되는 문제가 발생한다.

🔻 Multipe Agent

  • 각 agent가 asynchronous하게 업데이트를 진행할 때, 각 agent 사이에는 temporal correlation이 존재하지 않기 때문temporal correlation 문제를 해결할 수 있다.
  • 따라서 experience replay를 사용할 필요가 없다.
  • 각 agent마다 파라미터가 다르기 때문더 다양한 경험을 학습할 수 있다.
  • 하나의 multi-core CPU로도 작동할 수 있다.
  • Agent의 수가 많아질수록 학습속도가 빨라진다.


3️⃣ Asychronous Implementation

🔷 Asynchronous를 구현하는 방법

🔻 Global Network의 파라미터

  • Actor 파라미터 θ\theta
  • Critic 파라미터 ϕ\phi

🔻 파라미터 업데이트

  • 각 Agent가 각자의 학습을 마친 후 즉시 Global Network의 파라미터를 업데이트한다.
  • 축적된 gradient를 전달 후 agent는 업데이트된 θ,ϕ\theta, \phi를 그대로 가져온다.
  • Agent는 새로운 파라미터를 가지고 학습을 시작한다.
  • 학습은 tmaxt_{max} step 동안 진행한다.

🔻 Acumulated Gradient 계산

🔸 Agent Actor Network

ΔθΔθ+(Gt(n)Vϕ(st))θlogπθ(atst)\Delta\theta \leftarrow \Delta\theta + (G_t^{(n)} - V_{\phi'}(s_t)) \nabla_{\theta'} \log \pi_{\theta'}(a_t | s_t)
  • 해당 과정을 tmaxt_{max} step 동안 반복한다.
  • Δθ\Delta\thetaaccumulated gradient다.

🔸 Agent Critic Network

ΔϕΔϕ(Gt(n)Vϕ(st))ϕVϕ(st)\Delta\phi \leftarrow \Delta\phi - (G_t^{(n)} - V_{\phi'}(s_t)) \nabla_{\phi'} V_{\phi'}(s_t)
  • 해당 과정을 tmaxt_{max} step 동안 반복한다.
  • Δϕ\Delta\phiaccumulated gradient다.

🔸 파라미터 업데이트

θθ+αΔθ and ϕϕβΔϕ\theta \leftarrow \theta + \alpha \Delta\theta \text{ and } \phi \leftarrow \phi - \beta \Delta\phi
  • 계산된 gradient로 agent를 실제로 학습하지는 않고, Global Network로 전달하여 업데이트를 진행한다.
  • Actor Network θ\thetagradient ascent로 업데이트한다.
  • Critic Network ϕ\phigradient descent로 업데이트한다.

🔻 프로세스

  1. 각 Agent가 Global Network의 파라미터를 가져온다.
  2. 각 Agent는 주어진 환경에서 데이터를 수집한다.
  3. 수집한 데이터를 통해 value function와 policy의 loss를 구한다.
  4. tmaxt_{max} step동안 반복하여 accumulated gradient를 구한다.
  5. Accumulated gradient를 통해 Global Network를 업데이트한다.


4️⃣ 정리

🔷 24강에서 배운 내용은 아래와 같다.

  1. Asychronous Advantage Actor-criticpolicy gradient 방식이기 때문에 continuous action space를 처리할 수 있다.
  2. Asychronous Advantage Actor-criticGlobal Networkmultiple worker agent로 이루어져 있다.
  3. 실제 모델 학습target networkn-step return Gt(n)G^{(n)}_t 을 사용한다.
  4. n-step return Gt(n)G^{(n)}_tV(s)V(s)를 빼서 baseline 역할을 수행한다.
  5. 모델 업데이트각 agent가 개별적으로 Global Network를 업데이트한다.
  6. 각 Agent는 tmaxt_{max} step동안 gradient를 축적하여 Global Network에 전달한다.
profile
I'm curious about AI

0개의 댓글