首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >如何更新角点中的权重以进行强化学习?

如何更新角点中的权重以进行强化学习?
EN

Stack Overflow用户
提问于 2016-10-10 04:54:36
回答 1查看 2K关注 0票数 10

我正在一个强化学习程序中工作,我使用这篇文章作为参考文献。我使用python和keras(theano)来创建神经网络,我为这个程序使用的伪代码是

代码语言:javascript
复制
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

现在,如果我的模型结构是这样的,我应该如何使用上面的损失函数值来更新我的模型神经网络权重

代码语言:javascript
复制
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')
EN

回答 1

Stack Overflow用户

发布于 2017-01-05 02:49:55

假设NN正在建模Q值函数,则只需将目标传递给网络即可。例如:

代码语言:javascript
复制
model.train_on_batch(state_action_vector, target)

其中state_action_vector是一些预处理向量,表示对网络的状态动作输入。由于您的网络使用的是MSE损失函数,它将使用前传的状态动作来计算预测项,然后根据目标更新权重。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/39951502

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档