ElegantRL icon indicating copy to clipboard operation
ElegantRL copied to clipboard

'AgentPPO' object has no attribute 'traj_list'

Open HarryLukKF opened this issue 2 years ago • 8 comments

There is an error when I try to excute the train function in Demo_MultiCrypto_Trading.ipynb

AttributeError: 'AgentPPO' object has no attribute 'traj_list' image

Please kindly advise how should I fix this error? Many thanks in advance

HarryLukKF avatar Jul 02 '22 04:07 HarryLukKF

same here!

altosssss avatar Jul 06 '22 14:07 altosssss

Also encountered this issue when running Demo_MultiCrypto_Trading.ipynb I spent quite a long time debugging it and finally got it working by changing these things:

  1. elegantrl/agents/AgentBase.py line 43, insert:
self.traj_list = [
	[list() for _ in range(4 if self.if_off_policy else 5)]
	for _ in range(self.env_num)
]
  1. elegantrl/agents/AgentPPO.py line 88, change to: return self.convert_trajectory(traj_list, last_done), step_i

  2. elegantrl/train/evaluator.py line 60, comment it out

  3. finrl-meta/agents/elegantrl_models.py line 112, change to: environment.cash

  4. finrl-meta/agents/elegantrl_models.py line 114 change to: environment.price_array[environment.time] * environment.stocks

AlexLiddiard avatar Jul 06 '22 14:07 AlexLiddiard

Also encountered this issue when running Demo_MultiCrypto_Trading.ipynb I spent quite a long time debugging it and finally got it working by changing these things:

  1. elegantrl/agents/AgentBase.py line 43, insert:
self.traj_list = [
	[list() for _ in range(4 if self.if_off_policy else 5)]
	for _ in range(self.env_num)
]
  1. elegantrl/agents/AgentPPO.py line 88, change to: return self.convert_trajectory(traj_list, last_done), step_i
  2. elegantrl/train/evaluator.py line 60, comment it out
  3. finrl-meta/agents/elegantrl_models.py line 112, change to: environment.cash
  4. finrl-meta/agents/elegantrl_models.py line 114 change to: environment.price_array[environment.time] * environment.stocks

Thanks Alex. Wondering if you tried run it on Colab?

altosssss avatar Jul 07 '22 07:07 altosssss

Also encountered this issue when running Demo_MultiCrypto_Trading.ipynb I spent quite a long time debugging it and finally got it working by changing these things:

  1. elegantrl/agents/AgentBase.py line 43, insert:
self.traj_list = [
	[list() for _ in range(4 if self.if_off_policy else 5)]
	for _ in range(self.env_num)
]
  1. elegantrl/agents/AgentPPO.py line 88, change to: return self.convert_trajectory(traj_list, last_done), step_i
  2. elegantrl/train/evaluator.py line 60, comment it out
  3. finrl-meta/agents/elegantrl_models.py line 112, change to: environment.cash
  4. finrl-meta/agents/elegantrl_models.py line 114 change to: environment.price_array[environment.time] * environment.stocks

Thanks Alex. Wondering if you tried run it on Colab?

Yes, I am getting the same error both on ubuntu and google Colab

bassemfg avatar Jul 09 '22 15:07 bassemfg

Same problem here! Solution mentioned by @AlexLiddiard solved the issue. But why it hasn't been fixed yet on elegantrl?!

mhdmyz avatar Jul 11 '22 11:07 mhdmyz

Also, if when I try other agents like ddpg or td3 or sac, I get another error in the same line saying that init() expects 4 arguments but got 5. I spent a couple of hours trying to debug it but no luck. Anyone has any ideas?

bassemfg avatar Jul 12 '22 00:07 bassemfg

I modified the question related to 'traj_list'. The file ' demo_A2C_PPO.py ' and ' demo_PPO_H.py ' could run correctly now!

shixun404 avatar Jul 14 '22 18:07 shixun404

By the way, demo_DDPG_TD3_SAC.py and demo_DDPG_H.py run correctly as well~

shixun404 avatar Jul 14 '22 18:07 shixun404