i wanted save multiple models experiment noticed tf.train.saver()
constructor not save more 5 models. here simple code:
import tensorflow tf x = tf.variable(tf.zeros([1])) saver = tf.train.saver() sess = tf.session() in range(10): sess.run(tf.initialize_all_variables()) saver.save( sess, '/home/eneskocabey/desktop/model' + str(i) )
when ran code, saw 5 models on desktop. why this? how can save more 5 models same tf.train.saver()
constructor?
the tf.train.saver()
constructor takes optional argument called max_to_keep
, defaults keeping 5 recent checkpoints of model. save more models, specify value argument:
import tensorflow tf x = tf.variable(tf.zeros([1])) saver = tf.train.saver(max_to_keep=10) sess = tf.session() in range(10): sess.run(tf.initialize_all_variables()) saver.save(sess, '/home/eneskocabey/desktop/model' + str(i))
to keep all checkpoints, pass argument max_to_keep=none
saver constructor.
Comments
Post a Comment