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

When you're using tf.keras in TensorFlow 2.0, training your models with `fit` is one option, but you can also write a custom training loop. It takes about 10 lines.

If your model creates additional losses during its forward pass (i.e. if you called `self.add_loss` in a custom layer), collect them in one line like this.

The advantage of using `fit` is that it packs a lot of functionality in a convenient interface: a progress bar, easy reporting of metrics such as precision & recall, easy management of class weights for imbalanced classification, callbacks for model checkpointing and more...


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.

Since you’re here...

... we’re asking visitors like you to make a contribution to support this independent project. In these uncertain times, access to information is vital. Threader gets 1,000,000+ visits a month and our iOS Twitter client was featured as an App of the Day by Apple. Your financial support will help two developers to keep working on this app. Everyone’s contribution, big or small, is so valuable. Support Threader by becoming premium or by donating on PayPal. Thank you.