Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
Paddle
提交
e395bcd1
P
Paddle
项目概览
PaddlePaddle
/
Paddle
大约 1 年 前同步成功
通知
2298
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看板
体验新版 GitCode,发现更多精彩内容 >>
未验证
提交
e395bcd1
编写于
1月 14, 2021
作者:
J
Jiaqi Liu
提交者:
GitHub
1月 14, 2021
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
add auc into 'all' list (#30310)
* add auc into 'all' list * alias acc, expose to users * update sample code
上级
859431aa
变更
2
显示空白变更内容
内联
并排
Showing
2 changed file
with
33 addition
and
24 deletion
+33
-24
python/paddle/fluid/layers/metric_op.py
python/paddle/fluid/layers/metric_op.py
+30
-24
python/paddle/static/__init__.py
python/paddle/static/__init__.py
+3
-0
未找到文件。
python/paddle/fluid/layers/metric_op.py
浏览文件 @
e395bcd1
...
...
@@ -51,27 +51,30 @@ def accuracy(input, label, k=1, correct=None, total=None):
Examples:
.. code-block:: python
import paddle.fluid as fluid
import numpy as np
data = fluid.data(name="input", shape=[-1, 32, 32], dtype="float32")
label = fluid.data(name="label", shape=[-1,1], dtype="int")
fc_out = fluid.layers.fc(input=data, size=10)
predict = fluid.layers.softmax(input=fc_out)
result = fluid.layers.accuracy(input=predict, label=label, k=5)
import paddle
import paddle.static as static
import paddle.nn.functional as F
paddle.enable_static()
data = static.data(name="input", shape=[-1, 32, 32], dtype="float32")
label = static.data(name="label", shape=[-1,1], dtype="int")
fc_out = static.nn.fc(x=data, size=10)
predict = F.softmax(x=fc_out)
result = static.accuracy(input=predict, label=label, k=5)
place =
fluid
.CPUPlace()
exe =
fluid
.Executor(place)
place =
paddle
.CPUPlace()
exe =
static
.Executor(place)
exe.run(
fluid
.default_startup_program())
exe.run(
static
.default_startup_program())
x = np.random.rand(3, 32, 32).astype("float32")
y = np.array([[1],[0],[1]])
output= exe.run(feed={"input": x,"label": y},
fetch_list=[result[0]])
print(output)
#[array([0.
6666667
], dtype=float32)]
#[array([0.], dtype=float32)]
"""
if
in_dygraph_mode
():
if
correct
is
None
:
...
...
@@ -153,26 +156,29 @@ def auc(input,
Examples:
.. code-block:: python
import paddle.fluid as fluid
import numpy as np
data = fluid.data(name="input", shape=[-1, 32,32], dtype="float32")
label = fluid.data(name="label", shape=[-1], dtype="int")
fc_out = fluid.layers.fc(input=data, size=2)
predict = fluid.layers.softmax(input=fc_out)
result=fluid.layers.auc(input=predict, label=label)
import paddle
import paddle.static as static
import paddle.nn.functional as F
paddle.enable_static()
data = static.data(name="input", shape=[-1, 32,32], dtype="float32")
label = static.data(name="label", shape=[-1], dtype="int")
fc_out = static.nn.fc(x=data, size=2)
predict = F.softmax(x=fc_out)
result = static.auc(input=predict, label=label)
place =
fluid
.CPUPlace()
exe =
fluid
.Executor(place)
place =
paddle
.CPUPlace()
exe =
static
.Executor(place)
exe.run(
fluid
.default_startup_program())
exe.run(
static
.default_startup_program())
x = np.random.rand(3,32,32).astype("float32")
y = np.array([1,0,1])
output= exe.run(feed={"input": x,"label": y},
fetch_list=[result[0]])
print(output)
#[array([0.
5
])]
#[array([0.])]
"""
helper
=
LayerHelper
(
"auc"
,
**
locals
())
check_variable_and_dtype
(
input
,
'input'
,
[
'float32'
,
'float64'
],
'auc'
)
...
...
python/paddle/static/__init__.py
浏览文件 @
e395bcd1
...
...
@@ -45,6 +45,8 @@ __all__ = [
'Variable'
,
'load_vars'
,
'save_vars'
,
'auc'
,
'accuracy'
,
]
from
.
import
nn
...
...
@@ -92,3 +94,4 @@ from ..fluid.io import save_vars #DEFINE_ALIAS
from
..fluid.layers
import
create_parameter
#DEFINE_ALIAS
from
..fluid.layers
import
create_global_var
#DEFINE_ALIAS
from
..fluid.layers.metric_op
import
auc
#DEFINE_ALIAS
from
..fluid.layers.metric_op
import
accuracy
#DEFINE_ALIAS
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录