question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[Question] Using Random Seed Properly Custom Environment.

See original GitHub issue

How 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:closed
  • Created 3 years ago
  • Comments:5

github_iconTop GitHub Comments

0reactions
araffincommented, Mar 24, 2020

Ok I need to register my environment so that i can use this class. thanks

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 pass env_kwargs)

Read more comments on GitHub >

github_iconTop Results From Across the Web

c# - How do I seed a random class to avoid getting duplicate ...
A good seed generation for me is: Random rand = new Random(Guid.NewGuid().GetHashCode());. It is very random. The seed is always different because the...
Read more >
Properly Setting the Random Seed in ML Experiments. Not as ...
The good news is that by carefully setting the random seed across your pipeline you can achieve reproducibility. The “seed” is a starting...
Read more >
Python random.seed() function to initialize the pseudo-random ...
By setting the custom seed value, we can reproduce the data given by a pseudo-random number generator. Choose the same elements from the ......
Read more >
Custom Environments in OpenAI's Gym | Towards Data Science
Beginner's guide on how to set up, verify, and use a custom environment in reinforcement learning training with Python.
Read more >
The results changed even though seed is fixed [closed]
I am using a reinforcement learning model for some tasks. and for the model, I am using stable_baselin3 and for the environment, I...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found