TensorFlow张量变换函数:tf.gather

2018-12-24 14:48 更新
函数:tf.gather
gather(
    params,
    indices,
    validate_indices=None,
    name=None,
    axis=0
)

定义在:tensorflow/python/ops/array_ops.py.

参见指南:张量变换>切片和连接

根据索引从参数轴上收集切片.
索引必须是任何维度的整数张量 (通常为 0-D 或 1-D).生成输出张量该张量的形状为:params.shape[:axis] + indices.shape + params.shape[axis + 1:]

使用示例如下:

# Scalar indices (output is rank(params) - 1).
output[a_0, ..., a_n, b_0, ..., b_n] =
  params[a_0, ..., a_n, indices, b_0, ..., b_n]

# Vector indices (output is rank(params)).
output[a_0, ..., a_n, i, b_0, ..., b_n] =
  params[a_0, ..., a_n, indices[i], b_0, ..., b_n]

# Higher rank indices (output is rank(params) + rank(indices) - 1).
output[a_0, ..., a_n, i, ..., j, b_0, ... b_n] =
  params[a_0, ..., a_n, indices[i, ..., j], b_0, ..., b_n]

TensorFlow张量变换函数:tf.gather

参数:

  • params:一个张量.这个张量是用来收集数值的.该张量的秩必须至少是 axis + 1.
  • indices:一个张量.必须是以下类型之一:int32,int64.索引张量必须在 [0, params.shape[axis]) 范围内.
  • axis:一个张量.必须是以下类型之一:int32,int64.在参数轴从中收集索引.默认为第一个维度.支持负索引.
  • name:操作的名称(可选).

返回值:

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

以上内容是否对您有帮助:
在线笔记
App下载
App下载

扫描二维码

下载编程狮App

公众号
微信公众号

编程狮公众号

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy