keras Custom loss function and metrics in Keras

Help us to keep this website almost Ad Free! It takes only 10 seconds of your time:
> Step 1: Go view our video on YouTube: EF Core Bulk Extensions
> Step 2: And Like the video. BONUS: You can also share it!

Introduction

You can create a custom loss function and metrics in Keras by defining a TensorFlow/Theano symbolic function that returns a scalar for each data-point and takes the following two arguments: tensor of true values, tensor of the corresponding predicted values.

Note that the loss/metric (for display and optimization) is calculated as the mean of the losses/metric across all datapoints in the batch.

Remarks

Keras loss functions are defined in losses.py

Additional loss functions for Keras can be found in keras-contrib repository.



Got any keras Question?