Binary Penalty Reduced Focal CrossEntropy
- Original Link : https://keras.io/api/keras_cv/losses/binary_focal_crossentropy/
- Last Checked at : 2024-11-25
BinaryPenaltyReducedFocalCrossEntropy
class
keras_cv.losses.BinaryPenaltyReducedFocalCrossEntropy(
alpha=2.0,
beta=4.0,
from_logits=False,
positive_threshold=0.99,
positive_weight=1.0,
negative_weight=1.0,
reduction="sum_over_batch_size",
name="binary_penalty_reduced_focal_cross_entropy",
)
Implements CenterNet modified Focal loss.
Compared with keras.losses.BinaryFocalCrossentropy
, this loss discounts
for negative labels that have value less than positive_threshold
, the
larger value the negative label is, the more discount to the final loss.
User can choose to divide the number of keypoints outside the loss
computation, or by passing in sample_weight
as 1.0/num_key_points.
Arguments
- alpha: a focusing parameter used to compute the focal factor.
Defaults to 2.0. Note, this is equivalent to the
gamma
parameter inkeras.losses.BinaryFocalCrossentropy
. - beta: a float parameter, penalty exponent for negative labels, defaults to 4.0.
- from_logits: Whether
y_pred
is expected to be a logits tensor, defaults toFalse
. - positive_threshold: Anything bigger than this is treated as positive label, defaults to 0.99.
- positive_weight: single scalar weight on positive examples, defaults to 1.0.
- negative_weight: single scalar weight on negative examples, defaults to 1.0.
Inputs: y_true: [batch_size, …] float tensor y_pred: [batch_size, …] float tensor with same shape as y_true.
References
- Objects as Points Eq 1.
- Cornernet: Detecting objects as paired keypoints for
alpha
andbeta
.
- Cornernet: Detecting objects as paired keypoints for