AI4Finance-Foundation / FinRL

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

main.py - Could not broadcast input array from shape #206

Closed zywang624 closed 2 years ago

zywang624 commented 3 years ago

I run "python main.py --mode=train" as mentioned in README, and it reports that the following error. 4

b-tank1 commented 3 years ago

Does this actually impact anything? I'm able to run the notebooks despite this error

Wisgon commented 3 years ago

Same problem. @b-tank1 Which notebook do you run?

peacemind commented 3 years ago

I get same error when running "python3 main.py --mode=train" on my Ubuntu 20.04 (Python 3.8): The following show part of the error messages: ///////////////////// Shape of DataFrame: (156457, 8) ==============Start Feature Engineering=========== Successfully added technical indicators Successfully added turbulence index Traceback (most recent call last): File "main.py", line 52, in main() File "main.py", line 38, in main finrl.autotrain.training.train_one() File "/home/happy/gitprojects/rl/FinRL-Library/finrl/autotrain/training.py", line 67, in train_one envtrain, = e_train_gym.get_sb_env() File "/home/happy/gitprojects/rl/FinRL-Library/finrl/env/env_stocktrading.py", line 379, in get_sb_env obs = e.reset() File "/home/happy/miniconda3/envs/finrl-venv/lib/python3.8/site-packages/stable_baselines3/common/vec_env/dummy_vec_env.py", line 62, in reset self._save_obs(env_idx, obs) File "/home/happy/miniconda3/envs/finrl-venv/lib/python3.8/site-packages/stable_baselines3/common/vec_env/dummy_vec_env.py", line 92, in _save_obs self.buf_obs[key][env_idx] = obs ValueError: could not broadcast input array from shape (292,) into shape (301,)

///////// Any ideas how to fix this error?

RomanZWang commented 3 years ago

222

zhumingpassional commented 2 years ago

Some stock may not have data in the full-time period, so that the length is wrong. You can try remove some stock, or revise the start-end date.