François Chollet @fchollet Deep learning @google. Creator of Keras, neural networks library. Author of 'Deep Learning with Python'. Opinions are my own. Nov. 25, 2019 1 min read

Built-in losses and metrics in Keras follow the signature `loss(y_true, y_pred, sample_weight=None)`. If you have exotic losses or metrics, a simple way to add them w/o having to implement your own training loop from scratch is to define them in an "endpoint layer". Like this:

It feels a bit more like the "Estimator" training style.

Full Colab notebook:  https://colab.research.google.com/drive/1zzLcJ2A2qofIvv94YJ3axRknlA6cBSIw 

This usage pattern enables you to use `fit`/etc with losses or metrics that have completely arbitrary signatures. Such endpoint layer may also have different behavior during training or inference.


You can follow @fchollet.



Bookmark

____
Tip: mention @threader_app on a Twitter thread with the keyword “compile” to get a link to it.

Enjoy Threader? Sign up.

Threader is an independent project created by only two developers. The site gets 500,000+ visits a month and our iOS Twitter client was featured as an App of the Day by Apple. Running this space is expensive and time consuming. If you find Threader useful, please consider supporting us to make it a sustainable project.