Register
Login
Resources
Docs Blog Datasets Glossary Case Studies Tutorials & Webinars
Product
Data Engine LLMs Platform Enterprise
Pricing Explore
Connect to our Discord channel

summary.py 893 B

You have to be logged in to leave a comment. Sign In
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
  1. import csv
  2. import json
  3. import os
  4. from wandb import util
  5. SUMMARY_FNAME = 'wandb-summary.json'
  6. class Summary(object):
  7. """Used to store summary metrics during and after a run."""
  8. def __init__(self, out_dir='.'):
  9. self.out_fname = os.path.join(out_dir, SUMMARY_FNAME)
  10. self.summary = {}
  11. def _write(self):
  12. with open(self.out_fname, 'w') as f:
  13. s = util.json_dumps_safer(self.summary, indent=4)
  14. f.write(s)
  15. f.write('\n')
  16. def __getitem__(self, k):
  17. return self.summary[k]
  18. def __setitem__(self, k, v):
  19. self.summary[k] = v
  20. self._write()
  21. def __delitem__(self, k):
  22. del self.summary[k]
  23. self._write()
  24. def get(self, k, default=None):
  25. return self.summary.get(k, default)
  26. def update(self, key_vals):
  27. self.summary.update(key_vals)
  28. self._write()
Tip!

Press p or to see the previous file or, n or to see the next file

Comments

Loading...