Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
Paddle
提交
395cb561
P
Paddle
项目概览
PaddlePaddle
/
Paddle
大约 1 年 前同步成功
通知
2299
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看板
未验证
提交
395cb561
编写于
10月 09, 2020
作者:
Z
zhupengyang
提交者:
GitHub
10月 09, 2020
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
refine logsumexp error message and docs (#27713)
上级
057e28bc
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
14 addition
and
18 deletion
+14
-18
paddle/fluid/operators/reduce_ops/logsumexp_op.cc
paddle/fluid/operators/reduce_ops/logsumexp_op.cc
+13
-15
python/paddle/tensor/math.py
python/paddle/tensor/math.py
+1
-3
未找到文件。
paddle/fluid/operators/reduce_ops/logsumexp_op.cc
浏览文件 @
395cb561
...
@@ -32,7 +32,7 @@ class LogsumexpOp : public framework::OperatorWithKernel {
...
@@ -32,7 +32,7 @@ class LogsumexpOp : public framework::OperatorWithKernel {
PADDLE_ENFORCE_LE
(
x_rank
,
4
,
PADDLE_ENFORCE_LE
(
x_rank
,
4
,
platform
::
errors
::
InvalidArgument
(
platform
::
errors
::
InvalidArgument
(
"The input tensor X's dimensions of logsumexp "
"The input tensor X's dimensions of logsumexp "
"should be less equal than 4. But received X's "
"should be less
or
equal than 4. But received X's "
"dimensions = %d, X's shape = [%s]."
,
"dimensions = %d, X's shape = [%s]."
,
x_rank
,
x_dims
));
x_rank
,
x_dims
));
auto
axis
=
ctx
->
Attrs
().
Get
<
std
::
vector
<
int
>>
(
"axis"
);
auto
axis
=
ctx
->
Attrs
().
Get
<
std
::
vector
<
int
>>
(
"axis"
);
...
@@ -45,20 +45,18 @@ class LogsumexpOp : public framework::OperatorWithKernel {
...
@@ -45,20 +45,18 @@ class LogsumexpOp : public framework::OperatorWithKernel {
axis
.
size
()));
axis
.
size
()));
for
(
size_t
i
=
0
;
i
<
axis
.
size
();
i
++
)
{
for
(
size_t
i
=
0
;
i
<
axis
.
size
();
i
++
)
{
PADDLE_ENFORCE_LT
(
PADDLE_ENFORCE_LT
(
axis
[
i
],
x_rank
,
axis
[
i
],
x_rank
,
platform
::
errors
::
InvalidArgument
(
platform
::
errors
::
InvalidArgument
(
"axis[%d] should be in the "
"axis[%d] should be in the "
"range [-D, D), where D is the dimensions of X and "
"range [-dimension(X), dimension(X)] "
"D is %d. But received axis[%d] = %d."
,
"where dimesion(X) is %d. But received axis[i] = %d."
,
i
,
x_rank
,
i
,
axis
[
i
]));
i
,
x_rank
,
axis
[
i
]));
PADDLE_ENFORCE_GE
(
axis
[
i
],
-
x_rank
,
PADDLE_ENFORCE_GE
(
platform
::
errors
::
InvalidArgument
(
axis
[
i
],
-
x_rank
,
"axis[%d] should be in the "
platform
::
errors
::
InvalidArgument
(
"range [-D, D), where D is the dimensions of X and "
"axis[%d] should be in the "
"D is %d. But received axis[%d] = %d."
,
"range [-dimension(X), dimension(X)] "
i
,
x_rank
,
i
,
axis
[
i
]));
"where dimesion(X) is %d. But received axis[i] = %d."
,
i
,
x_rank
,
axis
[
i
]));
if
(
axis
[
i
]
<
0
)
{
if
(
axis
[
i
]
<
0
)
{
axis
[
i
]
+=
x_rank
;
axis
[
i
]
+=
x_rank
;
}
}
...
...
python/paddle/tensor/math.py
浏览文件 @
395cb561
...
@@ -999,7 +999,7 @@ def logsumexp(x, axis=None, keepdim=False, name=None):
...
@@ -999,7 +999,7 @@ def logsumexp(x, axis=None, keepdim=False, name=None):
This OP calculates the log of the sum of exponentials of ``x`` along ``axis`` .
This OP calculates the log of the sum of exponentials of ``x`` along ``axis`` .
.. math::
.. math::
logsumexp(x) = \
log
\sum exp(x)
logsumexp(x) =
\
\
log
\
\
sum exp(x)
Args:
Args:
x (Tensor): The input Tensor with data type float32, float64.
x (Tensor): The input Tensor with data type float32, float64.
...
@@ -1030,8 +1030,6 @@ def logsumexp(x, axis=None, keepdim=False, name=None):
...
@@ -1030,8 +1030,6 @@ def logsumexp(x, axis=None, keepdim=False, name=None):
import paddle
import paddle
paddle.disable_static()
x = paddle.to_tensor([[-1.5, 0., 2.], [3., 1.2, -2.4]])
x = paddle.to_tensor([[-1.5, 0., 2.], [3., 1.2, -2.4]])
out1 = paddle.logsumexp(x) # [3.4691226]
out1 = paddle.logsumexp(x) # [3.4691226]
out2 = paddle.logsumexp(x, 1) # [2.15317821, 3.15684602]
out2 = paddle.logsumexp(x, 1) # [2.15317821, 3.15684602]
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录