当前位置: 首页>>代码示例>>Python>>正文


Python estimator._get_replica_device_setter函数代码示例

本文整理汇总了Python中tensorflow.contrib.learn.python.learn.estimators.estimator._get_replica_device_setter函数的典型用法代码示例。如果您正苦于以下问题:Python _get_replica_device_setter函数的具体用法?Python _get_replica_device_setter怎么用?Python _get_replica_device_setter使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了_get_replica_device_setter函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: testMutableHashTableIsLocal

 def testMutableHashTableIsLocal(self):
     with tf.device(estimator._get_replica_device_setter(tf.contrib.learn.RunConfig(num_ps_replicas=0))):
         default_val = tf.constant([-1, -1], tf.int64)
         table = tf.contrib.lookup.MutableHashTable(tf.string, tf.int64, default_val)
         input_string = tf.constant(["brain", "salad", "tank"])
         output = table.lookup(input_string)
     self.assertDeviceEqual("", table._table_ref.device)
     self.assertDeviceEqual("", output.device)
开发者ID:abhishekns,项目名称:tensorflow,代码行数:8,代码来源:estimator_test.py

示例2: testMutableHashTableIsLocal

 def testMutableHashTableIsLocal(self):
   with ops.device(
       estimator._get_replica_device_setter(run_config.RunConfig())):
     default_val = constant_op.constant([-1, -1], dtypes.int64)
     table = lookup.MutableHashTable(dtypes.string, dtypes.int64,
                                     default_val)
     input_string = constant_op.constant(['brain', 'salad', 'tank'])
     output = table.lookup(input_string)
   self.assertDeviceEqual('', table._table_ref.device)
   self.assertDeviceEqual('', output.device)
开发者ID:Immexxx,项目名称:tensorflow,代码行数:10,代码来源:estimator_test.py

示例3: testVariablesAreLocal

 def testVariablesAreLocal(self):
     with tf.device(estimator._get_replica_device_setter(tf.contrib.learn.RunConfig(num_ps_replicas=0))):
         v = tf.Variable([1, 2])
         w = tf.Variable([2, 1])
         a = v + w
     self.assertDeviceEqual("", v.device)
     self.assertDeviceEqual("", v.initializer.device)
     self.assertDeviceEqual("", w.device)
     self.assertDeviceEqual("", w.initializer.device)
     self.assertDeviceEqual("", a.device)
开发者ID:abhishekns,项目名称:tensorflow,代码行数:10,代码来源:estimator_test.py

示例4: testVariablesAreLocal

 def testVariablesAreLocal(self):
   with tf.device(estimator._get_replica_device_setter(num_ps_replicas=0)):
     v = tf.Variable([1, 2])
     w = tf.Variable([2, 1])
     a = v + w
   self.assertDeviceEqual('', v.device)
   self.assertDeviceEqual('', v.initializer.device)
   self.assertDeviceEqual('', w.device)
   self.assertDeviceEqual('', w.initializer.device)
   self.assertDeviceEqual('', a.device)
开发者ID:tongwang01,项目名称:tensorflow,代码行数:10,代码来源:estimator_test.py

示例5: testMutableHashTableIsLocal

 def testMutableHashTableIsLocal(self):
   with tf.device(estimator._get_replica_device_setter(num_ps_replicas=0)):
     default_val = tf.constant([-1, -1], tf.int64)
     table = tf.contrib.lookup.MutableHashTable(tf.string,
                                                tf.int64,
                                                default_val)
     input_string = tf.constant(['brain', 'salad', 'tank'])
     output = table.lookup(input_string)
   self.assertDeviceEqual('', table._table_ref.device)
   self.assertDeviceEqual('', output.device)
开发者ID:tongwang01,项目名称:tensorflow,代码行数:10,代码来源:estimator_test.py

示例6: testVariablesAreOnPs

 def testVariablesAreOnPs(self):
   with tf.device(estimator._get_replica_device_setter(num_ps_replicas=1)):
     v = tf.Variable([1, 2])
     w = tf.Variable([2, 1])
     a = v + w
   self.assertDeviceEqual('/job:ps/task:0', v.device)
   self.assertDeviceEqual('/job:ps/task:0', v.initializer.device)
   self.assertDeviceEqual('/job:ps/task:0', w.device)
   self.assertDeviceEqual('/job:ps/task:0', w.initializer.device)
   self.assertDeviceEqual('/job:worker', a.device)
开发者ID:tongwang01,项目名称:tensorflow,代码行数:10,代码来源:estimator_test.py

示例7: testVariablesAreLocal

 def testVariablesAreLocal(self):
   with ops.device(
       estimator._get_replica_device_setter(run_config.RunConfig())):
     v = variables_lib.Variable([1, 2])
     w = variables_lib.Variable([2, 1])
     a = v + w
   self.assertDeviceEqual('', v.device)
   self.assertDeviceEqual('', v.initializer.device)
   self.assertDeviceEqual('', w.device)
   self.assertDeviceEqual('', w.initializer.device)
   self.assertDeviceEqual('', a.device)
开发者ID:Immexxx,项目名称:tensorflow,代码行数:11,代码来源:estimator_test.py

示例8: testMutableHashTableIsOnPs

    def testMutableHashTableIsOnPs(self):
        tf_config = {"cluster": {tf.contrib.learn.TaskType.PS: ["fake_ps_0"]}}
        with tf.test.mock.patch.dict("os.environ", {"TF_CONFIG": json.dumps(tf_config)}):
            config = tf.contrib.learn.RunConfig()

        with tf.device(estimator._get_replica_device_setter(config)):
            default_val = tf.constant([-1, -1], tf.int64)
            table = tf.contrib.lookup.MutableHashTable(tf.string, tf.int64, default_val)
            input_string = tf.constant(["brain", "salad", "tank"])
            output = table.lookup(input_string)
        self.assertDeviceEqual("/job:ps/task:0", table._table_ref.device)
        self.assertDeviceEqual("/job:ps/task:0", output.device)
开发者ID:yuikns,项目名称:tensorflow,代码行数:12,代码来源:estimator_test.py

示例9: testTaskIsSetOnWorkerWhenJobNameIsSet

 def testTaskIsSetOnWorkerWhenJobNameIsSet(self):
   with tf.device(
       estimator._get_replica_device_setter(
           tf.contrib.learn.RunConfig(
               num_ps_replicas=1, job_name='worker', task=3))):
     v = tf.Variable([1, 2])
     w = tf.Variable([2, 1])
     a = v + w
   self.assertDeviceEqual('/job:ps/task:0', v.device)
   self.assertDeviceEqual('/job:ps/task:0', v.initializer.device)
   self.assertDeviceEqual('/job:ps/task:0', w.device)
   self.assertDeviceEqual('/job:ps/task:0', w.initializer.device)
   self.assertDeviceEqual('/job:worker/task:3', a.device)
开发者ID:imzhenyu,项目名称:tensorflow,代码行数:13,代码来源:estimator_test.py

示例10: testMutableHashTableIsOnPs

  def testMutableHashTableIsOnPs(self):
    tf_config = {'cluster': {run_config.TaskType.PS: ['fake_ps_0']}}
    with test.mock.patch.dict('os.environ',
                              {'TF_CONFIG': json.dumps(tf_config)}):
      config = run_config.RunConfig()

    with ops.device(estimator._get_replica_device_setter(config)):
      default_val = constant_op.constant([-1, -1], dtypes.int64)
      table = lookup.MutableHashTable(dtypes.string, dtypes.int64,
                                      default_val)
      input_string = constant_op.constant(['brain', 'salad', 'tank'])
      output = table.lookup(input_string)
    self.assertDeviceEqual('/job:ps/task:0', table._table_ref.device)
    self.assertDeviceEqual('/job:ps/task:0', output.device)
开发者ID:Immexxx,项目名称:tensorflow,代码行数:14,代码来源:estimator_test.py

示例11: testVariablesAreOnPs

    def testVariablesAreOnPs(self):
        tf_config = {"cluster": {tf.contrib.learn.TaskType.PS: ["fake_ps_0"]}}
        with tf.test.mock.patch.dict("os.environ", {"TF_CONFIG": json.dumps(tf_config)}):
            config = tf.contrib.learn.RunConfig()

        with tf.device(estimator._get_replica_device_setter(config)):
            v = tf.Variable([1, 2])
            w = tf.Variable([2, 1])
            a = v + w
        self.assertDeviceEqual("/job:ps/task:0", v.device)
        self.assertDeviceEqual("/job:ps/task:0", v.initializer.device)
        self.assertDeviceEqual("/job:ps/task:0", w.device)
        self.assertDeviceEqual("/job:ps/task:0", w.initializer.device)
        self.assertDeviceEqual("/job:worker", a.device)
开发者ID:yuikns,项目名称:tensorflow,代码行数:14,代码来源:estimator_test.py

示例12: testVariablesAreOnPs

  def testVariablesAreOnPs(self):
    tf_config = {'cluster': {run_config.TaskType.PS: ['fake_ps_0']}}
    with test.mock.patch.dict('os.environ',
                              {'TF_CONFIG': json.dumps(tf_config)}):
      config = run_config.RunConfig()

    with ops.device(estimator._get_replica_device_setter(config)):
      v = variables_lib.Variable([1, 2])
      w = variables_lib.Variable([2, 1])
      a = v + w
    self.assertDeviceEqual('/job:ps/task:0', v.device)
    self.assertDeviceEqual('/job:ps/task:0', v.initializer.device)
    self.assertDeviceEqual('/job:ps/task:0', w.device)
    self.assertDeviceEqual('/job:ps/task:0', w.initializer.device)
    self.assertDeviceEqual('/job:worker', a.device)
开发者ID:Immexxx,项目名称:tensorflow,代码行数:15,代码来源:estimator_test.py

示例13: testTaskIsSetOnWorkerWhenJobNameIsSet

    def testTaskIsSetOnWorkerWhenJobNameIsSet(self):
        tf_config = {
            "cluster": {tf.contrib.learn.TaskType.PS: ["fake_ps_0"]},
            "task": {"type": tf.contrib.learn.TaskType.WORKER, "index": 3},
        }
        with tf.test.mock.patch.dict("os.environ", {"TF_CONFIG": json.dumps(tf_config)}):
            config = tf.contrib.learn.RunConfig()

        with tf.device(estimator._get_replica_device_setter(config)):
            v = tf.Variable([1, 2])
            w = tf.Variable([2, 1])
            a = v + w
        self.assertDeviceEqual("/job:ps/task:0", v.device)
        self.assertDeviceEqual("/job:ps/task:0", v.initializer.device)
        self.assertDeviceEqual("/job:ps/task:0", w.device)
        self.assertDeviceEqual("/job:ps/task:0", w.initializer.device)
        self.assertDeviceEqual("/job:worker/task:3", a.device)
开发者ID:yuikns,项目名称:tensorflow,代码行数:17,代码来源:estimator_test.py

示例14: __init__

    def __init__(self, model_fn, model_dir=None, config=None, params=None):
        # Create a run configuration.
        if config is None:
            self._config = RunConfig()
            logging.info("Using default config.")
        else:
            if not isinstance(config, RunConfig):
                raise ValueError("config must be an instance of RunConfig, "
                                 "received {}.".format(config))
            self._config = config

        if(model_dir is not None) and (self._config.model_dir is not None):
            if model_dir != self._config.model_dir:
                # pylint: disable=g-doc-exception
                raise ValueError(
                    "model_dir are set both in constructor and RunConfig, but with "
                    "different values. In constructor: '{}', in RunConfig: "
                    "'{}' ".format(model_dir, self._config.model_dir))

        self._model_dir = model_dir or self._config.model_dir or generate_model_dir()
        if self._config.model_dir is None:
            self._config = self._config.replace(model_dir=self._model_dir)
        logging.info("Using config: {}".format(vars(self._config)))

        if self._config.session_config is None:
            self._session_config = config_pb2.ConfigProto(allow_soft_placement=True)
        else:
            self._session_config = self._config.session_config

        # Set device function depending if there are replicas or not.
        self._device_fn = _get_replica_device_setter(self._config)

        self._graph = None

        self._verify_model_fn_args(model_fn, params)

        self._model_fn = model_fn
        self._params = params or {}
开发者ID:AlexMikhalev,项目名称:polyaxon,代码行数:38,代码来源:estimator.py

示例15: testTaskIsSetOnWorkerWhenJobNameIsSet

  def testTaskIsSetOnWorkerWhenJobNameIsSet(self):
    tf_config = {
        'cluster': {
            run_config.TaskType.PS: ['fake_ps_0']
        },
        'task': {
            'type': run_config.TaskType.WORKER,
            'index': 3
        }
    }
    with test.mock.patch.dict('os.environ',
                              {'TF_CONFIG': json.dumps(tf_config)}):
      config = run_config.RunConfig()

    with ops.device(estimator._get_replica_device_setter(config)):
      v = variables_lib.Variable([1, 2])
      w = variables_lib.Variable([2, 1])
      a = v + w
    self.assertDeviceEqual('/job:ps/task:0', v.device)
    self.assertDeviceEqual('/job:ps/task:0', v.initializer.device)
    self.assertDeviceEqual('/job:ps/task:0', w.device)
    self.assertDeviceEqual('/job:ps/task:0', w.initializer.device)
    self.assertDeviceEqual('/job:worker/task:3', a.device)
开发者ID:Immexxx,项目名称:tensorflow,代码行数:23,代码来源:estimator_test.py


注:本文中的tensorflow.contrib.learn.python.learn.estimators.estimator._get_replica_device_setter函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。