Keras produce different index per training step

30 Views Asked by At

I want to implement "Controlled Dropout" similar to this paper.

I have a list containing the dropout configurations as bernoulli vectors and I want all of them to be used during training. To define a counter and circle through the list does not work, probably because of a lot optimization going on with fitting the network. The current idea is to index from the list by using keras.backend.random.randint(0, self.max_dropout_configs), however it is hard to verify if this solution works. Do you know if keras.backend.random.randint returns a different int per training step, or just one in the beginning?

I really appreciate your help!

1

There are 1 best solutions below

2
achrafhamid On

keras.backend is based on TensorFlow which have a random seed that you can set manually so that it generate the same integer at each training step.

np.random.seed(123)
tf.random.set_seed(123)

You can add these seeds in the beginning of your code and it must get solved.