ramjet.losses¶
Code for custom losses for the ramjet package.
Module Contents¶
-
class
PerTimeStepBinaryCrossEntropy(positive_weight: float = 1, *args, **kwargs)[source]¶ Bases:
tensorflow.python.keras.losses.LossFunctionWrapperComputes the cross-entropy loss between true labels and predicted labels for a time series which each time step has a binary label.
-
__init__(self, positive_weight: float = 1, *args, **kwargs)[source]¶ Parameters: positive_weight – The weight to give to positive labels in calculating the loss (relative to negative).
-
static
per_time_step_binary_cross_entropy(y_true: tf.Tensor, y_pred: tf.Tensor, positive_weight: float = 1)[source]¶ Calculates the cross-entropy loss between true labels and predicted labels for a time series which each time step has a binary label.
Parameters: - y_true – The true label.
- y_pred – The predicted label.
- positive_weight – The weight to give to positive labels in calculating the loss (relative to negative).
Returns: The resulting cross entropy loss.
-