BrikerMan/Kashgari

Why can't I get reproducible results in even though I set the random seeds?

ahmad-alismail opened this issue · 5 comments

Hello,
I am trying to use this framework for text labeling with all existed methods with BERT embedding. However, each time I run the code I get different result. I set both nump.random and tensorflow.set_random_seed, but for some reasons I can't get reproducible results:

# Seed value
# Apparently you may use different seed values at each stage
seed_value= 42

# 1. Set `PYTHONHASHSEED` environment variable at a fixed value
import os
os.environ['PYTHONHASHSEED']=str(seed_value)

# 2. Set `python` built-in pseudo-random generator at a fixed value
import random
random.seed(seed_value)

# 3. Set `numpy` pseudo-random generator at a fixed value
import numpy as np
np.random.seed(seed_value)

# 4. Set `tensorflow` pseudo-random generator at a fixed value
import tensorflow as tf
tf.random.set_seed(seed_value)

Environment

  • OS [e.g. Mac OS, Linux]: Mac OS
  • Python Version: 3.6 - Google-colab ( training on GPU)

Thanks in Advance!

I haven't tried this use-case. Let me test & come back to you.

I got the same error! Did you solve it?

I got the same error! Did you solve it?
Not yet. Which corpus you are using to train. Can you share a colab with this issue so that I can follow up.

I got the same error! Did you solve it?
Not yet. Which corpus you are using to train. Can you share a colab with this issue so that I can follow up.

Unreproducibility should not be caused by the corpus. Maybe this can help: https://github.com/NVIDIA/framework-determinism

stale commented

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.