Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to turn off events.out.tfevents file in tf.contrib.learn Estimator

When using estimator.Estimator in tensorflow.contrib.learn, after training and prediction there are these files in the modeldir:

  • checkpoint
  • events.out.tfevents.1487956647
  • events.out.tfevents.1487957016
  • graph.pbtxt
  • model.ckpt-101.data-00000-of-00001
  • model.ckpt-101.index
  • model.ckpt-101.meta

When the graph is complicated or the number of variables is big, the graph.pbtxt file and the events files can be very big. Is here a way to not write these files? Since model reloading only needs the checkpoint files removing them won't affect evaluation and prediction down the road.

like image 684
JJ Crosskey Avatar asked Feb 24 '17 17:02

JJ Crosskey


2 Answers

On Google's Machine Learning Crash Course they use the following approach:

# Create classifier:
classifier = tf.estimator.DNNRegressor(
    feature_columns=feature_columns,
    optimizer=optimizer
)

# Train it:
classifier.train(
    input_fn=training_input_fn,
    steps=steps
)

# Remove event files to save disk space.
_ = map(os.remove, glob.glob(os.path.join(classifier.model_dir, 'events.out.tfevents*')))
like image 126
Ander Avatar answered Nov 15 '22 00:11

Ander


If you don't want the events.out.tfevents files to be written. Find in your code somethings like these and delete them.

tfFileWriter = tf.summary.FileWriter(os.getcwd())
tfFileWriter.add_graph(sess.graph)
tfFileWriter.close()
like image 25
Trieu Nguyen Avatar answered Nov 15 '22 00:11

Trieu Nguyen