函数:tf.gather_ndgather_nd(

params,

indices,

name=None

)

将参数中的切片收集到由索引指定的形状的张量中.

索引(indices)是一个 k 维整数张量,最好作为一个 (k-1) 维的索引(indices)张量的参数,其中每个元素定义了一个参数切片:output[i_0, ..., i_{K-2}] = params[indices[i0, ..., i_{K-2}]]

然而在 tf.gather 函数中,将片段定义为参数的第一维度;在 tf.gather_nd 中,索引将切片定义为参数的第一个 n 维度.其中: N = indices.shape[-1]

索引的最后一个维度最多可以是参数的秩:indices.shape[-1] <= params.rank

索引的最后一个维度对应于元素 (如果 indices.shape[-1] == params.rank) 或切片 (如果 indices.shape[-1] < params.rank) 沿参数 dices.shape[-1] 中的维度.输出张量具有形状:indices.shape[:-1] + params.shape[indices.shape[-1]:]

下面是一些例子:

简单的索引到矩阵:indices = [[0, 0], [1, 1]]

params = [['a', 'b'], ['c', 'd']]

output = ['a', 'd']

将索引分为矩阵:indices = [[1], [0]]

params = [['a', 'b'], ['c', 'd']]

output = [['c', 'd'], ['a', 'b']]

索引到一个3-tensor:indices = [[1]]

params = [[['a0', 'b0'], ['c0', 'd0']],

[['a1', 'b1'], ['c1', 'd1']]]

output = [[['a1', 'b1'], ['c1', 'd1']]]

indices = [[0, 1], [1, 0]]

params = [[['a0', 'b0'], ['c0', 'd0']],

[['a1', 'b1'], ['c1', 'd1']]]

output = [['c0', 'd0'], ['a1', 'b1']]

indices = [[0, 0, 1], [1, 0, 1]]

params = [[['a0', 'b0'], ['c0', 'd0']],

[['a1', 'b1'], ['c1', 'd1']]]

output = ['b0', 'b1']

分批索引到矩阵中:indices = [[[0, 0]], [[0, 1]]]

params = [['a', 'b'], ['c', 'd']]

output = [['a'], ['b']]

分批切片索引成矩阵:indices = [[[1]], [[0]]]

params = [['a', 'b'], ['c', 'd']]

output = [[['c', 'd']], [['a', 'b']]]

分批索引到一个 3-tensor:indices = [[[1]], [[0]]]

params = [[['a0', 'b0'], ['c0', 'd0']],

[['a1', 'b1'], ['c1', 'd1']]]

output = [[[['a1', 'b1'], ['c1', 'd1']]],

[[['a0', 'b0'], ['c0', 'd0']]]]

indices = [[[0, 1], [1, 0]], [[0, 0], [1, 1]]]

params = [[['a0', 'b0'], ['c0', 'd0']],

[['a1', 'b1'], ['c1', 'd1']]]

output = [[['c0', 'd0'], ['a1', 'b1']],

[['a0', 'b0'], ['c1', 'd1']]]

indices = [[[0, 0, 1], [1, 0, 1]], [[0, 1, 1], [1, 1, 0]]]

params = [[['a0', 'b0'], ['c0', 'd0']],

[['a1', 'b1'], ['c1', 'd1']]]

output = [['b0', 'b1'], ['d0', 'c1']]

参数:

params:张量.这个张量是用来收集数值的.

indices:张量.必须是以下类型之一:int32,int64;索引张量.

name:操作的名称(可选).

返回值:

该函数返回一个张量.与参数具有相同的类型.参数值从索引所给定的索引中收集,并且具有形状:indices.shape[:-1] + params.shape[indices.shape[-1]:]

