Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
Paddle
提交
1f3b9ef5
P
Paddle
项目概览
PaddlePaddle
/
Paddle
1 年多 前同步成功
通知
2302
Star
20931
Fork
5422
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
1423
列表
看板
标记
里程碑
合并请求
543
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
P
Paddle
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
1,423
Issue
1,423
列表
看板
标记
里程碑
合并请求
543
合并请求
543
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
未验证
提交
1f3b9ef5
编写于
4月 03, 2023
作者:
G
gouzil
提交者:
GitHub
4月 03, 2023
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
add autogen code support for accuracy (#52424)
* add autogen code support for accuracy * fix input
上级
2f850990
变更
4
显示空白变更内容
内联
并排
Showing
4 changed file
with
15 addition
and
86 deletion
+15
-86
paddle/fluid/operators/metrics/accuracy_op.cc
paddle/fluid/operators/metrics/accuracy_op.cc
+0
-77
paddle/phi/api/yaml/legacy_ops.yaml
paddle/phi/api/yaml/legacy_ops.yaml
+0
-9
paddle/phi/api/yaml/op_compat.yaml
paddle/phi/api/yaml/op_compat.yaml
+6
-0
paddle/phi/api/yaml/ops.yaml
paddle/phi/api/yaml/ops.yaml
+9
-0
未找到文件。
paddle/fluid/operators/metrics/accuracy_op.cc
已删除
100644 → 0
浏览文件 @
2f850990
/* Copyright (c) 2016 PaddlePaddle Authors. All Rights Reserved.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License. */
#include "paddle/fluid/framework/infershape_utils.h"
#include "paddle/fluid/framework/op_registry.h"
#include "paddle/phi/infermeta/ternary.h"
namespace
paddle
{
namespace
operators
{
class
AccuracyOp
:
public
framework
::
OperatorWithKernel
{
public:
using
framework
::
OperatorWithKernel
::
OperatorWithKernel
;
protected:
phi
::
KernelKey
GetExpectedKernelType
(
const
framework
::
ExecutionContext
&
ctx
)
const
override
{
return
phi
::
KernelKey
(
OperatorWithKernel
::
IndicateVarDataType
(
ctx
,
"Out"
),
ctx
.
GetPlace
());
}
};
class
AccuracyOpMaker
:
public
framework
::
OpProtoAndCheckerMaker
{
public:
void
Make
()
override
{
// TODO(typhoonzero): support both inference value and indices.
AddInput
(
"Out"
,
"The network output of topk (inferences)"
);
AddInput
(
"Indices"
,
"The network output of topk (indices)"
);
AddInput
(
"Label"
,
"Label of the training data"
);
// TODO(typhoonzero): AddInput("Weight", ...
AddOutput
(
"Accuracy"
,
"The accuracy of current batch"
);
AddOutput
(
"Correct"
,
"The correct samples count of current batch"
);
AddOutput
(
"Total"
,
"The samples count of current batch"
);
AddComment
(
R"DOC(
Accuracy Operator.
It will print accuracy rate for classification.
The accuracy is calculated as follows:
$$accuracy = \frac{NumOfCorrectPredicts}{NumOfAllSamples}$$
Both the input Out and Label can carry the LoD (Level of Details)
information, or not. But the output only shares the LoD information
with the input Out(Inference).
)DOC"
);
}
};
}
// namespace operators
}
// namespace paddle
// FIXME(typhoonzero): types of T is for infernece data.
// label data is always int.
DECLARE_INFER_SHAPE_FUNCTOR
(
accuracy
,
AccuracyInferShapeFunctor
,
PD_INFER_META
(
phi
::
AccuracyInferMeta
));
namespace
ops
=
paddle
::
operators
;
REGISTER_OPERATOR
(
accuracy
,
ops
::
AccuracyOp
,
ops
::
AccuracyOpMaker
,
paddle
::
framework
::
EmptyGradOpMaker
<
paddle
::
framework
::
OpDesc
>
,
paddle
::
framework
::
EmptyGradOpMaker
<
paddle
::
imperative
::
OpBase
>
,
AccuracyInferShapeFunctor
);
paddle/phi/api/yaml/legacy_ops.yaml
浏览文件 @
1f3b9ef5
...
...
@@ -10,15 +10,6 @@
func
:
abs
backward
:
abs_grad
-
op
:
accuracy
args
:
(Tensor x, Tensor indices, Tensor label)
output
:
Tensor(accuracy), Tensor(correct), Tensor(total)
infer_meta
:
func
:
AccuracyInferMeta
kernel
:
func
:
accuracy
data_type
:
x
-
op
:
adadelta_
args
:
(Tensor param, Tensor grad, Tensor avg_squared_grad, Tensor avg_squared_update, Tensor master_param, float rho, float epsilon, bool multi_precision)
output
:
Tensor(param_out), Tensor(moment_out), Tensor(inf_norm_out), Tensor(master_param_out)
...
...
paddle/phi/api/yaml/op_compat.yaml
浏览文件 @
1f3b9ef5
...
...
@@ -23,6 +23,12 @@
extra
:
attrs
:
[
bool use_mkldnn = false
]
-
op
:
accuracy
inputs
:
{
x
:
Out
,
indices
:
Indices
,
label
:
Label
}
outputs
:
{
accuracy
:
Accuracy
,
correct
:
Correct
,
total
:
Total
}
-
op
:
acos
inputs
:
x
:
X
...
...
paddle/phi/api/yaml/ops.yaml
浏览文件 @
1f3b9ef5
...
...
@@ -5,6 +5,15 @@
# are consistent and correspond one-to-one. It's forbidden that the
# operator configured in this yaml file does not have Python API.
-
op
:
accuracy
args
:
(Tensor x, Tensor indices, Tensor label)
output
:
Tensor(accuracy), Tensor(correct), Tensor(total)
infer_meta
:
func
:
AccuracyInferMeta
kernel
:
func
:
accuracy
data_type
:
x
-
op
:
acos
args
:
(Tensor x)
output
:
Tensor
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录