没有合适的资源?快使用搜索试试~ 我知道了~
首页浅谈tensorflow中张量的提取值和赋值
tf.gather和gather_nd从params中收集数值,tf.scatter_nd 和 tf.scatter_nd_update用updates更新某一张量。严格上说,tf.gather_nd和tf.scatter_nd_update互为逆操作。 已知数值的位置,从张量中提取数值:tf.gather, tf.gather_nd tf.gather indices每个元素(标量)是params某个axis的索引,tf.gather_nd 中indices最后一个阶对应于索引值。 tf.gather函数 函数原型 gather( params, indices, validate_
资源详情
资源评论
资源推荐

浅谈浅谈tensorflow中张量的提取值和赋值中张量的提取值和赋值
tf.gather和gather_nd从params中收集数值,tf.scatter_nd 和 tf.scatter_nd_update用updates更新某一张量。严格上
说,tf.gather_nd和tf.scatter_nd_update互为逆操作。
已知数值的位置,从张量中提取数值:已知数值的位置,从张量中提取数值:tf.gather, tf.gather_nd
tf.gather indices每个元素(标量)是params某个axis的索引,tf.gather_nd 中indices最后一个阶对应于索引值。
tf.gather函数
函数原型函数原型
gather(
params,
indices,
validate_indices=None,
name=None,
axis=0
)
params是要查找的张量,indices是要查找值的索引(int32或int64),axis是查找轴,name是操作名。
如果indices是标量
如果indices是向量
如果indices是高阶张量
返回值:
该函数返回值类型与params相同,具体值是从params中收集过来的,形状为
tf.gather_nd函数
函数原型函数原型
gather_nd(
params,
indices,
name=None
)
indices是K阶张量,包含K-1阶的索引值。它最后一阶是索引,最后一阶维度必须小于等于params的秩。indices最后一阶的维
数等于params的秩时,我们得到params的某些元素;indices最后一阶的维数小于params的秩时,我们得到params的切片。
输出张量的形状由indices的K-1阶和params索引到的形状拼接而成,如下面
indices.shape[:-1] + params.shape[indices.shape[-1]:]
参数:参数:
params:被收集的张量。
indices:索引张量。必须是以下类型之一:int32,int64。


















安全验证
文档复制为VIP权益,开通VIP直接复制

评论0