要在Keras / Tensorflow中获得确定性结果,(除其他外)有必要“停用并行性”,如Keras doc中所述:
# Force TensorFlow to use single thread.
# Multiple threads are a potential source of
# non-reproducible results.
# For further details, see: https://stackoverflow.com/questions/42022950/which-seeds-have-to-be-set-where-to-realize-100-reproducibility-of-training-res
session_conf = tf.ConfigProto(intra_op_parallelism_threads=1, inter_op_parallelism_threads=1)
This thread还指出(在评论中):
You also need to remove parallelism from your computation because that is often non-deterministic
是什么使Tensorflow并行计算具有不确定性?