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.
CodePudding user response:
Short answer: You cannot extract the current state of the seed.
Long Answer: see this post.