Git Product home page Git Product logo

dqn-atari-tensorflow's Introduction

DQN-Atari-Tensorflow

Reimplementing "Human-Level Control Through Deep Reinforcement Learning" in Tensorflow

This may be the simplest implementation of DQN to play Atari Games.

The pretrained network would release soon!

Prerequsite

  1. Tensorflow (prefer with GPU CUDA supported)
  2. opencv2
  3. Arcade Learning Environment ( https://github.com/mgbellemare/Arcade-Learning-Environment )

Setup and Run

git clone https://github.com/songrotek/DQN-Atari-Tensorflow.git

cd DQN-Atari-Tensorflow
python AtariDQN.py

Reference

  1. asrivat1/DeepLearningVideoGames
  2. gliese581gg/DQN_tensorflow

dqn-atari-tensorflow's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

dqn-atari-tensorflow's Issues

Save Error

At timestep 60000, there is a save error.

TIMESTEP 59997 / STATE explore / EPSILON 0.9910027
TIMESTEP 59998 / STATE explore / EPSILON 0.9910018
TIMESTEP 59999 / STATE explore / EPSILON 0.9910009
Traceback (most recent call last):
File "AtariDQN.py", line 43, in
main()
File "AtariDQN.py", line 40, in main
playAtari()
File "AtariDQN.py", line 37, in playAtari
brain.setPerception(nextObservation,action,reward,terminal)
File "/Users/x0r/Documents/codes/DQN-Atari-Tensorflow/BrainDQN_Nature.py", line 144, in setPerception
self.trainQNetwork()
File "/Users/x0r/Documents/codes/DQN-Atari-Tensorflow/BrainDQN_Nature.py", line 131, in trainQNetwork
self.saver.save(self.session, 'saved_networks/' + 'network' + '-dqn', global_step = self.timeStep)
File "/usr/local/lib/python2.7/site-packages/tensorflow/python/training/saver.py", line 1037, in save
{self.saver_def.filename_tensor_name: checkpoint_file})
File "/usr/local/lib/python2.7/site-packages/tensorflow/python/client/session.py", line 340, in run
run_metadata_ptr)
File "/usr/local/lib/python2.7/site-packages/tensorflow/python/client/session.py", line 564, in _run
feed_dict_string, options, run_metadata)
File "/usr/local/lib/python2.7/site-packages/tensorflow/python/client/session.py", line 637, in _do_run
target_list, options, run_metadata)
File "/usr/local/lib/python2.7/site-packages/tensorflow/python/client/session.py", line 659, in _do_call
e.code)
tensorflow.python.framework.errors.NotFoundError: saved_networks/network-dqn-60000.tempstate3373398505739141382
[[Node: save/save = SaveSlices[T=[DT_FLOAT, DT_FLOAT, DT_FLOAT, DT_FLOAT, DT_FLOAT, DT_FLOAT, DT_FLOAT, DT_FLOAT, DT_FLOAT, DT_FLOAT, DT_FLOAT, DT_FLOAT, DT_FLOAT, DT_FLOAT, DT_FLOAT, DT_FLOAT, DT_FLOAT, DT_FLOAT, DT_FLOAT, DT_FLOAT, DT_FLOAT, DT_FLOAT, DT_FLOAT, DT_FLOAT, DT_FLOAT, DT_FLOAT, DT_FLOAT, DT_FLOAT, DT_FLOAT, DT_FLOAT, DT_FLOAT, DT_FLOAT, DT_FLOAT, DT_FLOAT, DT_FLOAT, DT_FLOAT, DT_FLOAT, DT_FLOAT, DT_FLOAT, DT_FLOAT], _device="/job:localhost/replica:0/task:0/cpu:0"](_recv_save/Const_0, save/save/tensor_names, save/save/shapes_and_slices, Variable, Variable/RMSProp, Variable/RMSProp_1, Variable_1, Variable_1/RMSProp, Variable_1/RMSProp_1, Variable_10, Variable_11, Variable_12, Variable_13, Variable_14, Variable_15, Variable_16, Variable_17, Variable_18, Variable_19, Variable_2, Variable_2/RMSProp, Variable_2/RMSProp_1, Variable_3, Variable_3/RMSProp, Variable_3/RMSProp_1, Variable_4, Variable_4/RMSProp, Variable_4/RMSProp_1, Variable_5, Variable_5/RMSProp, Variable_5/RMSProp_1, Variable_6, Variable_6/RMSProp, Variable_6/RMSProp_1, Variable_7, Variable_7/RMSProp, Variable_7/RMSProp_1, Variable_8, Variable_8/RMSProp, Variable_8/RMSProp_1, Variable_9, Variable_9/RMSProp, Variable_9/RMSProp_1)]]
Caused by op u'save/save', defined at:
File "AtariDQN.py", line 43, in
main()
File "AtariDQN.py", line 40, in main
playAtari()
File "AtariDQN.py", line 20, in playAtari
brain = BrainDQN(actions)
File "/Users/x0r/Documents/codes/DQN-Atari-Tensorflow/BrainDQN_Nature.py", line 43, in init
self.saver = tf.train.Saver()
File "/usr/local/lib/python2.7/site-packages/tensorflow/python/training/saver.py", line 832, in init
restore_sequentially=restore_sequentially)
File "/usr/local/lib/python2.7/site-packages/tensorflow/python/training/saver.py", line 500, in build
save_tensor = self._AddSaveOps(filename_tensor, vars_to_save)
File "/usr/local/lib/python2.7/site-packages/tensorflow/python/training/saver.py", line 197, in _AddSaveOps
save = self.save_op(filename_tensor, vars_to_save)
File "/usr/local/lib/python2.7/site-packages/tensorflow/python/training/saver.py", line 149, in save_op
tensor_slices=[vs.slice_spec for vs in vars_to_save])
File "/usr/local/lib/python2.7/site-packages/tensorflow/python/ops/io_ops.py", line 172, in _save
tensors, name=name)
File "/usr/local/lib/python2.7/site-packages/tensorflow/python/ops/gen_io_ops.py", line 341, in _save_slices
name=name)
File "/usr/local/lib/python2.7/site-packages/tensorflow/python/ops/op_def_library.py", line 661, in apply_op
op_def=op_def)
File "/usr/local/lib/python2.7/site-packages/tensorflow/python/framework/ops.py", line 2154, in create_op
original_op=self._default_original_op, op_def=op_def)
File "/usr/local/lib/python2.7/site-packages/tensorflow/python/framework/ops.py", line 1154, in init
self._traceback = _extract_stack()

Runtime problem

When I am running the AtariDQN.py it keeps crashing at 59999th time step.
The error is provided below:
"
TIMESTEP 59999 / STATE explore / EPSILON 0.9910009
W tensorflow/core/common_runtime/executor.cc:1102] 0x68d28070 Compute status: Not found: saved_networks/network-dqn-60000.tempstate11733997792408763068
[[Node: save/save = SaveSlices[T=[DT_FLOAT, DT_FLOAT, DT_FLOAT, DT_F....
"

I ran it with default settings. What may be the problem ?

Thanks in advance.

I got error about cudnnCreate..... COuld you help me out?

I got this below error message:
I tensorflow/core/common_runtime/gpu/gpu_device.cc:975] Creating TensorFlow device (/gpu:0) -> (device: 0, name: GeForce 940MX, pci bus id: 0000:03:00.0)
Could not find old network weights
F tensorflow/stream_executor/cuda/cuda_dnn.cc:222] Check failed: s.ok() could not find cudnnCreate in cudnn DSO; dlerror: /usr/local/lib/python2.7/dist-packages/tensorflow/python/_pywrap_tensorflow.so: undefined symbol: cudnnCreate
Aborted (core dumped)

I definitely installed cudnn and copy it to the right location....

What should I do...?

cannot install ale_python_interface

when I tried to install ale_python_interface, I got this error and could not solve this...

Collecting ale_python_interface
  Downloading https://files.pythonhosted.org/packages/42/73/fc4c95337d2d0b06f7df69ae2409ef43c0176c7086176de03053a7731962/ale_python_interface-0.0.1.tar.gz (635kB)
     |████████████████████████████████| 645kB 9.8MB/s 
Building wheels for collected packages: ale-python-interface
  Building wheel for ale-python-interface (setup.py) ... error
  ERROR: Failed building wheel for ale-python-interface
  Running setup.py clean for ale-python-interface
Failed to build ale-python-interface
Installing collected packages: ale-python-interface
  Running setup.py install for ale-python-interface ... error
ERROR: Command "/usr/bin/python3 -u -c 'import setuptools, tokenize;__file__='"'"'/tmp/pip-install-2ghz1058/ale-python-interface/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' install --record /tmp/pip-record-wbv9q1y5/install-record.txt --single-version-externally-managed --compile" failed with error code 1 in /tmp/pip-install-2ghz1058/ale-python-interface/

How long to take to run this model

I have run for 30 hours training and I couldn't see any improvement.
I am using GTX1080 GPU.
I using DQN provided by google deep mind atari game using torch. It able to reached 400 points after 24 hours training. I am using same GPU GTX1080.
Anyone have training this model? how long it take to see improment on Breakout atari game ?

an error

A.L.E: Arcade Learning Environment (version 0.6.0)
[Powered by Stella]
Use -help for help screen.
Warning: couldn't load settings file: ./ale.cfg
Traceback (most recent call last):
File "AtariDQN.py", line 43, in
main()
File "AtariDQN.py", line 40, in main
playAtari()
File "AtariDQN.py", line 18, in playAtari
atari = Atari('breakout.bin')
File "game/Atari.py", line 9, in init
self.max_frames_per_episode = self.ale.getInt("max_num_frames_per_episode")
File "/home/hrhythm/anaconda3/lib/python3.6/site-packages/ale_python_interface/ale_python_interface.py", line 122, in getInt
return ale_lib.getInt(self.obj, key)
ctypes.ArgumentError: argument 2: <class 'TypeError'>: wrong type
how can i solve this? thank you!

I found a bug.

Line 138 : newState = np.append(nextObservation,self.currentState[:,:,1:],axis = 2)
This should be as follows:
Line 138 : newState = np.append(nextObservation,self.currentState[:,:,:-1],axis = 2)

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.