Set various random seeds required to ensure reproducible results. The
seed value will establish a new random seed for R, Python, NumPy,
and TensorFlow. GPU computations and CPU parallelism will also be disabled by
use_session_with_seed(seed, disable_gpu = TRUE, disable_parallel_cpu = TRUE, quiet = FALSE)
A single value, interpreted as an integer
TRUE to disable GPU execution (see Parallelism below).
TRUE to disable CPU parallelism (see
TRUE to suppress printing of messages.
TensorFlow session object, invisibly
By default the
disables GPU and CPU parallelism, since both can result in
non-determinisitc execution patterns (see
https://stackoverflow.com/questions/42022950/). You can optionally enable
GPU or CPU parallelism by setting the
disable_parallel_cpu parameters to
This function must be called at the very top of your script (i.e.
library(keras), etc.). Any
existing TensorFlow session is torn down via
This function takes all measures known to promote reproducible results from TensorFlow sessions, however it's possible that various individual TensorFlow features or dependent libraries escape its effects. If you encounter non-reproducible results please investigate the possible sources of the problem, contributions via pull request are very welcome!
Packages which need to be notified before and after the seed is set
can register for the "tensorflow.on_before_use_session" and
"tensorflow.on_use_session" hooks (see
setHook()) for additional
details on hooks).