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.
        """

  • 相关阅读:
    1010每次备份我的MySQL数据库
    1008win7与虚拟机中的linux共享文件的(详细)方法
    0930MySQL中实现高性能高并发计数器方案(例如文章点击数)
    0929shell操作mysql
    0929mysql前缀索引如何找到合适的位数
    0929mysql 用户管理和权限设置
    学习笔记之机器学习实战 (Machine Learning in Action)
    学习笔记之Python for Data Analysis
    学习笔记之入行数据科学,这些书一定要看
    面试总结之Python
  • 原文地址:https://www.cnblogs.com/YouXiangLiThon/p/7890825.html
Copyright © 2011-2022 走看看