RemoveAccidentalHits
classkeras_rs.layers.RemoveAccidentalHits(
activity_regularizer=None,
trainable=True,
dtype=None,
autocast=True,
name=None,
**kwargs
)
Zeroes the logits of accidental negatives.
Zeroes the logits of negative candidates that have the same ID as the positive candidate in that row.
Example
# Create layer with the configured number of hard negatives to mine.
remove_accidental_hits = keras_rs.layers.RemoveAccidentalHits()
# This will zero the logits of negative candidates that have the same ID as
# the positive candidate from `labels` so as to not negatively impact the
# true positive.
logits = remove_accidental_hits(logits, labels, candidate_ids)
call
methodRemoveAccidentalHits.call(logits: Any, labels: Any, candidate_ids: Any)
Zeroes selected logits.
For each row in the batch, zeroes the logits of negative candidates that have the same ID as the positive candidate in that row.
Arguments
[batch_size, num_candidates]
but can have more dimensions or be 1D as [num_candidates]
.logits
.[num_candidates]
or [batch_size, num_candidates]
or have
more dimensions as long as they match the last dimensions of
labels
.Returns
The modified logits with the same shape as the input logits.