Kashgari icon indicating copy to clipboard operation
Kashgari copied to clipboard

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

Open ahmad-alismail opened this issue 3 years ago • 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!

ahmad-alismail avatar Feb 02 '21 08:02 ahmad-alismail

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

BrikerMan avatar Feb 14 '21 01:02 BrikerMan

I got the same error! Did you solve it?

wangberry avatar Feb 23 '21 11:02 wangberry

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.

BrikerMan avatar Jul 07 '21 01:07 BrikerMan

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

wangberry avatar Jul 08 '21 02:07 wangberry

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.

stale[bot] avatar Apr 16 '22 03:04 stale[bot]