Code Monkey home page Code Monkey logo

by571 / dqn-atari-agents Goto Github PK

View Code? Open in Web Editor NEW
116.0 4.0 14.0 12.95 MB

DQN-Atari-Agents: Modularized & Parallel PyTorch implementation of several DQN Agents, i.a. DDQN, Dueling DQN, Noisy DQN, C51, Rainbow, and DRQN

License: MIT License

Jupyter Notebook 50.05% Python 49.95%
dqn-pytorch ddqn-pyotrch dueling-dqn-pytorch noisy-dqn c51 reinforcement-learning-algorithms reinforcement-learning-agent atari openai deep-reinforcement-learning

dqn-atari-agents's Issues

the quick convergence proof for the CartPole-v0

Hello, thank you for sharing. Your work has been very helpful to me!
I encountered some issues while training in the CartPolo environment. Although the training time has accelerated, the reward continues to decrease in the later stages of training, as shown in the figure. My hyperparameters are the same as your example.
Can you tell me where the quick convergence proof is in the code? Thank you!

figure

n step replay buffer

Hi, thanks for sharing the work. There might be an issue with the self.n_step_buffer.

When you reset the environment, self.n_step_buffer should also be reset, otherwise you will get a starting state from the previous environment and an end state from the current environment

Prioritized experience replay buffer error.

I think this should be loss = (td_error.pow(2)*weights).mean().to(self.device) instead of loss = td_error.pow(2)*weights.mean().to(self.device). Without those brackets, loss is a vector of shape [batch_size, 1] instead of a scalar.

Command to reproduce the error:
python run_atari_dqn.py -env CartPole-v0 -agent dqn+per -frames 30000 -m 500000 --fill_buffer 50000 -eps_frames 1000 -seed 42 -info testCP

The error:

Traceback (most recent call last):
  File "run_atari_dqn.py", line 220, in <module>
    final_average100 = run(frames = args.frames//args.worker, eps_fixed=eps_fixed, eps_frames=args.eps_frames//args.worker, min_eps=args.min_eps, eval_every=args.eval_every//args.worker, eval_runs=args.eval_runs, worker=args.worker)
  File "run_atari_dqn.py", line 77, in run
    agent.step(s, a, r, ns, d, writer)
  File "/Users/user/Downloads/DQN-Atari-Agents/Agents/dqn_agent.py", line 122, in step
    loss = self.learn_per(experiences)
  File "/Users/user/Downloads/DQN-Atari-Agents/Agents/dqn_agent.py", line 239, in learn_per
    loss.backward()
  File "/Users/user/opt/miniconda3/envs/py36/lib/python3.6/site-packages/torch/tensor.py", line 185, in backward
    torch.autograd.backward(self, gradient, retain_graph, create_graph)
  File "/Users/user/opt/miniconda3/envs/py36/lib/python3.6/site-packages/torch/autograd/__init__.py", line 121, in backward
    grad_tensors = _make_grads(tensors, grad_tensors)
  File "/Users/user/opt/miniconda3/envs/py36/lib/python3.6/site-packages/torch/autograd/__init__.py", line 47, in _make_grads
    raise RuntimeError("grad can be implicitly created only for scalar outputs")
RuntimeError: grad can be implicitly created only for scalar outputs

If you want I can submit a PR for that (although the change is a minor one:P).

some bugs

@ run_atari_dqn.py
before using variable "seed", should add
seed = args.seed
run_random_policy(args.fill_buffer) takes quite a long time, so I commented that line and now it runs well

About optimizer

Hi. I am doing some research about the optimizer. However, I just changed the optimized used in your code from Adam to SGD but it seems that the agent doesn't learn at all.

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.