2016-10-10 3 views
5

나는 보강 학습 프로그램에서 일하고 나는 reference로이 문서를 사용하고 있습니다. 내가 신경 네트워크와 나는이 프로그램을 위해 사용하고있는 의사 코드를 작성하기위한 keras (theano)와 파이썬을 사용하고 여기에 손실 함수 방정식이강화 학습을 위해 keras의 가중치를 업데이트하는 방법은 무엇입니까?

enter image description here

입니다

Do a feedforward pass for the current state s to get predicted Q-values for all actions. 

Do a feedforward pass for the next state s’ and calculate maximum overall network outputs max a’ Q(s’, a’). 

Set Q-value target for action to r + γmax a’ Q(s’, a’) (use the max calculated in step 2). For all other actions, set the Q-value target to the same as originally returned from step 1, making the error 0 for those outputs. 

Update the weights using backpropagation. 

입니다 내 보상 +1, MAXQ (S ', A') = 0.8375 및 Q (s는, a) = 0.6892

내 L가 될 것이다 1/2*(1+0.8375-0.6892)^2=0.659296445

이제 내 모델 구조는 NN은 Q 값 기능을 모델링되는 가정이

model = Sequential() 
model.add(Dense(150, input_dim=150)) 
model.add(Dense(10)) 
model.add(Dense(1,activation='sigmoid')) 
model.compile(loss='mse', optimizer='adam') 

답변

0

경우 나는 위의 손실 함수 값을 사용하여 내 모델 신경망의 가중치를 업데이트하는 방법, 당신은 네트워크에 대상을 통과 할 것 . 예 :

model.train_on_batch(state_action_vector, target) 

여기서 state_action_vector는 네트워크에 입력 된 상태 - 조치 입력을 나타내는 사전 처리 된 벡터입니다. 네트워크가 MSE 손실 기능을 사용하기 때문에 포워드 패스의 상태 - 조치를 사용하여 예측 기간을 계산 한 다음 목표에 따라 가중치를 업데이트합니다.

+0

자세한 설명을 제공해주십시오. 감사 – RZK