@ -23,11 +23,11 @@ class AucOp : public framework::OperatorWithKernel {
protected :
void InferShape ( framework : : InferShapeContext * ctx ) const override {
PADDLE_ENFORCE ( ctx - > HasInput ( " Out " ) , " Input of Out must be initialized ." ) ;
PADDLE_ENFORCE ( ctx - > HasInput ( " Out " ) , " Input of Out should not be null ." ) ;
PADDLE_ENFORCE ( ctx - > HasInput ( " Indices " ) ,
" Input of Indices must be initialized ." ) ;
" Input of Indices should not be null ." ) ;
PADDLE_ENFORCE ( ctx - > HasInput ( " Label " ) ,
" Input of Label must be initialized ." ) ;
" Input of Label should not be null ." ) ;
auto inference_height = ctx - > GetInputDim ( " Out " ) [ 0 ] ;
auto label_height = ctx - > GetInputDim ( " Label " ) [ 0 ] ;
@ -52,20 +52,20 @@ class AucOpMaker : public framework::OpProtoAndCheckerMaker {
: OpProtoAndCheckerMaker ( proto , op_checker ) {
AddInput ( " Out " ,
" A floating point 2D tensor, values are in the range [0, 1]. "
" Each row is descend s orte d. This input should be the"
" Each row is sorted in descending order . This input should be the"
" output of topk. "
" Typically, this tensor indicates the probability of each label " ) ;
AddInput ( " Indices " ,
" An int 2D tensor, indicating the indices of original "
" tensor before sort . Typically, this tensor indicates which label "
" the probability stands for." ) ;
" tensor before sort ing . Typically, this tensor indicates which "
" label the probability stands for." ) ;
AddInput ( " Label " ,
" A 2D int tensor indicating the label of the training data. "
" The height is batch size and width is always 1. " ) ;
// TODO(typhoonzero): support weight input
AddOutput ( " AUC " ,
" A scalar representing the "
" current area-under- curve." ) ;
" current area-under- the- curve." ) ;
AddAttr < std : : string > ( " curve " , " Curve type, can be 'ROC' or 'PR'. " )
. SetDefault ( " ROC " ) ;
@ -74,19 +74,18 @@ class AucOpMaker : public framework::OpProtoAndCheckerMaker {
" roc curve. " )
. SetDefault ( 200 ) ;
AddComment (
R " DOC(Computes the AUC according forward output and label.
Best to use for binary classification evaluations .
AddComment ( R " DOC(
Area Under The Curve ( AUC ) Operator .
This implementation computes the AUC according to forward output and label .
It is used very widely in binary classification evaluation . As a note :
If input label contains values other than 0 and 1 , it will be cast
to bool .
You can find the definations here :
to bool . You can find the relevant definitions here :
https : //en.wikipedia.org/wiki/Receiver_operating_characteristic#Area_under_the_curve
Possible curves are :
- ROC : Receiver operating characteristic
- PR : Precision Recall
There are two types of possible curves :
1. ROC : Receiver operating characteristic
2. PR : Precision Recall
) DOC " );
}
} ;