tensorforce / tensorforce

Tensorforce: a TensorFlow library for applied reinforcement learning
Apache License 2.0
3.29k stars 532 forks source link

How to set random seed #375

Closed mysl closed 6 years ago

mysl commented 6 years ago

Hi, a quick question. Is there a way to set random seed in tensorforce? Thanks!

michaelschaarschmidt commented 6 years ago

Hi, I think you can set a seed in tensorflow somewhere https://www.tensorflow.org/api_docs/python/tf/set_random_seed This however depends on the scope, so you might have to place that somewhere in the model..

mysl commented 6 years ago

ok, got it thanks

ecorreig commented 5 years ago

Hi, how did you do it, @mysl? I can get the vpg agent to give the same results twice.

Thanks!

AlexKuhnle commented 5 years ago

The newer branch versions should support this, see here. Alternatively, it should be possible to just call these three lines before instantiating an agent.

ecorreig commented 5 years ago

Yeah, I already did this and also call the lines but with no luck...

ecorreig commented 5 years ago

Oh, by the way, there is a small bug in here I think; now random.seed has the parameter "a", not "n", so, at line 84 it should be random.seed(a=seed)

AlexKuhnle commented 5 years ago

Can you post the lines how you call Tensorforce after setting seeds? I assume your environment does not introduce any randomness?

ecorreig commented 5 years ago

It's a little involved and the code is protected... :-( The environment introduces randomness but it should be under control with more random seeds.

I'll try to get a minimal example and get back to you; thanks for the help!

AlexKuhnle commented 5 years ago

Yes, that would be great, thanks.