The custom Loss function I am looking at is as follows:
@tf.keras.utils.register_keras_serializable(package="Addons")
class GIoULoss(LossFunctionWrapper):
@typechecked
def __init__(
self,
mode: str = "giou",
reduction: str = tf.keras.losses.Reduction.AUTO,
name: Optional[str] = "giou_loss",
):
super().__init__(giou_loss, name=name, reduction=reduction, mode=mode)
@tf.keras.utils.register_keras_serializable(package="Addons")
def giou_loss(y_true: TensorLike, y_pred: TensorLike, mode: str = "giou") -> tf.Tensor:
My questions:
- Majority of the custom loss functions I have looked at work without using LossFunctionWrapper. So under what circumstances is LossFunctionWrapper used and when can you work without it?
- I haven't been able to fully understand from the tensorflow documentation what
@tf.keras.utils.register_keras_serializable(package="Addons")does. Any help?