Giter Club home page Giter Club logo

Comments (2)

DaxLynch avatar DaxLynch commented on June 14, 2024

So I decided to use this library and I am currently writing my own vanilla policy gradient. It seems that the td3 algorithm has the assumption that the state of the environment doesn't automatically get changed due to an observation/action, but with my plan for my project I was going to have it make an observation, and then make an action and get a reward approximately one fixed eval period later, so I figured I couldn't have the two critics making observations and getting rewards as the state would have changed.

from rl-tools.

jonas-eschmann avatar jonas-eschmann commented on June 14, 2024

Hi @DaxLynch sorry for the late reply. That sounds like a very cool project! Since TD3 is an off-policy method you can populate the replay buffer however you like. I would suggest to create your own training loop by copying the operations from here:

bool step(DEVICE& device, rl::algorithms::td3::loop::core::State<T_CONFIG>& ts){

But removing the step(device, ts.off_policy_runner, ts.actor_critic.actor, ts.actor_buffers_eval, ts.rng); where the off-policy runner is used to generate samples from the environment and place them into the replay buffer.

Then you can have your own code using the policy to generate actions (like e.g. in the evaulation code:

evaluate(device, policy, observation_normalized, action_full, policy_eval_buffers);
). Once you have collected the [state, observation, action, reward, next_state, next_observation, terminated_flag, truncated_flag] tuple you can add it to the replay buffer like in
add(device, runner.replay_buffers[env_i], state, observation, observation_privileged, action, reward_value, next_state, next_observation, next_observation_privileged, terminated_flag, truncated);

It is probably best to do a full rollout of the trajectory and then, when the robot is idle, do some steps of training to prevent the training to interfere with the control frequency.

I think this is a common use-case (where the interaction/inference can not be in lock-step with and governed by the training loop) and I'm thinking of ways to better accommodate it. Once I find some time, I'll probably separate out the rollouts of the off-policy runner into a separate loop so that it can be optional and create an example where the rollouts are conducted independently of the training

from rl-tools.

Related Issues (7)

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.