codecamp

tf.scatter_update函数:将稀疏更新应用于变量引用

tf.scatter_update 函数

scatter_update(
    ref,
    indices,
    updates,
    use_locking=True,
    name=None
)

请参阅指南:变量>稀疏变量更新

将稀疏更新应用于变量引用.

此操作计算如下:

# Scalar indices
ref[indices, ...] = updates[...]

# Vector indices (for each i)
ref[indices[i], ...] = updates[i, ...]

# High rank indices (for each i, ..., j)
ref[indices[i, ..., j], ...] = updates[i, ..., j, ...]

此操作在更新完成后输出 ref.这样可以更容易地链接到需要使用重置值的操作.

如果 ref 中的值要更新多次,由于indices中有重复的条目,则每个值的更新发生的顺序是未定义的.

需要:updates.shape = indices.shape + ref.shape[1:].

TensorFlow函数

函数参数

  • ref:一个可变的Tensor;应该来自一个Variable节点.
  • indices:一个Tensor;必须是以下类型之一:int32,int64;进入ref的第一维度的一个索引的张量.
  • updates:一个Tensor.必须与ref具有相同的类型.存储在ref中的更新值的张量.
  • use_locking:可选bool,默认为True;如果为True,则赋值将受锁定的保护;否则行为是不确定的,但可能表现出较少的争用.
  • name:操作的名称(可选).

函数返回值

和ref一样;作为在更新完成后想要使用更新值的操作的便利返回.

TensorFlow函数:tf.scatter_sub
tf.segment_max函数:计算一个张量的最大沿段
温馨提示
下载编程狮App,免费阅读超1000+编程语言教程
取消
确定
目录

TensorFlow 函数介绍

TensorFlow 函数模块:tf

TensorFlow的image模块

TensorFlow使用之tf.io

TensorFlow使用之tf.keras

TensorFlow函数教程:tf.keras.applications

TensorFlow函数教程:tf.keras.backend

TensorFlow使用之tf.metrics

TensorFlow使用之tf.nn

TensorFlow使用之tf.python_io

TensorFlow 功能函数

关闭

MIP.setData({ 'pageTheme' : getCookie('pageTheme') || {'day':true, 'night':false}, 'pageFontSize' : getCookie('pageFontSize') || 20 }); MIP.watch('pageTheme', function(newValue){ setCookie('pageTheme', JSON.stringify(newValue)) }); MIP.watch('pageFontSize', function(newValue){ setCookie('pageFontSize', newValue) }); function setCookie(name, value){ var days = 1; var exp = new Date(); exp.setTime(exp.getTime() + days*24*60*60*1000); document.cookie = name + '=' + value + ';expires=' + exp.toUTCString(); } function getCookie(name){ var reg = new RegExp('(^| )' + name + '=([^;]*)(;|$)'); return document.cookie.match(reg) ? JSON.parse(document.cookie.match(reg)[2]) : null; }