Spec-Zone.ru › TensorFlow

tf.keras.losses.categorical_hinge

Вычисляет категориальную потерю типа «hinge» между y_true и y_pred.

Просмотр псевдонимов

Основные псевдонимы

tf.keras.metrics.categorical_hinge

tf.keras.losses.categorical_hinge(
    y_true, y_pred
)

Формула:

loss = maximum(neg - pos + 1, 0)

где neg=maximum((1-y_true)*y_pred) и pos=sum(y_true*y_pred)

Аргументы
y_true Значения целевого объекта. Ожидается, что значения будут либо {-1, +1}, либо {0, 1} (т. е. тензор в формате one-hot) с формой = [batch_size, d0, .. dN].
y_pred Прогнозируемые значения с формой = [batch_size, d0, .. dN].
Возвращаемые значения
Значения категориальной потери hinge с формой = [batch_size, d0, .. dN-1].

Пример:

y_true = np.random.randint(0, 3, size=(2,))
y_true = np.eye(np.max(y_true) + 1)[y_true]
y_pred = np.random.random(size=(2, 3))
loss = keras.losses.categorical_hinge(y_true, y_pred)

© 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/losses/categorical_hinge

Spec-Zone.ru

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