2016-10-10 7 views
5

私は強化学習プログラムで働いており、この記事をreferenceとして使用しています。ここでは損失関数の式は、この強化学習のためにケラスのウェイトを更新するには?

enter image description here

ところ、私の報酬である私は、ニューラルネットワークを作成するためのkeras(theano)でのpythonを使用していますが、私はこのプログラムのために使用していた擬似コードは

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

関連する問題