本文整理匯總了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)
示例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()
示例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()
示例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)
示例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)
示例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()
示例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()
示例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()
示例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()
示例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()
示例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)
示例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]])
示例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()
示例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()
示例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()