You can not select more than 25 topics Topics must start with a chinese character,a letter or number, can include dashes ('-') and can be up to 35 characters long.

hyperdash.py 1.6 kB

4 years ago
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. #! /usr/bin/python
  2. # -*- coding: utf-8 -*-
  3. from __future__ import absolute_import
  4. import hyperdash as hd
  5. import tensorlayer as tl
  6. __all__ = ["HyperDashHandler", "monitor", "Experiment", "IPythonMagicsWrapper"]
  7. class HyperDashHandler(object):
  8. apikey = None
  9. @classmethod
  10. def reset_apikey(cls):
  11. cls.apikey = None
  12. @classmethod
  13. def set_apikey(cls, apikey):
  14. cls.apikey = apikey
  15. @classmethod
  16. def get_apikey(cls):
  17. if cls.apikey is None:
  18. raise ValueError(
  19. "Hyperdash API is not set.\n"
  20. "You can obtain your API Key using: `hyperdash login --email` or `hyperdash login --github`\n"
  21. "You should first call `HyperDashHandler.set_apikey('my_api_key')` in order to use `hyperdash`"
  22. )
  23. tl.logging.debug("Hyperdash API Key: %s" % cls.apikey)
  24. return cls.apikey
  25. @classmethod
  26. def monitor(cls, model_name, api_key=None, capture_io=True):
  27. if api_key is not None:
  28. cls.set_apikey(api_key)
  29. return hd.monitor(model_name, api_key_getter=cls.get_apikey, capture_io=capture_io)
  30. class Experiment(hd.Experiment):
  31. def __init__(
  32. self,
  33. model_name,
  34. api_key=None,
  35. capture_io=True,
  36. ):
  37. if api_key is not None:
  38. HyperDashHandler.set_apikey(api_key)
  39. super(Experiment,
  40. self).__init__(model_name=model_name, api_key_getter=HyperDashHandler.get_apikey, capture_io=capture_io)
  41. monitor = HyperDashHandler.monitor
  42. IPythonMagicsWrapper = hd.IPythonMagicsWrapper

TensorLayer3.0 是一款兼容多种深度学习框架为计算后端的深度学习库。计划兼容TensorFlow, Pytorch, MindSpore, Paddle.