python - Reading a random seed of a jupyter notebook -
is there way read "state" of random number generator in jupyter notebook?
for example, if ran cell specify neural network architecture, , train on data without specifying seed, there way can read seed used run this?
you can indeed read (and store) current state of rng, changes every time used, i.e. cannot describe after have run cell.
here example (since have tagged question withkeras
, assume interested in numpy rng, 1 used in keras):
import numpy np current_state = np.random.get_state() # produce random numbers: = np.random.randn(3) # array([-0.44270351, 1.42933504, 2.11385353]) # now, restoring rng state , producing again 3 random numbers, same result: np.random.set_state(current_state) b = np.random.randn(3) b # array([-0.44270351, 1.42933504, 2.11385353]) == b # array([ true, true, true], dtype=bool)
Comments
Post a Comment