Path: blob/master/examples/keras_recipes/ipynb/endpoint_layer_pattern.ipynb
5294 views
Kernel: Python 3
Endpoint layer pattern
Author: fchollet
Date created: 2019/05/10
Last modified: 2023/11/22
Description: Demonstration of the "endpoint layer" pattern (layer that handles loss management).
Setup
In [0]:
Usage of endpoint layers in the Functional API
An "endpoint layer" has access to the model's targets, and creates arbitrary losses in call() using self.add_loss() and Metric.update_state(). This enables you to define losses and metrics that don't match the usual signature fn(y_true, y_pred, sample_weight=None).
Note that you could have separate metrics for training and eval with this pattern.
In [0]:
Exporting an inference-only model
Simply don't include targets in the model. The weights stay the same.
In [0]:
Usage of loss endpoint layers in subclassed models
In [0]: