• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Python resource_variable_ops.resource_scatter_add函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: testScatterAdd

 def testScatterAdd(self):
     with self.test_session():
         handle = resource_variable_ops.var_handle_op(dtype=dtypes.int32, shape=[1, 1])
         resource_variable_ops.assign_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:kdavis-mozilla,项目名称:tensorflow,代码行数:9,代码来源:resource_variable_ops_test.py


示例2: _resource_apply_sparse_duplicate_indices

 def _resource_apply_sparse_duplicate_indices(self, grad, var, indices, state):
   if self._use_momentum:
     return super(SGD, self)._resource_apply_sparse_duplicate_indices(
         grad, var, indices, state)
   else:
     lr = state.get_hyper("learning_rate", grad.dtype.base_dtype)
     return resource_variable_ops.resource_scatter_add(var.handle, indices,
                                                       -grad * lr)
开发者ID:ThunderQi,项目名称:tensorflow,代码行数:8,代码来源:sgd.py


示例3: _resource_apply_sparse_duplicate_indices

 def _resource_apply_sparse_duplicate_indices(self, grad, var, indices):
   if self._momentum:
     return super(SGD, self)._resource_apply_sparse_duplicate_indices(
         grad, var, indices)
   else:
     return resource_variable_ops.resource_scatter_add(
         var.handle, indices, -grad * math_ops.cast(
             self._get_hyper("learning_rate"), grad.dtype.base_dtype))
开发者ID:JonathanRaiman,项目名称:tensorflow,代码行数:8,代码来源:gradient_descent.py


示例4: testScatterAdd

 def testScatterAdd(self):
   handle = resource_variable_ops.var_handle_op(
       dtype=dtypes.int32, shape=[1, 1])
   self.evaluate(resource_variable_ops.assign_variable_op(
       handle, constant_op.constant([[1]], dtype=dtypes.int32)))
   self.evaluate(resource_variable_ops.resource_scatter_add(
       handle, [0], constant_op.constant([[2]], dtype=dtypes.int32)))
   read = resource_variable_ops.read_variable_op(handle, dtype=dtypes.int32)
   self.assertEqual(self.evaluate(read), [[3]])
开发者ID:AbhinavJain13,项目名称:tensorflow,代码行数:9,代码来源:resource_variable_ops_test.py


示例5: _resource_apply_sparse_duplicate_indices

 def _resource_apply_sparse_duplicate_indices(self, grad, var, indices):
   if self._momentum:
     return super(SGD, self)._resource_apply_sparse_duplicate_indices(
         grad, var, indices)
   else:
     var_dtype = var.dtype.base_dtype
     lr_t = self._decayed_lr(var_dtype)
     return resource_variable_ops.resource_scatter_add(var.handle, indices,
                                                       -grad * lr_t)
开发者ID:Wajih-O,项目名称:tensorflow,代码行数:9,代码来源:gradient_descent.py


示例6: _assign_sub

 def _assign_sub(self, ref, updates, indices=None):
   if indices is not None:
     if isinstance(ref, tf.Variable):
       return tf.scatter_sub(ref, indices, updates, use_locking=self._use_locking)
     elif isinstance(ref, resource_variable_ops.ResourceVariable):
       with tf.control_dependencies([resource_variable_ops.resource_scatter_add(ref.handle, indices, -updates)]):
         return ref.value()
     else:
       raise TypeError("did not expect type %r" % type(ref))
   else:
     return tf.assign_sub(ref, updates, use_locking=self._use_locking)
开发者ID:rwth-i6,项目名称:returnn,代码行数:11,代码来源:TFUpdater.py


示例7: testScatterAddScalar

 def testScatterAddScalar(self):
   with self.test_session() as sess, self.test_scope():
     handle = resource_variable_ops.var_handle_op(
         dtype=dtypes.int32, shape=[1, 1])
     sess.run(
         resource_variable_ops.assign_variable_op(
             handle, constant_op.constant([[1]], dtype=dtypes.int32)))
     sess.run(
         resource_variable_ops.resource_scatter_add(
             handle, [0], constant_op.constant(2, dtype=dtypes.int32)))
     read = resource_variable_ops.read_variable_op(handle, dtype=dtypes.int32)
     self.assertEqual(self.evaluate(read), [[3]])
开发者ID:Albert-Z-Guo,项目名称:tensorflow,代码行数:12,代码来源:variable_ops_test.py


示例8: _resource_scatter_add

 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:terrytangyuan,项目名称:tensorflow,代码行数:4,代码来源:optimizer_v2.py


示例9: _resource_apply_sparse_duplicate_indices

 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:AndrewTwinz,项目名称:tensorflow,代码行数:3,代码来源:gradient_descent.py


示例10: _resource_scatter_add

 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:Ajaycs99,项目名称:tensorflow,代码行数:6,代码来源:weight_decay_optimizers.py


示例11: _resource_apply_sparse_duplicate_indices

 def _resource_apply_sparse_duplicate_indices(
     self, grad, handle, indices, state):
   lr = state.get_hyper("learning_rate", grad.dtype.base_dtype)
   return resource_variable_ops.resource_scatter_add(
       handle.handle, indices, -grad * lr)
开发者ID:AnishShah,项目名称:tensorflow,代码行数:5,代码来源:gradient_descent.py



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap