garethjns / reinforcement-learning-keras

Reinforcement learning algorithms implemented in Keras (tensorflow==2.3) and sklearn
GNU General Public License v3.0
6 stars 2 forks source link

__init__() missing 1 required positional argument: 'agent_type' #27

Closed chenxiaohua20140401 closed 4 years ago

chenxiaohua20140401 commented 4 years ago

hi, when i try to test the example pong,i copy and paste the “RUN example”,however i got the error log like below: Traceback (most recent call last): File "c:/Users/littlechen/reinforcement-learning-keras/chen.py", line 6, in agent = DeepQAgent(*PongConfig('dqn').build()) File "c:\Users\littlechen\reinforcement-learning-keras\reinforcement_learning_keras\enviroments\atari\atari_default_config.py", line 30, in init
super().init(
args, **kwargs) TypeError: init() missing 1 required positional argument: 'agent_type'

my software environment is: absl-py==0.10.0 aiohttp==3.6.2 astroid==2.4.2 astunparse==1.6.3 async-timeout==3.0.1 atari-py==0.2.6 attrs==20.2.0 backcall==0.2.0 cachetools==4.1.1 certifi==2020.6.20 chardet==3.0.4 cloudpickle==1.3.0 colorama==0.4.3 coverage==5.3 cycler==0.10.0 dataclasses==0.7 decorator==4.4.2 future==0.18.2 gast==0.3.3 google-auth==1.22.0 google-auth-oauthlib==0.4.1 google-pasta==0.2.0 grpcio==1.32.0 gym==0.17.1 h5py==2.10.0 idna==2.10 idna-ssl==1.1.0 importlib-metadata==2.0.0 ipykernel==5.3.4 ipython==7.16.1 ipython-genutils==0.2.0 isort==5.5.4 jedi==0.17.2 joblib==0.16.0 jupyter-client==6.1.7 jupyter-core==4.6.3 Keras-Preprocessing==1.1.2 kiwisolver==1.2.0 lazy-object-proxy==1.4.3 Markdown==3.2.2 matplotlib==3.3.2 mccabe==0.6.1 mock==4.0.2 multidict==4.7.6 numpy==1.18.0 oauthlib==3.1.0 opencv-python==4.4.0.44 opt-einsum==3.3.0 pandas==1.1.2 parso==0.7.1 pickleshare==0.7.5 Pillow==7.2.0 prompt-toolkit==3.0.7 protobuf==3.13.0 pyasn1==0.4.8 pyasn1-modules==0.2.8 pyglet==1.5.0 Pygments==2.7.1 pylint==2.6.0 pyparsing==2.4.7 python-dateutil==2.8.1 pytz==2020.1 pywin32==228 pyzmq==19.0.2 requests==2.24.0 requests-oauthlib==1.3.0 rsa==4.6 scikit-learn==0.23.0 scipy==1.5.2 seaborn==0.11.0 six==1.15.0 tensorboard==2.3.0 tensorboard-plugin-wit==1.7.0 tensorflow==2.3.1 tensorflow-estimator==2.3.0 termcolor==1.1.0 threadpoolctl==2.1.0 toml==0.10.1 tornado==6.0.4 tqdm==4.50.0 traitlets==4.3.3 typed-ast==1.4.1 typing-extensions==3.7.4.3 urllib3==1.25.10 wcwidth==0.2.5 Werkzeug==1.0.1 wincertstore==0.2 wrapt==1.12.1 yarl==1.6.0 zipp==3.2.0


how can i fix the error?

garethjns commented 4 years ago

Hi @chenxiaohua20140401,

Thank you for pointing this out. It looks like there's a bug with how the args are passed in the configs. I'll have a look, in the mean time you can avoid the problem by specifying the agent_type as a kwarg, for example this should work:

from reinforcement_learning_keras.agents.q_learning.deep_q_agent import DeepQAgent
from reinforcement_learning_keras.enviroments.atari.pong.pong_config import PongConfig

agent = DeepQAgent(**PongConfig(agent_type='dqn').build())

agent.train(n_episodes=1000, max_episode_steps=10000, render=True, update_every=1, checkpoint_every=100)
garethjns commented 4 years ago

Should be fixed, let me know if you have any problems!

chenxiaohua20140401 commented 4 years ago

Should be fixed, let me know if you have any problems!

yes, it has been fixed.thanks!