tf.compat.v1.math.softmax
Вычисляет активации softmax.
tf.compat.v1.math.softmax(
logits, axis=None, name=None, dim=None
)
Используется для многоклассовых прогнозов. Сумма всех выходов, генерируемых функцией softmax, равна 1.
Эта функция выполняет эквивалент
softmax = tf.exp(logits) / tf.reduce_sum(tf.exp(logits), axis, keepdims=True)
Пример использования:
softmax = tf.nn.softmax([-1, 0., 1.]) softmax <tf.Tensor: shape=(3,), dtype=float32, numpy=array([0.09003057, 0.24472848, 0.66524094], dtype=float32)> sum(softmax) <tf.Tensor: shape=(), dtype=float32, numpy=1.0>
| Аргументы | |
|---|---|
logits | Непустой Tensor. Должен быть одного из следующих типов: half, float32, float64. |
axis | Измерение, по которому будет выполняться softmax. По умолчанию -1, что указывает на последнее измерение. |
name | Имя операции (необязательно). |
| Возвращаемое значение | |
|---|---|
Массив Tensor. Имеет тот же тип и форму, что и logits. |
| Исключения | |
|---|---|
InvalidArgumentError | если logits пусто или axis выходит за пределы последнего измерения logits. |
© 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/compat/v1/math/softmax