Losses

losses sub-module within the ketos.neural_networks module

This module provides loss functions

Contents:

FScoreLoss class:

class ketos.neural_networks.dev_utils.losses.FScoreLoss(beta=1.0, **kwargs)[source]

Bases: tensorflow.python.keras.losses.Loss

Loss function based on the inverse of F-Score.

When instantiated, the resulting loss function expects the predictions in the ‘y_pred’ argument and the true labels in the ‘y_true’ argument.

Args:
beta:float
The relative weight of recall in relation to precision.
Examples:

If beta = 1.0, recall has same weight as precision If beta = 0.5, recall has half the weight of precision If beta = 2.0, recall has twice the weight of precision

call(y_true, y_pred)[source]

Invokes the Loss instance.

Args:
y_true: Ground truth values. shape = [batch_size, d0, .. dN], except

sparse loss functions such as sparse categorical crossentropy where shape = [batch_size, d0, .. dN-1]

y_pred: The predicted values. shape = [batch_size, d0, .. dN]

Returns:

Loss values with the shape [batch_size, d0, .. dN-1].