TensorFlow函數(shù):tf.sparse_reduce_max

2018-03-02 10:35 更新

tf.sparse_reduce_max 函數(shù)

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

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

計(jì)算 SparseTensor 各個(gè)維度上元素的最大值.

這個(gè)操作需要一個(gè) SparseTensor,并且是 tf.reduce_max() 的稀疏對(duì)應(yīng).特別是,這個(gè)操作也返回一個(gè)稠密的 Tensor,而不是一個(gè)稀疏的.

沿著在 reduction_axes 中給定的維度減少 sp_input.除非 keep_dims 為真,否則 reduction_axes 中的每個(gè)條目的張量的秩都減少了1.如果 keep_dims 屬實(shí),減小的維度將保留為1.

如果 reduction_axes 沒(méi)有條目,則會(huì)減少所有維度,并返回具有單個(gè)元素的張量.另外,坐標(biāo)軸可以是負(fù)值,類似于 Python 中的索引規(guī)則.

例如:

# '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

函數(shù)參數(shù):

  • sp_input:將減少的 SparseTensor,應(yīng)該為數(shù)字類型.
  • axis:要減少的維度,列表或標(biāo)量.如果為 None(默認(rèn)),則減少所有維度.
  • keep_dims:如果為 true,則保留長(zhǎng)度為1的減少維度.
  • reduction_axes:軸的棄用名稱.

函數(shù)返回值:

tf.sparse_reduce_max 函數(shù)返回減少的張量.

以上內(nèi)容是否對(duì)您有幫助:
在線筆記
App下載
App下載

掃描二維碼

下載編程獅App

公眾號(hào)
微信公眾號(hào)

編程獅公眾號(hào)