当前位置: 首页>>代码示例>>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;未经允许,请勿转载。