zoukankan      html  css  js  c++  java
  • tensorflow 高级api使用分布式之配置

      """Constructor.

        Sets the properties `cluster_spec`, `is_chief`, `master` (if `None` in the
        args), `num_ps_replicas`, `task_id`, and `task_type` based on the
        `TF_CONFIG` environment variable, if the pertinent information is
        present. The `TF_CONFIG` environment variable is a JSON object with
        attributes: `cluster`, `environment`, and `task`.

        `cluster` is a JSON serialized version of `ClusterSpec`'s Python dict from
        `server_lib.py`, mapping task types (usually one of the TaskType enums) to a
        list of task addresses.

        `environment` specifies the runtime environment for the job (usually one of
        the `Environment` enums). Defaults to `LOCAL`.

        `task` has two attributes: `type` and `index`, where `type` can be any of
        the task types in `cluster`. When `TF_CONFIG` contains said information, the
        following properties are set on this class:

        * `task_type` is set to `TF_CONFIG['task']['type']`. Defaults to `None`.
        * `task_id` is set to `TF_CONFIG['task']['index']`. Defaults to 0.
        * `cluster_spec` is parsed from `TF_CONFIG['cluster']`. Defaults to {}.
        * `master` is determined by looking up `task_type` and `task_id` in the
          `cluster_spec`. Defaults to ''.
        * `num_ps_replicas` is set by counting the number of nodes listed
          in the `ps` attribute of `cluster_spec`. Defaults to 0.
        * `num_worker_replicas` is set by counting the number of nodes listed
          in the `worker` attribute of `cluster_spec`. Defaults to 0.
        * `is_chief` is deteremined based on `task_type`, `type_id`, and
          `environment`.

        Example:
        ```
          cluster = {'ps': ['host1:2222', 'host2:2222'],
                     'worker': ['host3:2222', 'host4:2222', 'host5:2222']}
          os.environ['TF_CONFIG'] = json.dumps(
              {'cluster': cluster,
               'task': {'type': 'worker', 'index': 1}})
          config = ClusterConfig()
          assert config.master == 'host4:2222'
          assert config.task_id == 1
          assert config.num_ps_replicas == 2
          assert config.num_worker_replicas == 3
          assert config.cluster_spec == server_lib.ClusterSpec(cluster)
          assert config.task_type == 'worker'
          assert not config.is_chief
        ```

        Args:
          master: TensorFlow master. Defaults to empty string for local.
          evaluation_master: The master on which to perform evaluation.
        """

  • 相关阅读:
    IBM WebSphere MQ 7.5基本用法
    IBM WebSphere MQ介绍安装以及配置服务详解
    Windows平台上使用Github搭建Git服务器的图文教程
    Git安装和TortoiseGit详细使用教程【基础篇】
    DOS命令之at命令详解
    单元测试数据库 -- 使用事物回滚测试
    VS中实时获取SVN的版本号并写入到AssemblyInfo.cs中
    SQL2008中Merge的用法
    VS版本号定义、规则和相关的Visual Studio插件
    JSON字符串互相转换的三种方式和性能比较
  • 原文地址:https://www.cnblogs.com/YouXiangLiThon/p/7890825.html
Copyright © 2011-2022 走看看