In short, you use `add_loss`/`add_metric` inside an "endpoint layer" that also has access to model targets. The layer then returns the inference-time predictions. You compile without an external "loss" argument, and you fit with a dictionary of data that contains the targets.
-
-
Show this thread
-
Of course logistic regression is a basic case that doesn't actually need this advanced pattern. But endpoint layers will work every time, even when you have losses & metrics that don't match the usual `fn(y_true, y_pred, sampl_weight)` signature that is required in `compile`.
Show this thread
End of conversation
New conversation -
-
-
A very good method to customize our neural networks. This method can be generalized for other machine learning techniques too.
Thanks. Twitter will use this to make your timeline better. UndoUndo
-
-
-
How does this work during inference, when targets are not available? Do we only add loss and metric when the targets are not None.
-
You need to redefine your model for inference. This is pretty easy since you can reuse almost all the logic from the training model.
- Show replies
New conversation -
-
-
cc
@notwaldorf for all your custom crazy lossesThanks. Twitter will use this to make your timeline better. UndoUndo
-
-
-
I assume this is the new preferred way of using complex losses over using the Function layer, as in the OCR example?
Thanks. Twitter will use this to make your timeline better. UndoUndo
-
-
-
Nice. Actually we use sometime like this for CTC loss (targets as inputs, add_loss()).
Thanks. Twitter will use this to make your timeline better. UndoUndo
-
-
-
Is this feature available in TensorFlow Eager model without compiling?
Thanks. Twitter will use this to make your timeline better. UndoUndo
-
-
-
Tried this, getting an error at self.add_metric saying that the attribute doesn't exist...
Thanks. Twitter will use this to make your timeline better. UndoUndo
-
Loading seems to be taking a while.
Twitter may be over capacity or experiencing a momentary hiccup. Try again or visit Twitter Status for more information.