稀疏数据运算符¶
CUDA 运算符¶
-
at::Tensor expand_into_jagged_permute_cuda(const at::Tensor &permute, const at::Tensor &input_offsets, const at::Tensor &output_offsets, int64_t output_size)¶
expand_into_jagged_permute 函数将稀疏数据的置换索引从表维度扩展到批次维度,用于处理稀疏特征在不同秩上具有不同批次大小的情况。
- 参数:
permute – 表级别的置换索引。
input_offsets – 表级别长度的 exclusive 偏移量。
output_offsets – 表级别置换后长度的 exclusive 偏移量。此操作通过将每个 bag 及其对应的表连续映射到特征置换后批次所在的位置,从而将置换从表级别扩展到批次级别。我们将推导表和批次的偏移数组来计算输出置换。
- 返回值:
输出遵循以下格式
output_permute[table_offset[permute[table]] + batch] <- bag_offset[batch]
CPU 运算符¶
-
std::tuple<at::Tensor, at::Tensor> generic_histogram_binning_calibration_by_feature_cpu(const at::Tensor &logit, const at::Tensor &segment_value, const at::Tensor &segment_lengths, int64_t num_segments, const at::Tensor &bin_num_examples, const at::Tensor &bin_num_positives, const at::Tensor &bin_boundaries, double positive_weight, int64_t bin_ctr_in_use_after = 0, double bin_ctr_weight_value = 1.0)¶
将预测范围(例如,[0, 1])划分为 B 个 bin。在每个 bin 中,使用两个参数存储正例的数量和落入此 bin 的示例数量。因此,我们基本上获得了模型预测的直方图。结果是,对于每个 bin,我们都有一个真实 CTR (
num_pos / num_example
) 的统计值。如果预校准预测落入相应的 bin,我们将使用此统计值作为最终的校准预测。这样,如果我们有足够的示例,每个 bin 内的预测应该得到很好的校准。也就是说,通过此校准模块,我们获得了一个细粒度的校准模型。理论上,如果我们有足够的 bin 和示例,此校准层可以修正任何未校准的模型或预测。
// 直方图分箱校准模型的扩展,该模型根据一个特定特征和预测/ECTR 范围将数据划分为 bin。/ 在每个 bin 中,使用两个参数存储正例的数量和落入此 bucket / 的示例数量。因此,我们基本上获得了模型预测的直方图。/ 结果是,对于每个 bin,我们都有一个真实 CTR (num_pos / num_example) / 的统计值。如果预校准预测落入相应的 bin,我们将使用此统计 / 值作为最终的校准预测。这样,如果我们有足够的示例,每个 bin / 内的预测应该得到很好的校准。也就是说,通过此校准模块,我们获得了 / 一个细粒度的校准模型。理论上,如果我们有足够的 bin 和示例,此 / 校准层可以修正任何未校准的模型或预测。 / /
与上述相同,但接受通用的“bin_boundaries”,假定其已排序。- 参数:
logit – 应用 Sigmoid 之前的输入张量。假定对校准目标使用了正权重校准,并且
positive_weight – 作为输入参数传递。bin 的数量自动从
bin_num_examples
和bin_num_positives
中推导得出,它们的大小应相同。 /lower/upper_bound – bin 的边界。 /
bin_ctr_in_use_after – 如果示例数量不足,我们将使用 calibration_target 作为 / 最终校准预测。仅在观察到落入此 bin 的
bin_ctr_in_use_after
个示例后,/ 才使用 bin CTR 的统计值。默认值:0。 /bin_ctr_weight_value – bin CTR 统计值的权重。/ 指定此值时,我们对统计的 / bin CTR 和 calibration_target 执行加权求和:/
/ final_calibrated_prediction = bin_ctr_weight * bin_ctr + (1 - / bin_ctr_weight) * calibration_target /
/ 默认值:1.0 std::tuple<at::Tensor, at::Tensor> histogram_binning_calibration_cpu( const at::Tensor& logit, const at::Tensor& bin_num_examples, const at::Tensor& bin_num_positives, double positive_weight, double lower_bound = 0.0, double upper_bound = 1.0, int64_t bin_ctr_in_use_after = 0, double bin_ctr_weight_value = 1.0);logit – 应用 Sigmoid 之前的输入张量。/ / 假定对校准目标使用了正权重校准,并且 /
positive_weight
作为输入参数传递。 /segment_value/lengths – KeyJaggedTensor 中的值和长度。/ 假定长度值为 0 或 1。 /
num_bins – bin 的数量不再与
bin_num_examples
/ 和bin_num_positives
相同,尽管它们的大小仍应相同。 /lower/upper_bound – bin 的边界。 /
bin_ctr_in_use_after – 如果示例数量不足,我们将使用 calibration_target 作为 / 最终校准预测。/ 仅在观察到落入此 bin 的
bin_ctr_in_use_after
个示例后,/ 才使用 bin CTR 的统计值。默认值为0
。/@parambin_ctr_weight_value bin CTR 统计值的权重。指定此值时,我们对统计的 / bin CTR 和 calibration_target 执行加权求和:// final_calibrated_prediction = bin_ctr_weight * bin_ctr + (1 - / bin_ctr_weight) * calibration_target. /
/ 默认值:1.0
- 返回值:
[calibrated_prediction, bin_ids]
- 返回值:
[calibrated_prediction, bin_ids]
/- 返回值:
calibrated_prediction。