當前位置: 首頁>>代碼示例>>Python>>正文


Python resource_variable_ops.resource_scatter_add方法代碼示例

本文整理匯總了Python中tensorflow.python.ops.resource_variable_ops.resource_scatter_add方法的典型用法代碼示例。如果您正苦於以下問題:Python resource_variable_ops.resource_scatter_add方法的具體用法?Python resource_variable_ops.resource_scatter_add怎麽用?Python resource_variable_ops.resource_scatter_add使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在tensorflow.python.ops.resource_variable_ops的用法示例。


在下文中一共展示了resource_variable_ops.resource_scatter_add方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: _resource_apply_sparse

# 需要導入模塊: from tensorflow.python.ops import resource_variable_ops [as 別名]
# 或者: from tensorflow.python.ops.resource_variable_ops import resource_scatter_add [as 別名]
def _resource_apply_sparse(self, grad, var, indices):
        momentum_buffer = self.get_slot(var, "momentum")
        learning_rate = math_ops.cast(self._learning_rate_tensor, var.dtype.base_dtype)
        momentum = math_ops.cast(self._momentum_tensor, var.dtype.base_dtype)
        nu = math_ops.cast(self._nu_tensor, var.dtype.base_dtype)

        momentum_op = training_ops.resource_sparse_apply_momentum(
            var.handle,
            momentum_buffer.handle,
            nu * (1.0 - momentum) * learning_rate,
            grad,
            indices,
            momentum,
            use_locking=self._use_locking,
            use_nesterov=False,
        )

        with ops.control_dependencies([momentum_op]):
            delta = (nu - 1.0) * learning_rate * grad
            gd_op = resource_variable_ops.resource_scatter_add(var.handle, indices, delta)

        return control_flow_ops.group(momentum_op, gd_op) 
開發者ID:facebookresearch,項目名稱:qhoptim,代碼行數:24,代碼來源:qhm.py

示例2: _resource_scatter_add

# 需要導入模塊: from tensorflow.python.ops import resource_variable_ops [as 別名]
# 或者: from tensorflow.python.ops.resource_variable_ops import resource_scatter_add [as 別名]
def _resource_scatter_add(self, x, i, v):
        with ops.control_dependencies(
                [resource_variable_ops.resource_scatter_add(x.handle, i, v)]):
            return x.value() 
開發者ID:imsb-uke,項目名稱:scGAN,代碼行數:6,代碼來源:AMSGrad.py

示例3: _resource_scatter_add

# 需要導入模塊: from tensorflow.python.ops import resource_variable_ops [as 別名]
# 或者: from tensorflow.python.ops.resource_variable_ops import resource_scatter_add [as 別名]
def _resource_scatter_add(self, x, i, v):
    with ops.control_dependencies(
        [resource_variable_ops.resource_scatter_add(
            x.handle, i, v)]):
      return x.value() 
開發者ID:ryfeus,項目名稱:lambda-packs,代碼行數:7,代碼來源:adam.py

示例4: _resource_apply_sparse_duplicate_indices

# 需要導入模塊: from tensorflow.python.ops import resource_variable_ops [as 別名]
# 或者: from tensorflow.python.ops.resource_variable_ops import resource_scatter_add [as 別名]
def _resource_apply_sparse_duplicate_indices(self, grad, handle, indices):
    return resource_variable_ops.resource_scatter_add(
        handle.handle, indices, -grad * self._learning_rate) 
開發者ID:ryfeus,項目名稱:lambda-packs,代碼行數:5,代碼來源:gradient_descent.py

示例5: _resource_apply_sparse

# 需要導入模塊: from tensorflow.python.ops import resource_variable_ops [as 別名]
# 或者: from tensorflow.python.ops.resource_variable_ops import resource_scatter_add [as 別名]
def _resource_apply_sparse(self, grad, handle, indices):
    return resource_variable_ops.resource_scatter_add(
        handle, indices, -grad * self._learning_rate) 
開發者ID:abhisuri97,項目名稱:auto-alt-text-lambda-api,代碼行數:5,代碼來源:gradient_descent.py

示例6: _resource_scatter_add

# 需要導入模塊: from tensorflow.python.ops import resource_variable_ops [as 別名]
# 或者: from tensorflow.python.ops.resource_variable_ops import resource_scatter_add [as 別名]
def _resource_scatter_add(self, x, i, v):
    with tf.control_dependencies(
        [resource_variable_ops.resource_scatter_add(x.handle, i, v)]):
      return x.value() 
開發者ID:tensorflow,項目名稱:tensor2tensor,代碼行數:6,代碼來源:multistep_with_adamoptimizer.py

示例7: _resource_scatter_add

# 需要導入模塊: from tensorflow.python.ops import resource_variable_ops [as 別名]
# 或者: from tensorflow.python.ops.resource_variable_ops import resource_scatter_add [as 別名]
def _resource_scatter_add(self, x, i, v):
		with ops.control_dependencies([resource_variable_ops.resource_scatter_add(x.handle, i, v)]):
			return x.value() 
開發者ID:yyht,項目名稱:BERT,代碼行數:5,代碼來源:lamb_utils.py

