AI4Finance-Foundation/FinRL-Tutorials

Resolve this error

Closed this issue · 7 comments


TypeError Traceback (most recent call last)
in <cell line: 1>()
----> 1 train(start_date = '2022-08-25',
2 end_date = '2022-08-31',
3 ticker_list = ticker_list,
4 data_source = 'alpaca',
5 time_interval= '1Min',

2 frames
in train_agent(args)
308 env = build_env(args.env_class, args.env_args)
309 agent = args.agent_class(args.net_dims, args.state_dim, args.action_dim, gpu_id=args.gpu_id, args=args)
--> 310 agent.states = env.reset()[np.newaxis, :]
311
312 evaluator = Evaluator(eval_env=build_env(args.env_class, args.env_args),

TypeError: tuple indices must be integers or slices, not tuple

it need to change to : agent.states = env.reset()[0][np.newaxis, :]

Thank you

in explore_env(self, env, horizon_len)
201
202 ary_action = convert(action).detach().cpu().numpy()
--> 203 ary_state, reward, done, _ = env.step(ary_action)
204 if done:
205 ary_state = env.reset()

ValueError: too many values to unpack (expected 4). Now it is showing another error.

all of the env.reset() you need to do the same env.reset()[0]

but I am still fighting to understand how everything is done, wish they had a manual.... it is sooo cryptic.... I been trying to modify the models, but they dont improve the learning....

Yes, model is showing error in every step. Thanks a lot for your help.

After modifying env.reset() to env.reset()[0] this error is resolved.