auc

paddle.distributed.fleet.metrics.metric. auc ( stat_pos, stat_neg, scope=None, util=None ) [source]

distributed auc in fleet

Parameters
  • stat_pos (numpy.array|Variable|string) – stat_pos in output of fluid.layers.auc

  • stat_neg (numpy.array|Variable|string) – stat_neg in output of fluid.layers.auc

  • scope (Scope) – specific scope

Returns

auc value

Return type

auc_value(float)

Example

# in model.py
similarity_norm = fluid.layers.sigmoid(fluid.layers.clip(output, min=-15.0, max=15.0))
binary_predict = fluid.layers.concat(
    input=[fluid.layers.elementwise_sub(fluid.layers.ceil(similarity_norm), similarity_norm), similarity_norm], axis=1)
self.auc, batch_auc, [batch_stat_pos, batch_stat_neg, stat_pos, stat_neg] =
    fluid.layers.auc(input=binary_predict, label=label, curve='ROC', num_thresholds=4096)

# in train.py, after train or infer
pos = np.array(scope.find_var(stat_pos.name).get_tensor())
neg = np.array(scope.find_var(stat_neg.name).get_tensor())
print("auc: ", paddle.distributed.fleet.auc(pos, neg))