TensorFlow函数:tf.sparse_reduce_max

2018-03-02 10:35 更新

tf.sparse_reduce_max 函数

sparse_reduce_max(
    sp_input,
    axis=None,
    keep_dims=False,
    reduction_axes=None
)

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

计算 SparseTensor 各个维度上元素的最大值.

这个操作需要一个 SparseTensor,并且是 tf.reduce_max() 的稀疏对应.特别是,这个操作也返回一个稠密的 Tensor,而不是一个稀疏的.

沿着在 reduction_axes 中给定的维度减少 sp_input.除非 keep_dims 为真,否则 reduction_axes 中的每个条目的张量的秩都减少了1.如果 keep_dims 属实,减小的维度将保留为1.

如果 reduction_axes 没有条目,则会减少所有维度,并返回具有单个元素的张量.另外,坐标轴可以是负值,类似于 Python 中的索引规则.

例如:

# 'x' represents [[1, ?, 2]
#                 [?, 3, ?]]
# where ? is implicitly-zero.
tf.sparse_reduce_max(x) ==> 3
tf.sparse_reduce_max(x, 0) ==> [1, 3, 2]
tf.sparse_reduce_max(x, 1) ==> [2, 3]  # Can also use -1 as the axis.
tf.sparse_reduce_max(x, 1, keep_dims=True) ==> [[2], [3]]
tf.sparse_reduce_max(x, [0, 1]) ==> 3

函数参数:

  • sp_input:将减少的 SparseTensor,应该为数字类型.
  • axis:要减少的维度,列表或标量.如果为 None(默认),则减少所有维度.
  • keep_dims:如果为 true,则保留长度为1的减少维度.
  • reduction_axes:轴的弃用名称.

函数返回值:

tf.sparse_reduce_max 函数返回减少的张量.

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

扫描二维码

下载编程狮App

公众号
微信公众号

编程狮公众号