[Question] Using Random Seed Properly Custom Environment.
See original GitHub issueHow to use the seed function properly? It seems it that it still selecting random data. The starting dates are different.
I just use the seed like this.
n_cpu = 1
env = SubprocVecEnv([lambda:Monitor(StockTradingEnv(df),log_dir) for i in range(n_cpu)])
env.seed(1)
When I run the program, every time it will choose a random data.
First run: The date is 2010-04-06
logging timesteps ['tmp/'] reset Date: ['2010-04-06'] Open: [238.2] Close: [239.54] Step function _take_action actiontype -0.18988504 Date: ['2010-04-07'] Open: [239.72] Close: [240.6] print_step Profit: 0.0 Step: 3083 Balance: 207.06486251360002 Shares held: 41 (Total sold: 0) Avg cost for held shares: 238.85207652405853 (Total sales value: 0) Net worth: 10000.0 (Max net worth: 10000) Profit: 0.0
Second Run the Date is 2018-10-19
logging timesteps ['tmp/'] reset Date: ['2018-10-19'] Open: [218.06] Close: [219.31] Step function _take_action actiontype 0.23568505 Date: ['2018-10-22'] Open: [219.79] Close: [220.65] print_step Profit: 0.0 Step: 5235 Balance: 170.80492586384753 Shares held: 45 (Total sold: 0) Avg cost for held shares: 218.42655720302562 (Total sales value: 0) Net worth: 10000.0 (Max net worth: 10000) Profit: 0.0
Issue Analytics
- State:
- Created 3 years ago
- Comments:5
Top GitHub Comments
https://github.com/hill-a/stable-baselines/blob/d2364c9d565f419092504f01d49eae9b631bc226/stable_baselines/common/cmd_util.py#L52
in
https://github.com/hill-a/stable-baselines/blob/d2364c9d565f419092504f01d49eae9b631bc226/stable_baselines/common/cmd_util.py#L18-L72
Please use
make_vec_env
btw (cf doc).You don’t have to, the doc says:
:param env_id: (str or Type[gym.Env]) the environment ID or the environment class
so
env_id=YourCustomEnvClass
would work (and you can passenv_kwargs
)