TensorFlow函数:tf.unique

2018-04-12 10:10 更新

tf.unique函数

tf.unique(
    x,
    out_idx=tf.int32,
    name=None
)

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

请参阅指南:数学函数>序列比较和索引

在一维张量中找到唯一的元素.

该操作返回一个张量 y,该张量包含所有发生在 x 中的所有唯一的元素 x,它们按照相同的顺序排序.此操作还会返回一个与 x 具有相同大小的张量 idx,包含唯一的输出 y 中 x 的每个值的索引.也就是说:

y[idx[i]] = x[i] for i in [0, 1,...,rank(x) - 1]

例如:

# tensor 'x' is [1, 1, 2, 4, 4, 4, 7, 8, 8]
y, idx = unique(x)
y ==> [1, 2, 4, 7, 8]
idx ==> [0, 0, 1, 2, 2, 2, 3, 4, 4]

函数参数:

  • x:一个 Tensor,是1维的.
  • out_idx:可选 tf.DType 来自:tf.int32, tf.int64,默认为 tf.int32.
  • name:操作的名称(可选).

函数返回值:

Tensor对象(y, idx)的元型态组.

  • y:一个 Tensor,与 x 类型相同.
  • idx:一个 out_idx 类型的 Tensor.
以上内容是否对您有帮助:
在线笔记
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