There is a good chance that you can get deterministic results if you run your network on a CPU ( export CUDA_VISIBLE_DEVICES= ), with one thread in the native thread pool ( tf.Session(config=tf.ConfigProto(intra_op_parallelism_threads=1) ), one thread Python (without the multi-threaded queues that you get from ops, for example tf.batch ), and one well-defined order of operations.In addition, using inter_op_parallelism_threads=1 may help in some scenarios.
One problem is that floating point addition / multiplication is not associative, so one sure-fire way to get deterministic results is to use integer arithmetic or quantized values.
The ban is that you can highlight which operation is non-deterministic, and try to avoid using this op. For example, there is tf.add_n op, which says nothing about the order in which it sums up the values, but different orders give different results.
Getting deterministic results is a battle in a battle because determinism conflicts with performance, and performance is usually the goal that attracts more attention. An alternative to trying to have the same numbers on restart is to focus on numerical stability - if your algorithm is stable, you will get reproducible results (i.e. the same number of erroneous estimates), although the exact values of the parameters may vary slightly
source share