Skip to content

Instantly share code, notes, and snippets.

@allanbatista
Created January 24, 2020 13:58
Show Gist options
  • Save allanbatista/49021c27446ccb19645381670306a674 to your computer and use it in GitHub Desktop.
Save allanbatista/49021c27446ccb19645381670306a674 to your computer and use it in GitHub Desktop.
set seed for keras and tensorflow
import tensorflow as tf
import numpy as np
import random as rn
from tensorflow.keras import backend as K
np.random.seed(0)
rn.seed(0)
session_conf = tf.ConfigProto(intra_op_parallelism_threads=1, inter_op_parallelism_threads=1)
tf.set_random_seed(0)
sess = tf.Session(graph=tf.get_default_graph(), config=session_conf)
K.set_session(sess)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment