Solve the problem of TensorFlow training model and saving quantity limit

  • 2021-09-12 01:36:37
  • OfStack

The results of each convolution neural network training only save the last part. After consulting the relevant data under 1, it is found that it is the default value used when defining saver. Here, the following settings are made:


 saver 
 =
 tf.train.Saver(
 max_to_keep
 =
 100
 ,
 keep_checkpoint_every_n_hours
 =
 1
 )

Add: Solve the problem that TensorFlow can only save 5 models

Get to the point

Find this code in the code of the training model: tf. train. Saver (),

Change to:


tf.train.Saver(max_to_keep = m) # m For the number of models you want to save 

Expand

Optional parameters in the Saver class


tf.train.Saver(max_to_keep = m, keep_checkpoint_every_n_hours = n)

max_to_keep Save the number of models closest to the current training, and the default value is 5. If you want to save it all, and the computer memory is enough, how big it is to set it.

keep_checkpoint_every_n_hours Save the model once every n hours, with a default value of 10,000 (in general, it should not be trained for such a long time, so it is equivalent to not saving according to time, but saving according to the set number of epoch saving nodes).


Related articles: