Reproducibility in Keras

I bet I am not the only one that tried to figure this out! Of course I google’d around but really could not find a solution to make a Keras model expel the same results every time I execute the notebook cell with the compile and fit of the model. I read and applied the recipe in the official Keras documentation but still my code was returning different results. The solution came when I read the details in the Tensorflow documentation for tf.random.set_seed. It turns out that in order to make a Keras model compilation and fit methods reproducible we need to wrap our model in a function to leverage what the TensorFlow documentation says about functions:

Continue reading “Reproducibility in Keras”