c语言gather函数,TensorFlow函数:tf.gather_nd相关推荐

  1. 【python】tensorflow框架中的tf.gather_nd()函数对应的 pytorch框架的gather_nd()函数

    tf.gather_nd 函数对应的pytorch函数 1. 简单介绍 2. 步入正题 2.1 tensorflow tf.gather_nd() 2.2 pytorch框架手动实现gather_nd ...

  2. tf.gather_nd函数

    函数原型 tf.gather_nd(params, indices, batch_dims=0, name=None ) 函数说明 从指定的张量中根据索引来进行切片.注意tf.gather函数和tf. ...

  3. Tensorflow利用函数修饰符@tf.custom_gradients自定义函数梯度

    Tensorflow学习笔记(1) 利用函数修饰符@tf.custom_gradients自定义函数梯度_寂乐居士的博客-CSDN博客_tf.custom_gradient python中的修饰符以及 ...

  4. Tensorflow:tf.contrib.rnn.DropoutWrapper函数(谷歌已经为Dropout申请了专利!)、MultiRNNCell函数的解读与理解

    Tensorflow:tf.contrib.rnn.DropoutWrapper函数(谷歌已经为Dropout申请了专利!).MultiRNNCell函数的解读与理解 目录 1.tf.contrib. ...

  5. 【TensorFlow】tf.nn.softmax_cross_entropy_with_logits 函数:求交叉熵损失

    [TensorFlow]tf.nn.softmax_cross_entropy_with_logits的用法_xf__mao的博客-CSDN博客 https://blog.csdn.net/mao_x ...

  6. 【tensorflow】tf.layers.conv1d函数解析(一维卷积)

    TensorFlow函数:tf.layers.Conv1D_w3cschool https://www.w3cschool.cn/tensorflow_python/tensorflow_python ...

  7. tensorflow 之 tf.tile()函数

    这个函数是用来进行tensor维度扩展的,我们来看一下是怎么用的. 函数定义:tf.tile(input,multiples,name = None) input:表示输入tensor multipl ...

  8. 【TensorFlow】TensorFlow函数精讲之tf.nn.max_pool()和tf.nn.avg_pool()

    tf.nn.max_pool()和tf.nn.avg_pool()是TensorFlow中实现最大池化和平均池化的函数,在卷积神经网络中比较核心的方法. 有些和卷积很相似,可以参考TensorFlow ...

  9. 【TensorFlow】TensorFlow函数精讲之tf.nn.conv2d()

    博客之星评选,谢谢您的支持!微信.qq五连击投票(无需关注.无需登录) 人工智能博士(投票链接):http://m234140.nofollow.ax.mvote.cn/opage/4fddfa73- ...

最新文章

  1. 12、OpenCV实现图像的空间滤波——图像平滑
  2. seaborn将图例放置在图像外部并使用move_legend函数将图例(legend)放置在图像的顶部top(多组图例)
  3. 方向对了?MIT新研究:GPT-3和人类大脑处理语言的方式惊人相似
  4. 19-7-15学习笔记
  5. Netgear wndr3700v2 路由器刷OpenWrt打造全能服务器(五)SVN服务
  6. windows环境下ELK平台搭建
  7. Java中9大内置基本数据类型Class实例和数组的Class实例
  8. 网络货运平台要智能,安全的数据底座少不了
  9. 雷军:技术立业是小米血液里最重要的东西
  10. 蓝桥杯 ALGO-21算法训练 装箱问题(动态规划,01背包)
  11. 使用getopt_long解析程序长选项参数
  12. 计算机基础知识常用口诀,计算机基础知识(初中级教程)-20210712024844.pdf-原创力文档...
  13. openlayers2渐变色渲染
  14. 使用java 实现 word 转换成图片
  15. WinTel联盟发展史
  16. 达梦(DM)数据库常见问题详解
  17. c语言fprintf 数组,C语言fprintf()函数:格式化输出到一个流中
  18. NMOS和PMOS的电路符号记忆方法
  19. 计算机网络修复提示DNS服务器,dns被劫持或提示配置错误,该怎么解决
  20. 有人知道这是错哪了么?

热门文章

  1. 伍六七带你学算法 入门篇-链表的中间节点
  2. vb中可视对象的操作
  3. 『PyTorch』第十一弹_torch.optim优化器 每层定制参数
  4. Druid数据库连接池超时问题com.alibaba.druid.pool.GetConnectionTimeoutException: wait millis 1000, active 10
  5. Android Studio中RecycerView依赖库加载问题
  6. MinkowskiBroadcast广播
  7. ASIC设计-终极指南
  8. 车道线检测算法经典编程
  9. 2021年大数据Hive(一):​​​​​​​Hive基本概念
  10. Django 模板4.1