tf.keras.Loss
Базовый класс потерь.
tf.keras.Loss(
name=None, reduction='sum_over_batch_size', dtype=None
)
Для реализации подклассами:
-
call(): Содержит логику расчета потерь с использованиемy_true,y_pred.
Пример реализации подкласса:
class MeanSquaredError(Loss):
def call(self, y_true, y_pred):
return ops.mean(ops.square(y_pred - y_true), axis=-1)
Методы
call
call(
y_true, y_pred
)
from_config
@classmethod
from_config(
config
)
get_config
get_config()
__call__
__call__(
y_true, y_pred, sample_weight=None
)
Вызов self как функции.
© 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/Loss