dickreuter / neuron_poker

Texas holdem OpenAi gym poker environment with reinforcement learning based on keras-rl. Includes virtual rendering and montecarlo for equity calculation.
MIT License
628 stars 173 forks source link

AttributeError: 'NoneType' object has no attribute 'load_weights' #16

Closed SmokeyGab closed 5 years ago

SmokeyGab commented 5 years ago

Im trying to train and then play DQN.

Train works fine and it generated a weight file. Now I try to play and i suppose it can't load the weights for some reason.


Traceback (most recent call last):
  File "D:/Pokerbot/main.py", line 208, in <module>
    command_line_parser()
  File "D:/Pokerbot/main.py", line 73, in command_line_parser
    runner.dqn_play()
  File "D:/Pokerbot/main.py", line 201, in dqn_play
    self.env.add_player(DQNPlayer(load_model='neuron_poker-v0'))
  File "D:\Pokerbot\agents\agent_dqn.py", line 42, in __init__
    self.load(load_model)
  File "D:\Pokerbot\agents\agent_dqn.py", line 120, in load
    self.dqn.load_weights('dqn_{}_weights.h5'.format(env_name))
AttributeError: 'NoneType' object has no attribute 'load_weights'

Process finished with exit code 1
dickreuter commented 5 years ago

When you instantiate the player, you need to pass it the "load_model" parameter to point to the correct file name. It seems to be hard coded to neuron_poker-v0. Maybe this should be passed as an argument.

darkavatar23 commented 5 years ago

i've the same error, and tryed to pass che correct file name, but AttributeError: 'NoneType' object has no attribute 'load_weights' refers to self.dqn so still not working

welsonliang commented 5 years ago

I have the same error, I am sure that loading h5 filename is right

dickreuter commented 5 years ago

had to revert the PR, as it's causing issues: https://github.com/dickreuter/neuron_poker/issues/22

Also I'm getting File "C:\Users\dickr\git\neuron_poker\agents\agent_dqn.py", line 99, in initiate_agent self.dqn.compile(tf.optimizers.Adam(lr=1e-3), metrics=['mae']) File "C:\Users\dickr\Anaconda3\envs\neuron_poker\lib\site-packages\tensorflow\python\util\deprecation_wrapper.py", line 106, in getattr attr = getattr(self._dw_wrapped_module, name) AttributeError: module 'tensorflow' has no attribute 'optimizers'

vkresch commented 5 years ago

@dickreuter which tensorflow version are you using?

My dependencies it worked with: OS: Ubuntu 18.04

Python libraries:

dickreuter commented 5 years ago

you are right. The issue is not related to your PR. Reverted the revert :)

It seems keras-rl is not compatible with tf2