danijar / dreamerv2

Mastering Atari with Discrete World Models

Home Page:https://danijar.com/dreamerv2

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Setting random seed

izkula opened this issue · comments

Dear Danijar,

I'm running into an issue that may be a non-issue, and I thought it was worth checking.

Are you able to reproduce training runs using a fixed random seed?
There is a 'seed' flag in the config file, but I cannot find where it is actually being used, and my runs do not appear fixed to a seed.

Additionally, I am running into what appears to be a weird bug, and I am wondering if you have insight. The model does not train properly if I try to manually set the random seeds by adding, before any other code:
np.random.seed(config.seed)
tf.random.set_seed(config.seed)
print(f'--> Setting random seed to {config.seed}')

For example, using dmc_walker_run, here is a training curve if I do not set the seed
image

Whereas here is a training curve if the only change I make is to add the above three lines.
image

This has been a consistent finding. I also see it if I try setting the random seed at other locations in the code.
Otherwise, I am getting consistent success training without setting a random seed ( --> congratulations and thank you for the wonderful codebase and algorithm :-)

Is this a known problem? And/or do you have any insight into why this might be the case. Is there a reason to give up trying to set a random seed?

Note: I have been using the original version of your repo (i.e. from March). Is this something you have knowingly fixed with subsequent updates?

Thank you so much.

Best,

Isaac

Hi Isaac, setting the seed is not supported in the code base. I don't know why it breaks with your two added lines. I could imagine that it's related to these two pieces of code that are there to make sampling faster on GPU and that removing them could help. Sorry that I can't help much more with debugging this but please feel free to post progress here for other people to see who might be interested in fixing the seed.