March 2019
Intermediate to advanced
196 pages
4h 50m
English
In order to save and load the values of tensors, here is the best method (see Chapter 2, Keras, a High-Level API for TensorFlow 2, for methods to save complete models):
variable = tf.Variable([[1,3,5,7],[11,13,17,19]])checkpoint= tf.train.Checkpoint(var=variable)save_path = checkpoint.save('./vars')variable.assign([[0,0,0,0],[0,0,0,0]])variablecheckpoint.restore(save_path)print(variable)
The output will be as follows:
<tf.Variable 'Variable:0' shape=(2, 4) dtype=int32, numpy= array([[ 1, 3, 5, 7], [11, 13, 17, 19]], dtype=int32)>
Read now
Unlock full access