FinRL-Meta
FinRL-Meta copied to clipboard
TypeError: __init__() got an unexpected keyword argument 'agent' in elegantrl_models.py
I get the following error while running the elegantrl_models.py:
TypeError: init() got an unexpected keyword argument 'agent' in the 58th line of /agents/elegantrl_models.py
I understand "agent" argument in Arguments class of config.py has been changed to "agent_class"
So when I change the "agent" argument in the elegantrl_models.py to "agent_class", I get the following error:
ValueError: too many values to unpack (expected 2), in the 107th line of elegantrl/train/run.py
Has anyone solved?
I traced the issue but not sure how to solve it yet. In the train_and_evaluate
function in run.py
, agent.explore_env()
returns a list of 5 tensors while it's supposed to return 2 to set the trajectory
and step
variables.
I solved the issue, I'll create a pull request shortly.
Anyone solved this yet? Is there a PR already?
it's easy, the attribute Arguments.agent in config.py should be Arguments.agent_class
They are/were equivalent.
After that, you will get a module not callable error. To solve that, find elegantrl_models.py and replace the imports as :
# DRL models from ElegantRL: https://github.com/AI4Finance-Foundation/ElegantRL import torch from elegantrl.agents.AgentDDPG import AgentDDPG from elegantrl.agents.AgentPPO import AgentPPO from elegantrl.agents.AgentSAC import AgentSAC from elegantrl.agents.AgentTD3 import AgentTD3 from elegantrl.train.config import Arguments from elegantrl.train.run import init_agent from elegantrl.train.run import train_and_evaluate
I created the required PRs to solve the issue.
In addition to changing agent
to agent_class
in elegantrl_models.py, the run.py in elegantrl had to be modified as well.
@mhdmyz did you ever publish a PR about this? I stil have the same issue.