export_summary.py 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738
  1. #!/usr/bin/env python3
  2. # -*- coding: utf-8 -*-
  3. __author__ = "Christian Heider Nielsen"
  4. __doc__ = r"""
  5. Created on 31-10-2020
  6. """
  7. from pathlib import Path
  8. from matplotlib import pyplot
  9. from warg import ensure_existence
  10. from draugr import PROJECT_APP_PATH
  11. from draugr.tensorboard_utilities import TensorboardEventExporter
  12. from draugr.writers import StandardTrainingScalarsEnum
  13. if __name__ == "__main__":
  14. save = False
  15. event_files = list(PROJECT_APP_PATH.user_log.rglob("events.out.tfevents.*"))
  16. if len(event_files) > 0:
  17. for _path_to_events_file in event_files:
  18. print(f"Event file: {_path_to_events_file}")
  19. _out_dir = Path.cwd() / "exclude" / "results"
  20. ensure_existence(_out_dir)
  21. tee = TensorboardEventExporter(
  22. _path_to_events_file.parent, save_to_disk=save
  23. )
  24. print(f"Available tags: {tee.tags_available}")
  25. tee.export_line_plot(
  26. StandardTrainingScalarsEnum.training_loss.value, out_dir=_out_dir
  27. )
  28. if not save:
  29. pyplot.show()
  30. else:
  31. print("No events found")