示例8: _resource_scatter_add

# 需要導入模塊: from tensorflow.python.ops import resource_variable_ops [as 別名]
# 或者: from tensorflow.python.ops.resource_variable_ops import resource_scatter_add [as 別名]
def _resource_scatter_add(self, x, i, v):
        with ops.control_dependencies([resource_variable_ops.resource_scatter_add(x.handle, i, v)]):
            return x.value() 
開發者ID:yyht,項目名稱:BERT,代碼行數:5,代碼來源:radam_utils.py

示例9: _resource_scatter_add

# 需要導入模塊: from tensorflow.python.ops import resource_variable_ops [as 別名]
# 或者: from tensorflow.python.ops.resource_variable_ops import resource_scatter_add [as 別名]
def _resource_scatter_add(self, x, i, v, _=None):
    # last argument allows for one overflow argument, to have the same function
    # signature as state_ops.scatter_add
    with ops.control_dependencies(
        [resource_variable_ops.resource_scatter_add(x.handle, i, v)]):
      return x.value() 
開發者ID:yyht,項目名稱:BERT,代碼行數:8,代碼來源:adam_weight_decay_exclude_utils.py

示例10: _resource_scatter_add

# 需要導入模塊: from tensorflow.python.ops import resource_variable_ops [as 別名]
# 或者: from tensorflow.python.ops.resource_variable_ops import resource_scatter_add [as 別名]
def _resource_scatter_add(self, x, i, v, _=None):
		# last argument allows for one overflow argument, to have the same function
		# signature as state_ops.scatter_add
		with ops.control_dependencies(
				[resource_variable_ops.resource_scatter_add(x.handle, i, v)]):
			return x.value() 
開發者ID:yyht,項目名稱:BERT,代碼行數:8,代碼來源:adam_weight_decay_utils.py

示例11: _resource_apply_sparse

# 需要導入模塊: from tensorflow.python.ops import resource_variable_ops [as 別名]
# 或者: from tensorflow.python.ops.resource_variable_ops import resource_scatter_add [as 別名]
def _resource_apply_sparse(self, grad, var, indices):
        def resource_scatter_add(x, i, v):
            with ops.control_dependencies([resource_variable_ops.resource_scatter_add(x.handle, i, v)]):
                return x.value()

        return self._apply_sparse_shared(grad, var, indices, resource_scatter_add) 
開發者ID:facebookresearch,項目名稱:qhoptim,代碼行數:8,代碼來源:qhadam.py

示例12: testScatterAdd

# 需要導入模塊: from tensorflow.python.ops import resource_variable_ops [as 別名]
# 或者: from tensorflow.python.ops.resource_variable_ops import resource_scatter_add [as 別名]
def testScatterAdd(self):
    with self.test_session():
      handle = resource_variable_ops.var_handle_op(
          dtype=dtypes.int32, shape=[1, 1])
      resource_variable_ops.create_variable_op(
          handle, constant_op.constant([[1]], dtype=dtypes.int32)).run()
      resource_variable_ops.resource_scatter_add(
          handle, [0], constant_op.constant([[2]], dtype=dtypes.int32)).run()
      read = resource_variable_ops.read_variable_op(handle, dtype=dtypes.int32)
      self.assertEqual(read.eval(), [[3]]) 
開發者ID:tobegit3hub,項目名稱:deep_image_model,代碼行數:12,代碼來源:resource_variable_ops_test.py

示例13: _resource_scatter_add

# 需要導入模塊: from tensorflow.python.ops import resource_variable_ops [as 別名]
# 或者: from tensorflow.python.ops.resource_variable_ops import resource_scatter_add [as 別名]
def _resource_scatter_add(self, x, i, v):
        with ops.control_dependencies(
                [resource_variable_ops.resource_scatter_add(
                    x.handle, i, v)]):
            return x.value() 
開發者ID:HaoyuHu,項目名稱:bert-multi-gpu,代碼行數:7,代碼來源:custom_optimization.py

示例14: _resource_scatter_add

# 需要導入模塊: from tensorflow.python.ops import resource_variable_ops [as 別名]
# 或者: from tensorflow.python.ops.resource_variable_ops import resource_scatter_add [as 別名]
def _resource_scatter_add(self, x, i, v):
        with ops.control_dependencies(
                [resource_variable_ops.resource_scatter_add(x, i, v)]):
            return x.value() 
開發者ID:kerlomz,項目名稱:captcha_trainer,代碼行數:6,代碼來源:AdaBound.py

示例15: _resource_scatter_add

# 需要導入模塊: from tensorflow.python.ops import resource_variable_ops [as 別名]
# 或者: from tensorflow.python.ops.resource_variable_ops import resource_scatter_add [as 別名]
def _resource_scatter_add(self, x, i, v):
        with ops.control_dependencies(
            [resource_variable_ops.resource_scatter_add(
                x.handle, i, v)]):
            return x.value() 
開發者ID:JayYip,項目名稱:bert-multitask-learning,代碼行數:7,代碼來源:optimizer.py


注:本文中的tensorflow.python.ops.resource_variable_ops.resource_scatter_add方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。