Skip to content Skip to sidebar Skip to footer

Gru Same Configurations But In Two Different Ways Produces Two Different Output In Tensorflow

I would like to do some sequence prediction in tensorflow using GRU. so I have created the same model in 2 different ways as follows: In model 1 I have a 2 GRUs, one after the othe

Solution 1:

so to reproduce the same results in different files, tf.set_random_seed() is not enough. I figured out that we need to also set the seed for the intializers of the gru cells as well as the initializers of the weights in the dense layer at the output (this is at least acccording to my model); so the definition of the cell is now:

cell1 = tf.nn.rnn_cell.GRUCell(cell_size, kernel_initializer=tf.glorot_normal_initializer(seed=123, dtype=m_dtype))

And for the dense layer:

output = tf.layers.dense(output, units=1, kernel_initializer=tf.glorot_uniform_initializer(seed=123, dtype=m_dtype))

Note that any other initializer could be used as long as we set the seed the dtype for it.

Post a Comment for "Gru Same Configurations But In Two Different Ways Produces Two Different Output In Tensorflow"