'Does tensorflow.random have functions like get_state() and set_state()?
In TensorFlow, we can set seed by
import tensorflow as tf
tf.random.set_seed(1)
In my experiments, I wish to save the seed state in order to resume my training in case my execution is killed. I know the default random library in python and numpy.random both have functions to retrieve and set seed's state, such as
>>> import numpy as np
>>> np.random.seed(1)
>>> np.random.rand(1,1)
array([[0.417022]])
>>> state = np.random.get_state()
>>> np.random.rand(1,1)
array([[0.72032449]])
>>> np.random.set_state(state)
>>> np.random.rand(1,1)
array([[0.72032449]])
But I don't see similar functions from its documentation.
How may I save a tensorflow's seed state and reuse it? Thanks.
Solution 1:[1]
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Noltibus |
