How to get same accuracy with identical models in Keras and Tensorflow?

As we all know Keras backend uses Tensorflow and so it should give out same kind of results when we provide same parameters, hyper-parameters, weights and biases initialisation at each layer, but still the accuracy is different.

This maybe because of the batches of images which are fed at each step in both the models are not identical and as it gets shuffled randomly.

Is there any way in which we can make sure that the same batch of images are fed into the model while eliminating the randomness?

I have tried using all the same parameters, hyperparameters, same weights and biases initialization with seed values.

The accuracy of both the models are not same.

• Kindly check this answer on how to get reproducible results with Keras: stackoverflow.com/a/52897289/6204860 – pcko1 Sep 19 '19 at 10:08
• I dont have a problem on how to produce reproducible results with keras. I have a problem of not get same accuracy with an identical keras and tensorflow model. – Subham Tiwari Sep 20 '19 at 10:44

I created a rule to achieve reproducibility:

• Works for python 3.6, not 3.7
• First install Keras 2.2.4
• After install tensorflow 1.9

And finally in the code:

import numpy as np
import random as rn
import tensorflow as tf
import keras
from keras import backend as K

#-----------------------------Keras reproducible------------------#
SEED = 1234

tf.set_random_seed(SEED)
os.environ['PYTHONHASHSEED'] = str(SEED)
np.random.seed(SEED)
rn.seed(SEED)

session_conf = tf.ConfigProto(