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.

train_task_manager.py 2.9 kB

5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. # Copyright 2019 Huawei Technologies Co., Ltd
  2. #
  3. # Licensed under the Apache License, Version 2.0 (the "License");
  4. # you may not use this file except in compliance with the License.
  5. # You may obtain a copy of the License at
  6. #
  7. # http://www.apache.org/licenses/LICENSE-2.0
  8. #
  9. # Unless required by applicable law or agreed to in writing, software
  10. # distributed under the License is distributed on an "AS IS" BASIS,
  11. # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  12. # See the License for the specific language governing permissions and
  13. # limitations under the License.
  14. # ============================================================================
  15. """Train task manager."""
  16. from mindinsight.datavisual.common import exceptions
  17. from mindinsight.datavisual.common.enums import PluginNameEnum
  18. from mindinsight.datavisual.common.validation import Validation
  19. from mindinsight.datavisual.processors.base_processor import BaseProcessor
  20. from mindinsight.datavisual.data_transform.data_manager import DATAVISUAL_PLUGIN_KEY, DATAVISUAL_CACHE_KEY
  21. class TrainTaskManager(BaseProcessor):
  22. """Train task manager."""
  23. def get_single_train_task(self, plugin_name, train_id):
  24. """
  25. get single train task.
  26. Args:
  27. plugin_name (str): Plugin name, refer `PluginNameEnum`.
  28. train_id (str): Specify a training job to query.
  29. Returns:
  30. {'train_jobs': list[TrainJob]}, refer to restful api.
  31. """
  32. Validation.check_param_empty(plugin_name=plugin_name, train_id=train_id)
  33. Validation.check_plugin_name(plugin_name=plugin_name)
  34. train_job = self._data_manager.get_train_job_by_plugin(train_id=train_id, plugin_name=plugin_name)
  35. if train_job is None:
  36. raise exceptions.TrainJobNotExistError()
  37. return dict(train_jobs=[train_job])
  38. def get_plugins(self, train_id, manual_update=True):
  39. """
  40. Queries the plug-in data for the specified training job
  41. Args:
  42. train_id (str): Specify a training job to query.
  43. manual_update (bool): Specifies whether to refresh automatically.
  44. Returns:
  45. dict, refer to restful api.
  46. """
  47. Validation.check_param_empty(train_id=train_id)
  48. if manual_update:
  49. self._data_manager.cache_train_job(train_id)
  50. train_job = self._data_manager.get_train_job(train_id)
  51. try:
  52. data_visual_content = train_job.get_detail(DATAVISUAL_CACHE_KEY)
  53. plugins = data_visual_content.get(DATAVISUAL_PLUGIN_KEY)
  54. except exceptions.TrainJobDetailNotInCacheError:
  55. plugins = []
  56. if not plugins:
  57. default_result = dict()
  58. for plugin_name in PluginNameEnum.list_members():
  59. default_result.update({plugin_name: list()})
  60. return dict(plugins=default_result)
  61. return dict(
  62. plugins=plugins
  63. )

MindInsight为MindSpore提供了简单易用的调优调试能力。在训练过程中,可以将标量、张量、图像、计算图、模型超参、训练耗时等数据记录到文件中,通过MindInsight可视化页面进行查看及分析。