Conversation
| // TODO(typhoonzero): support weight input | ||
| AddOutput("AUC", | ||
| "A scalar `Tensor` representing the " | ||
| "current area-under-curve."); |
There was a problem hiding this comment.
I think it's better to tell users "what is it" before "how to represent it".
So the comment might be better to write "Current AUC(area-under-curve), represented by a scalar Tensor."
There was a problem hiding this comment.
I think it's better to tell users "what is it" before "how to represent it".
Correct, but in this line, "what is it", the output is a scalar indeed, and "representing ..." is what it does.
paddle/operators/auc_op.cc
Outdated
| "A scalar `Tensor` representing the " | ||
| "current area-under-curve."); | ||
|
|
||
| AddAttr<std::string>("curve", "Possible curves are ROC and PR") |
There was a problem hiding this comment.
"Curves type, can be 'ROC' or 'PR'."
seems better?
paddle/operators/auc_op.cc
Outdated
| AucOpMaker(framework::OpProto *proto, framework::OpAttrChecker *op_checker) | ||
| : OpProtoAndCheckerMaker(proto, op_checker) { | ||
| AddInput("Inference", | ||
| "A floating point `Tensor` of arbitrary shape and whose values" |
There was a problem hiding this comment.
There is no need to surround Tensor with ``, because this comment will be read by Python users and they know nothing about C++ class Tensor. So tensor is OK.
paddle/operators/auc_op.cc
Outdated
| PADDLE_ENFORCE_NOT_NULL(ctx.InputVar("Inference"), | ||
| "Input of Inference must be initialized."); | ||
| PADDLE_ENFORCE_NOT_NULL(ctx.InputVar("Label"), | ||
| "Input of Inference must be initialized."); |
| float* tp_rate_data = tp_rate.mutable_data<float>(ctx.GetPlace()); | ||
| float* fp_rate_data = fp_rate.mutable_data<float>(ctx.GetPlace()); | ||
| float* rec_rate_data = rec_rate.mutable_data<float>(ctx.GetPlace()); | ||
| for (int i = 0; i < num_thresholds; i++) { |
There was a problem hiding this comment.
Maybe we can convert Tensor to Eigen::Tensor, and do vector computation instead of loop.
There was a problem hiding this comment.
Added to TODO, will refine if eigen have enough operators.
There was a problem hiding this comment.
Maybe https://github.com/PaddlePaddle/Paddle/blob/develop/paddle/operators/elementwise_div_op.h#L71
can be used as a reference.
| auto* label = ctx.Input<Tensor>("Label"); | ||
| auto* auc = ctx.Output<Tensor>("AUC"); | ||
|
|
||
| float* auc_data = auc->mutable_data<float>(ctx.GetPlace()); |
There was a problem hiding this comment.
Evaluator output is always float.
| for (int i = 1; i < num_thresholds - 1; i++) { | ||
| thresholds_list[i] = (float)i / (num_thresholds - 1); | ||
| } | ||
| const float kEpsilon = 1e-7; |
There was a problem hiding this comment.
Overflow the accuracy range?
There was a problem hiding this comment.
Sorry didn't get your point?
There was a problem hiding this comment.
Oh, maybe float type can have 7 significant digits, I'm not sure about this.
Fix #4062
This is WIP, will add GPU code in next PR.