
Q(S,a)=Return if you

우리는 optimal policy는 알 수 없음

Continuous state : 어떤 값이 올 지 모름

Learning the State-Action Value Function
주요 아이디어는 신경망을 훈련시켜 상태-행동 가치 함수 Q(s, a)를 계산하거나 근사하는 것. 이를 통해 좋은 행동을 선택 가능

😎 이런 (s,a)를 주면 이런 Q(s,a)가 나와야 해
We’re going to train a neural network that (다음과 같이 신경망을 훈련시킬 예정)
– Inputs the current state 𝑠 and an action 𝑎 (→ the input 𝑥)
– Then computes or approximates 𝑄(𝑠, 𝑎) (→ the target 𝑦)
After we train the neural network (신경망을 훈련한 후에는 다음과 같이 사용)
– In a state 𝑠, we use the neural network to compute -> 𝑄(𝑠, nothing), 𝑄(𝑠, left), 𝑄(𝑠, main), 𝑄(𝑠, right)
– We then pick action 𝑎 that maximizes 𝑄(𝑠, 𝑎)
NOTE!!!
Notice that RL is different from supervised learning (강화 학습은 지도 학습과는 다르다는 점을 주목)
What we’re going to do is not to input a state and output an action (우리가 하는 것은 상태를 입력으로 받고 행동을 출력하는 것이 아님)
What we’re going to do is to input a state-action pair and output 𝑄(𝑠, 𝑎) (우리의 목표는 상태-행동 쌍을 입력으로 받고 𝑄(𝑠, 𝑎)를 출력하는 것)
Using a neural network inside the RL algorithm this way turns out to work
pretty well (잠깐만 neural network를 쓰는 것 ; 강화 학습 알고리즘 내부에서 신경망을 사용하는 것은 상당히 잘 작동)
Question: "How do we train a neural network to output 𝑄(𝑠, 𝑎)? 신경망을 어떻게 훈련하여 𝑄(𝑠, 𝑎)를 출력?
- We will use the Bellman’s equations to create a training set with lots of
examples (𝑥, 𝑦) = ((𝑠, 𝑎),𝑄(𝑠, 𝑎)) 벨만 방정식을 사용하여 많은 예제(𝑥, 𝑦) = ((𝑠, 𝑎),𝑄(𝑠, 𝑎))로 이루어진 훈련 세트를 만들 것
- Then we’ll use supervised learning exactly as you learned in the 2nd course 그런 다음 2번째 과정에서 배운 것과 똑같이 지도 학습을 사용할 것
- But how do we get the training set with (𝑥, 𝑦) = ((𝑠, 𝑎),𝑄(𝑠, 𝑎)) to train a
neural network?
Using the Bellman Equation


s(1)에서 a(1) 행동을 취했더니 R(s(1)) 보상이 왔고, 다음 state는 s'(1)이 되었다.
질문: "지도 학습에서 우리는 신경망 𝑓𝐖,𝐁를 훈련시켜 𝑥에 대해 𝑦를 예측합니다. 그렇다면 (𝑥, 𝑦) = ((𝑠, 𝑎),𝑄(𝑠, 𝑎)) 훈련 세트를 어떻게 얻을 수 있을까요?"
우리가 할 일은 다음과 같음:
다양한 시도를 해보고 많은 예제를 관찰


// initial random guess of 𝑄(𝑠, 𝑎)
Initialize a neural network 𝑄 randomly
// improves to get a better estimate of 𝑄(𝑠, 𝑎)
Repeat {
Take actions and get 𝑠, 𝑎, 𝑅 𝑠 , 𝑠
′
Store 10,000 most recent 𝑠, 𝑎, 𝑅 𝑠 , 𝑠
′ tuples
Train the neural network:
Create a training set of 10,000 examples using
𝑥, 𝑦 = (𝑠, 𝑎), 𝑅 𝑠 + 𝛾 max Q(s',a'))
Train 𝑄𝑛𝑒𝑤 such that 𝑄𝑛𝑒𝑤 𝑠, 𝑎 ≈ 𝑦
Set 𝑄 = 𝑄𝑛𝑒𝑤
}
정리를 하자면
방금 보신 알고리즘은 DQN 알고리즘이라고 합니다.
지금까지 one-hot encoding을 보면서 답답하지 않았는가..?
action이 possible 개수가 10개가 넘을 경우, 10개를 전부 돌리기에는 너무 무리임
결론 : ouput을 4개로 만들자!


More Efficient Architecture for DQN
이 알고리즘을 훨씬 효율적으로 만드는 신경망 구조가 변경
s를 밀어넣으면 각 Q(s,a)가 바로 나오도록 바꾸는 것 (한 큐에 전부 구할 수 있음)