0

I followed all the guidelines in keras docs, but I still have issues

import numpy as np
np.random.seed(0)
import random as rn
rn.seed(0)
import tensorflow as tf
tf.set_random_seed(0)
session_conf = tf.ConfigProto(intra_op_parallelism_threads=1, 
inter_op_parallelism_threads=1)

for i in range(3):
    sess = tf.Session(graph=tf.get_default_graph(), config=session_conf)
    K.set_session(sess)
    ## Keras Model ##
    ## Print Accuracy ##

I get different answers for all the three epochs

user239457
  • 1,766
  • 1
  • 16
  • 26

1 Answers1

0

The seeds have to be set in every epoch to get reproducible results

for i in range(3):
    rn.seed(0)
    np.random.seed(0)
    tf.set_random_seed(0)
    sess = tf.Session(graph=tf.get_default_graph(), config=session_conf)
    K.set_session(sess)
    ## Keras Model ##
    ## Print Accuracy ##

Refer to this answer for more

user239457
  • 1,766
  • 1
  • 16
  • 26