AI4Finance-Foundation / FinRL-Tutorials

Tutorials. Please star.
https://ai4finance.org
MIT License
848 stars 349 forks source link

Resolve this error #79

Closed Anupa-123 closed 8 months ago

Anupa-123 commented 8 months ago

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

TheStoneMX commented 8 months ago

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

Anupa-123 commented 8 months ago

Thank you

Anupa-123 commented 8 months ago

in explore_env(self, env, horizon_len) 201 202 ary_action = convert(action).detach().cpu().numpy() --> 203 arystate, 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.

TheStoneMX commented 8 months ago

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

TheStoneMX commented 8 months ago

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....

Anupa-123 commented 8 months ago

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

Anupa-123 commented 8 months ago

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