Skip to content

Instantly share code, notes, and snippets.

@tomrunia
Created March 2, 2016 09:11
Show Gist options
  • Star 51 You must be signed in to star a gist
  • Fork 9 You must be signed in to fork a gist
  • Save tomrunia/1e1d383fb21841e8f144 to your computer and use it in GitHub Desktop.
Save tomrunia/1e1d383fb21841e8f144 to your computer and use it in GitHub Desktop.
Reading out binary TensorFlow log file and plotting process using MatplotLib
import numpy as np
from tensorflow.python.summary.event_accumulator import EventAccumulator
import matplotlib as mpl
import matplotlib.pyplot as plt
def plot_tensorflow_log(path):
# Loading too much data is slow...
tf_size_guidance = {
'compressedHistograms': 10,
'images': 0,
'scalars': 100,
'histograms': 1
}
event_acc = EventAccumulator(path, tf_size_guidance)
event_acc.Reload()
# Show all tags in the log file
#print(event_acc.Tags())
training_accuracies = event_acc.Scalars('training-accuracy')
validation_accuracies = event_acc.Scalars('validation_accuracy')
steps = 10
x = np.arange(steps)
y = np.zeros([steps, 2])
for i in xrange(steps):
y[i, 0] = training_accuracies[i][2] # value
y[i, 1] = validation_accuracies[i][2]
plt.plot(x, y[:,0], label='training accuracy')
plt.plot(x, y[:,1], label='validation accuracy')
plt.xlabel("Steps")
plt.ylabel("Accuracy")
plt.title("Training Progress")
plt.legend(loc='upper right', frameon=True)
plt.show()
if __name__ == '__main__':
log_file = "./logs/events.out.tfevents.1456909092.DTA16004"
plot_tensorflow_log(log_file)
@pimdh
Copy link

pimdh commented Jul 4, 2018

The EventAccumulator appears to have been moved to:

from tensorboard.backend.event_processing.event_accumulator import EventAccumulator

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment