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.6 kB

5 years ago
5 years ago
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  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. class TrainTaskManager(BaseProcessor):
  21. """Train task manager."""
  22. def get_single_train_task(self, plugin_name, train_id):
  23. """
  24. get single train task.
  25. Args:
  26. plugin_name (str): Plugin name, refer `PluginNameEnum`.
  27. train_id (str): Specify a training job to query.
  28. Returns:
  29. {'train_jobs': list[TrainJob]}, refer to restful api.
  30. """
  31. Validation.check_param_empty(plugin_name=plugin_name, train_id=train_id)
  32. Validation.check_plugin_name(plugin_name=plugin_name)
  33. train_job = self._data_manager.get_train_job_by_plugin(train_id=train_id, plugin_name=plugin_name)
  34. if train_job is None:
  35. raise exceptions.TrainJobNotExistError()
  36. return dict(train_jobs=[train_job])
  37. def get_plugins(self, train_id, manual_update=True):
  38. """
  39. Queries the plug-in data for the specified training job
  40. Args:
  41. train_id (str): Specify a training job to query.
  42. manual_update (bool): Specifies whether to refresh automatically.
  43. Returns:
  44. dict, refer to restful api.
  45. """
  46. Validation.check_param_empty(train_id=train_id)
  47. train_job = self._data_manager.get_single_train_job(train_id, manual_update=manual_update)
  48. if not train_job:
  49. default_result = dict()
  50. for plugin_name in PluginNameEnum.list_members():
  51. default_result.update({plugin_name: list()})
  52. return dict(plugins=default_result)
  53. return dict(
  54. plugins=train_job['tag_mapping']
  55. )

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