Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How could we control Random State? #6

Closed
yuchenlin opened this issue Jul 14, 2017 · 12 comments
Closed

How could we control Random State? #6

yuchenlin opened this issue Jul 14, 2017 · 12 comments

Comments

@yuchenlin
Copy link
Contributor

yuchenlin commented Jul 14, 2017

Hi, Guillaume,

I am very confused about why the training result is quite random since it seems that there is no shuffling of the data in the code.

I tried to set tf.set_random_seed(42) and np.random.seed(42) at the beginning of model.py, but it does not work.

Thanks very much,
Bill

@yuchenlin
Copy link
Contributor Author

OIC.. the random effect seems to be due to the Dropout.

@guillaumegenthial
Copy link
Owner

You're right, there is no shuffling anywhere. Randomness surely comes from dropout + initialization. However, if you carefully control the random seeds, you should get non-random convergence!

@yuchenlin
Copy link
Contributor Author

yuchenlin commented Jul 18, 2017

Thanks so much. Although simply setting the random state does not work, I found a page here regarding the exactly the same question.
I will have a try!

@SeekPoint
Copy link

maybe you should also set python's random seed fixed

@yuchenlin
Copy link
Contributor Author

It seems that even if I set dropout=1, the results are still changing.

@yuchenlin
Copy link
Contributor Author

@lovejasmine i have tried but not effective...: (

@yuchenlin
Copy link
Contributor Author

yuchenlin commented Jul 23, 2017

I tried use different tf random seed and I found that the results are very different than before.
Thus, it seems that setting random seed is effective to some extent but cannot keep the results 100% exactly the same. I guess it maybe due to the multi-thred thing.

It seems that the tensorflow is often complained by users about the random state stuff..

@guillaumegenthial
Copy link
Owner

Have you tried running it on CPU on a subset of the dataset with a batch of size 1 with dropout = 1? I'm not too familiar with tf random seeds, and the stackoverflow post you refered above seems to mention some pretty weird behavior. Batch size = 1 could alleviate the problem they're mentioning.

@grafael
Copy link

grafael commented Jul 28, 2017

@guillaumegenthial
Copy link
Owner

@yuchenlin did you make progress on this issue? Should we keep it open or should we close it?

@yuchenlin
Copy link
Contributor Author

@guillaumegenthial sorry for the delayed reply! I was busy doing other stuff. Yes, I guess we can close it. It seems that the current methods are difficult to maintain the stable results under the GPU settings. Thanks!

@guillaumegenthial
Copy link
Owner

@yuchenlin no problem! I'll close it, but I must confess that this is an interesting issue and I'd love to hear more about it if you find the answer one day.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants