强化学习 qlearning CartPole-v0 单网络 学习

原文链接: 强化学习 qlearning CartPole-v0 单网络 学习

上一篇: numpy 向量叉积计算时的性能问题

下一篇: vs code 配置 c++环境

玄学炼丹,有时候可以跑出好结果,有时候不行

最好的一次,很快收敛,且效果很好

6554f2e4ad242453088f3f230b30cd383e9.jpg

a9bf3e6257c39bb4939ad7d5ac5e81556e6.jpg

更新

避免两百步时,无论是否失败,都结束的行为,将reword自己进行判断,只有超出范围才算作失败


    def refresh_memory(self):
        observation = self.env.reset()
        step = 0
        for i in range(self.memory_size):
            action = self.choose_action(observation)
            observation_new, reword, done, info = self.env.step(action)
            step += 1
            theta_threshold_radians = 12 * 2 * math.pi / 360
            x_threshold = 2.4
            x, x_dot, theta, theta_dot = observation_new
            done2 = any([
                x < -x_threshold,
                x > x_threshold,
                theta < -theta_threshold_radians,
                theta > theta_threshold_radians
            ])
            # reword = -10 if done and step < 200 else reword
            reword = -10 if done2 else reword
            self.store_memory(observation, action, reword, observation_new)
            observation = observation_new
            if done:
                observation = self.env.reset()
                step = 0

51ff0e76031b04a90c9c29fb4fc06796047.jpg

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值