AI4Finance-Foundation / FinRL

FinRL: Financial Reinforcement Learning. 🔥
https://ai4finance.org
MIT License
9.61k stars 2.33k forks source link

assert hasattr(self.agent, 'init') AssertionError (elegantrl-0.3.3 ) #719

Open hokhay opened 1 year ago

hokhay commented 1 year ago

Describe the bug Run into an assertionError in Elegantrl-0.3.3-py3.9.egg-->config.py assert hasattr(self.agent, 'init') AssertionError

Error message

File "/home/FinRL/FinRL-Library/finrl/agents/elegantrl/models.py", line 87, in train_model
    train_and_evaluate(model)
  File "/home/FinRL/FinRL-Library/venv/lib/python3.9/site-packages/elegantrl-0.3.3-py3.9.egg/elegantrl/train/run.py", line 15, in train_and_evaluate
    args.init_before_training()  # necessary!
  File "/home/FinRL/FinRL-Library/venv/lib/python3.9/site-packages/elegantrl-0.3.3-py3.9.egg/elegantrl/train/config.py", line 191, in init_before_training
    assert hasattr(self.agent, 'init')
AssertionError

I suppose this due to update in elegantrl-0.3.3.

diplinfmarkodrews commented 1 year ago

The implementation of the initialization doesn't seem to finished yet for elegantrl. There are multiple issues still.

  1. There is further selection layer needed for concrete implementation of the agents. MODELS = {"ddpg": AgentDDPG.AgentDDPG(), "td3": AgentTD3.AgentTD3(), "sac": AgentSAC.AgentSAC(), "ppo": AgentPPO.AgentPPO()} in finrl.agents.elegantrl..models.py -temporary fix
  2. Argument class has no argument agent_class, it has to be changed to agent and will only accept an object with members init, explore_env, ...
  3. The gpu_id is not initialized properly