Reproducible results using Keras with TensorFlow backend

前端 未结 3 1031
爱一瞬间的悲伤
爱一瞬间的悲伤 2020-12-10 04:56

I am using Keras to build a deep learning LSTM model, using TensorFlow backend. Each time I run the model, the result is different. Is there a way to fix the seed to create

3条回答
  •  不知归路
    2020-12-10 05:33

    There is an inherent randomness associated with deep learning leading to non reproducible results, But you can control it up to certain extent.

    Since we are using Deep neural network, we can have different randomness affecting our reproducibility leading to different results such as

    • Randomness in Initialization, such as weights.

    • Randomness in Regularization, such as dropout.

    • Randomness in Layers.

    • Randomness in Optimization.

    But there are several ways to mitigate this one option is to use summary statistics. Another method that will provide more reproducible result is to use a random seed with numpy and/or tensorflow, see:

    https://docs.scipy.org/doc/numpy-1.12.0/reference/generated/numpy.random.seed.html

    https://www.tensorflow.org/api_docs/python/tf/set_random_seed

    For the methods that are using GPUs we could specify it to use a deterministic method instead of the default non-deterministic method.For nvidia graphic cards see: docs.nvidia.com/cuda

提交回复
热议问题