Spaces:
Runtime error
Runtime error
NORLIE JHON MALAGDAO
commited on
Update app.py
Browse files
app.py
CHANGED
@@ -57,9 +57,27 @@ def seed_everything(seed=42):
|
|
57 |
inter_op_parallelism_threads=1
|
58 |
)
|
59 |
|
60 |
-
|
61 |
-
|
62 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
63 |
sess = tf.compat.v1.Session(graph=tf.compat.v1.get_default_graph(), config=session_conf)
|
64 |
tf.compat.v1.keras.backend.set_session(sess)
|
65 |
|
|
|
57 |
inter_op_parallelism_threads=1
|
58 |
)
|
59 |
|
60 |
+
def seed_everything(seed=42):
|
61 |
+
# Seed value for Python's random library
|
62 |
+
random.seed(seed)
|
63 |
+
|
64 |
+
# Seed value for NumPy
|
65 |
+
np.random.seed(seed)
|
66 |
+
|
67 |
+
# Seed value for TensorFlow
|
68 |
+
tf.random.set_seed(seed)
|
69 |
+
|
70 |
+
# Ensure deterministic behavior
|
71 |
+
os.environ['PYTHONHASHSEED'] = str(seed)
|
72 |
+
os.environ['TF_DETERMINISTIC_OPS'] = '1'
|
73 |
+
os.environ['TF_CUDNN_DETERMINISTIC'] = '1'
|
74 |
+
|
75 |
+
# Set session configuration to ensure single-threaded execution
|
76 |
+
session_conf = tf.compat.v1.ConfigProto(
|
77 |
+
intra_op_parallelism_threads=1,
|
78 |
+
inter_op_parallelism_threads=1
|
79 |
+
)
|
80 |
+
|
81 |
sess = tf.compat.v1.Session(graph=tf.compat.v1.get_default_graph(), config=session_conf)
|
82 |
tf.compat.v1.keras.backend.set_session(sess)
|
83 |
|