Как сохранить несколько параметров журнала, используя AzureML SDK для Python? - PullRequest
0 голосов
/ 22 января 2020

Я использую AzureML SDK для Python, чтобы определить прогон и назначить параметры журнала, как показано ниже.

run = Run.get_context()

run.parent.log("param1", 25)
run.parent.log("param2", 100)
run.parent.log("param3", 10)
run.parent.log("param4", 40)

Проблема в том, что в машинном обучении я вижу только param1 и param2 Рабочая область обслуживания. Есть ли ограничения на количество переменных?

1 Ответ

0 голосов
/ 27 января 2020

Короткий ответ - НЕТ после того, как я просмотрел исходный код azureml-core, полученный при распаковке файла azureml_core-1.0.85-py2.py3-none-any.whl.

Источник ключа коды здесь.

# azureml_core-1.0.85-py2.py3-none-any.whl\azureml\core\run.py
class Run(_RunBase):
    .......

    @classmethod
    def get_context(cls, allow_offline=True, used_for_context_manager=False, **kwargs):
        """Return current service context.

        Use this method to retrieve the current service context for logging metrics and uploading files. If
        ``allow_offline`` is True (the default), actions against the Run object will be printed to standard
        out.

        .. remarks::

            This function is commonly used to retrieve the authenticated Run object
            inside of a script to be submitted for execution via experiment.submit(). This run object is both
            an authenticated context to communicate with Azure Machine Learning services and a conceptual container
            within which metrics, files (artifacts), and models are contained.

            .. code-block:: python

                run = Run.get_context() # allow_offline=True by default, so can be run locally as well
                ...
                run.log("Accuracy", 0.98)
                run.log_row("Performance", epoch=e, error=err)

        :param cls: Indicates class method.
        :param allow_offline: Allow the service context to fall back to offline mode so that the training script
            can be tested locally without submitting a job with the SDK. True by default.
        :type allow_offline: bool
        :param kwargs: A dictionary of additional parameters.
        :type kwargs: dict
        :return: The submitted run.
        :rtype: azureml.core.run.Run
        """
        try:
            experiment, run_id = cls._load_scope()

            # Querying for the run instead of initializing to load current state
            if used_for_context_manager:
                return _SubmittedRun(experiment, run_id, **kwargs)
            return _SubmittedRun._get_instance(experiment, run_id, **kwargs)
        except RunEnvironmentException as ex:
            module_logger.debug("Could not load run context %s, switching offline: %s", ex, allow_offline)
            if allow_offline:
                module_logger.info("Could not load the run context. Logging offline")
                return _OfflineRun(**kwargs)
            else:
                module_logger.debug("Could not load the run context and allow_offline set to False")
                raise RunEnvironmentException(inner_exception=ex)

class _OfflineRun(ChainedIdentity):
    def __init__(self, parent_logger=None, run_id=None, **kwargs):
        self._run_id = "OfflineRun_{}".format(uuid4()) if run_id is None else run_id
        super(_OfflineRun, self).__init__(
            _ident=self._run_id,
            _parent_logger=parent_logger if parent_logger is not None else module_logger)

    ....

    def log(self, name, value, description=""):
        self._emit("scalar", name, value)

    ....

    def _emit(self, type, name, value):
        print("Attempted to log {0} metric {1}:\n{2}".format(type, name, value))

Объект run, полученный из функции get_context, работает в автономном режиме, поэтому его функция log будет просто псевдонимом print.

...