Sitemap
The Startup

Get smarter at building your thing. Follow to join The Startup’s +8 million monthly readers & +772K followers.

Member-only story

Curated Custom Callbacks

An ongoing list of custom written callbacks that I use for my machine learning research.

4 min readDec 13, 2020

--

Press enter or click to view image in full size
Photo by Quino Al on Unsplash

The following callbacks are mainly input-type agnostic, meaning that they can be used for time-series, images, and text as well.

Notes

The __slots__ attribute reduces memory usage. If you modify any callback, just add any new parameter to this list.

A TensorFlow callback has access to the model it is applied to, via the self.model attribute. I use this convenient access extensively throughout my code.

Some callbacks are designed to work with TensorBoard. If you do not need this functionality, then modify — only small changes are required, mostly you will need to delete code.

ClassificationReportCallback

This short callback comes in handy when you want to regulary check on summary statistics for your training. It requires the sklearn package to generate the actual report. The arguments are a FileWriter (to write data to a TensorBoard directory), the batch size to take during prediction, and most importantly two numpy arrays, x and y.

These arrays contain sample data (x) and corresponding labels (y), based on which the classification report is created by sklearn. The…

--

--

The Startup
The Startup

Published in The Startup

Get smarter at building your thing. Follow to join The Startup’s +8 million monthly readers & +772K followers.

Pascal Janetzky
Pascal Janetzky

Written by Pascal Janetzky

I aim to read and learn, code and move.