RemoveAccidentalHits
类keras_rs.layers.RemoveAccidentalHits(
activity_regularizer=None,
trainable=True,
dtype=None,
autocast=True,
name=None,
**kwargs
)
将意外负样本的 logits 置零。
将与该行中正样本具有相同 ID 的负样本候选项的 logits 置零。
示例
# 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
方法RemoveAccidentalHits.call(logits: Any, labels: Any, candidate_ids: Any)
将选定的 logits 置零。
对于批次中的每一行,将与该行中正样本具有相同 ID 的负样本候选项的 logits 置零。
参数
[batch_size, num_candidates]
,但可以有更多维度或为 [num_candidates]
的一维张量。logits
的形状相同。[num_candidates]
或 [batch_size, num_candidates]
,或者只要与 labels
的最后维度匹配就可以有更多维度。返回
修改后的 logits,与输入 logits 的形状相同。