tf.math.argmax
| Просмотреть исходный код на GitHub |
Возвращает индекс с наибольшим значением по осям тензора.
tf.math.argmax(
input,
axis=None,
output_type=tf.dtypes.int64,
name=None
)
В случае идентичности возвращает наименьший индекс.
Например:
A = tf.constant([2, 20, 30, 3, 6])
tf.math.argmax(A) # A[2] is maximum in tensor A
<tf.Tensor: shape=(), dtype=int64, numpy=2>
B = tf.constant([[2, 20, 30, 3, 6], [3, 11, 16, 1, 8],
[14, 45, 23, 5, 27]])
tf.math.argmax(B, 0)
<tf.Tensor: shape=(5,), dtype=int64, numpy=array([2, 2, 0, 2, 2])>
tf.math.argmax(B, 1)
<tf.Tensor: shape=(3,), dtype=int64, numpy=array([2, 2, 1])>
C = tf.constant([0, 0, 0, 0])
tf.math.argmax(C) # Returns smallest index in case of ties
<tf.Tensor: shape=(), dtype=int64, numpy=0>
| Аргументы | |
|---|---|
input | A Tensor. |
axis | Целое число, ось для сокращения. По умолчанию 0. |
output_type | Необязательный тип выходных данных (tf.int32 или tf.int64). По умолчанию tf.int64. |
name | Необязательное имя операции. |
| Возвращаемое значение | |
|---|---|
A Tensor типа output_type. |
© 2022 The TensorFlow Authors. All rights reserved.
Licensed under the Creative Commons Attribution License 4.0.
Code samples licensed under the Apache 2.0 License.
https://www.tensorflow.org/versions/r2.9/api_docs/python/tf/math/argmax