Spec-Zone.ru › TensorFlow

tf.keras.ops.softmax

Softmax activation function.

View aliases

Main aliases

tf.keras.ops.nn.softmax

tf.keras.ops.softmax(
    x, axis=-1
)

The elements of the output vector lie within the range (0, 1), and their total sum is exactly 1 (excluding the floating point rounding error).

Each vector is processed independently. The axis argument specifies the axis along which the function is applied within the input.

It is defined as:

f(x) = exp(x) / sum(exp(x))

Args
x Input tensor.
axis Integer, axis along which the softmax is applied.
Returns
A tensor with the same shape as x.

Example:

x = np.array([-1., 0., 1.])
x_softmax = keras.ops.softmax(x)
print(x_softmax)
array([0.09003057, 0.24472847, 0.66524096], shape=(3,), dtype=float64)

© 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/api_docs/python/tf/keras/ops/softmax

Spec-Zone.ru

Настройки Оффлайн Что нового Помощь О нас
Spec-Zone .ru
спецификации, руководства, описания, API