Code Monkey home page Code Monkey logo

Comments (1)

HannH avatar HannH commented on September 26, 2024

#代码中你说用的 td_error 的 actor-critic 算法,但实际算actor的gradient时,你用的是q而不是td_error, 修改如下

def learn(self, s, a, r, s_):

    s, s_ = s[np.newaxis, :], s_[np.newaxis, :]
    next_a = [[i] for i in range(N_A)]
    s_ = np.tile(s_,[N_A,1])
    q_ = self.sess.run(self.td_error, {self.s: s_,self.a:next_a})
    q_ = np.max(q_,axis=0,keepdims=True)
    q, _ = self.sess.run([self.q, self.train_op],
                                {self.s: s, self.q_: q_, self.r: r,self.a:[[a]]})
    return q

直接看源码吧,源码就是td_error,这个作者改来改去的反而把东西改错了,而且还把源码声明删了。
https://github.com/MorvanZhou/Reinforcement-learning-with-tensorflow/blob/967c829335fa34a329b7976b29fc1f579776d67f/contents/8_Actor_Critic_Advantage/AC_CartPole.py#L74

from tensorflow_practice.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.