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

Turn the randomness off in order to reproduce results #30

Open
BogdanM1 opened this issue Nov 6, 2021 · 3 comments
Open

Turn the randomness off in order to reproduce results #30

BogdanM1 opened this issue Nov 6, 2021 · 3 comments

Comments

@BogdanM1
Copy link

BogdanM1 commented Nov 6, 2021

Is there a way to exclude all the stochastics within SciANN so that we get results that can be easily reproduced?

So far I tried
import tensorflow as tf
from numpy.random import seed
import random

_seed = 0
seed(_seed)
random.seed(_seed)
tf.random.set_seed(_seed)
tf.compat.v1.set_random_seed(_seed)

but I am getting different results each time I run the training.

@BogdanM1 BogdanM1 changed the title Turn the randomness off Turn the randomness off in order to reproduce results Nov 6, 2021
@ehsanhaghighat
Copy link
Collaborator

ehsanhaghighat commented Nov 6, 2021 via email

@BogdanM1
Copy link
Author

BogdanM1 commented Nov 6, 2021

Thank you for your fast response!

This is what I did:
import tensorflow.compat.v1 as tf
tf.disable_v2_behavior()
import tensorflow as tf
from numpy.random import seed
import random
import sciann as sn

      _seed = 0
      
      seed(_seed)
      random.seed(_seed)
      tf.random.set_seed(_seed)
      tf.compat.v1.set_random_seed(_seed)
      
      sn.set_random_seed(_seed)
      
      session_conf = tf.compat.v1.ConfigProto(intra_op_parallelism_threads=1,inter_op_parallelism_threads=1)
      sess = tf.compat.v1.Session(graph=tf.compat.v1.get_default_graph(), config=session_conf)
      K.set_session(sess)

Unfortunatelly, I am still getting minor differences in my results.

@pradhyumna85
Copy link

Hey @BogdanM1,
Just have a look at this issue which I raised - "https://github.com/sciann/sciann/issues/53", and you can also find the code changes in the associated pull request "https://github.com/sciann/sciann/pull/57" which I raised.

This tweak worked for me for reproducibility. Let me know it that helps.

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

3 participants