Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Crayon鑫
Paddle
提交
0a7bab4e
P
Paddle
项目概览
Crayon鑫
/
Paddle
与 Fork 源项目一致
Fork自
PaddlePaddle / Paddle
通知
1
Star
1
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
1
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
P
Paddle
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
1
Issue
1
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
未验证
提交
0a7bab4e
编写于
10月 09, 2020
作者:
F
Feiyu Chan
提交者:
GitHub
10月 09, 2020
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fix error mesage for negative_positive_pair_op and nce_op (#27779)
上级
395cb561
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
52 addition
and
41 deletion
+52
-41
paddle/fluid/operators/nce_op.h
paddle/fluid/operators/nce_op.h
+43
-34
paddle/fluid/operators/positive_negative_pair_op.cc
paddle/fluid/operators/positive_negative_pair_op.cc
+9
-7
未找到文件。
paddle/fluid/operators/nce_op.h
浏览文件 @
0a7bab4e
...
...
@@ -104,25 +104,29 @@ class NCEKernel : public framework::OpKernel<T> {
PADDLE_ENFORCE_EQ
(
dist_probs
->
numel
(),
num_total_classes
,
"ShapeError: The number of elements in Input(CustomDistProbs) "
"should be equal to the number of total classes. But Received: "
"Input(CustomDistProbs).numel() = %d, Attr(num_total_classes) "
"= %d."
,
dist_probs
->
numel
(),
num_total_classes
);
platform
::
errors
::
InvalidArgument
(
"ShapeError: The number of elements in Input(CustomDistProbs) "
"should be equal to the number of total classes. But Received: "
"Input(CustomDistProbs).numel() = %d, Attr(num_total_classes) "
"= %d."
,
dist_probs
->
numel
(),
num_total_classes
));
PADDLE_ENFORCE_EQ
(
dist_alias
->
numel
(),
num_total_classes
,
"ShapeError: The number of elements in Input(CustomDistAlias) "
"should be equal to the number of total classes. But Received: "
"Input(CustomDistAlias).numel() = %d, Attr(num_total_classes) "
"= %d."
,
dist_alias
->
numel
(),
num_total_classes
);
platform
::
errors
::
InvalidArgument
(
"ShapeError: The number of elements in Input(CustomDistAlias) "
"should be equal to the number of total classes. But Received: "
"Input(CustomDistAlias).numel() = %d, Attr(num_total_classes) "
"= %d."
,
dist_alias
->
numel
(),
num_total_classes
));
PADDLE_ENFORCE_EQ
(
dist_alias_probs
->
numel
(),
num_total_classes
,
"ShapeError: The number of elements in Input(CustomDistAliasProbs) "
"should be equal to the number of total classes. But Received: "
"Input(CustomDistAliasProbs).numel() = %d, "
"Attr(num_total_classes) = %d."
,
dist_alias_probs
->
numel
(),
num_total_classes
);
platform
::
errors
::
InvalidArgument
(
"ShapeError: The number of elements in "
"Input(CustomDistAliasProbs) "
"should be equal to the number of total classes. But Received: "
"Input(CustomDistAliasProbs).numel() = %d, "
"Attr(num_total_classes) = %d."
,
dist_alias_probs
->
numel
(),
num_total_classes
));
const
float
*
probs_data
=
dist_probs
->
data
<
float
>
();
const
int
*
alias_data
=
dist_alias
->
data
<
int
>
();
...
...
@@ -140,10 +144,11 @@ class NCEKernel : public framework::OpKernel<T> {
for
(
int
x
=
0
;
x
<
sample_labels
->
numel
();
x
++
)
{
PADDLE_ENFORCE_GE
(
sample_labels_data
[
x
],
0
,
"ValueError: Every sample label should be "
"non-negative. But received: "
"Input(SampleLabels)[%d] = %d"
,
x
,
sample_labels_data
[
x
]);
platform
::
errors
::
InvalidArgument
(
"ValueError: Every sample label should be "
"non-negative. But received: "
"Input(SampleLabels)[%d] = %d"
,
x
,
sample_labels_data
[
x
]));
}
auto
sample_out
=
context
.
Output
<
Tensor
>
(
"SampleLogits"
);
...
...
@@ -311,25 +316,29 @@ class NCEGradKernel : public framework::OpKernel<T> {
PADDLE_ENFORCE_EQ
(
dist_probs
->
numel
(),
num_total_classes
,
"ShapeError: The number of elements in Input(CustomDistProbs) "
"should be equal to the number of total classes. But Received: "
"Input(CustomDistProbs).numel() = %d, Attr(num_total_classes) "
"= %d."
,
dist_probs
->
numel
(),
num_total_classes
);
platform
::
errors
::
InvalidArgument
(
"ShapeError: The number of elements in Input(CustomDistProbs) "
"should be equal to the number of total classes. But Received: "
"Input(CustomDistProbs).numel() = %d, Attr(num_total_classes) "
"= %d."
,
dist_probs
->
numel
(),
num_total_classes
));
PADDLE_ENFORCE_EQ
(
dist_alias
->
numel
(),
num_total_classes
,
"ShapeError: The number of elements in Input(CustomDistAlias) "
"should be equal to the number of total classes. But Received: "
"Input(CustomDistAlias).numel() = %d, Attr(num_total_classes) "
"= %d."
,
dist_alias
->
numel
(),
num_total_classes
);
platform
::
errors
::
InvalidArgument
(
"ShapeError: The number of elements in Input(CustomDistAlias) "
"should be equal to the number of total classes. But Received: "
"Input(CustomDistAlias).numel() = %d, Attr(num_total_classes) "
"= %d."
,
dist_alias
->
numel
(),
num_total_classes
));
PADDLE_ENFORCE_EQ
(
dist_alias_probs
->
numel
(),
num_total_classes
,
"ShapeError: The number of elements in Input(CustomDistAliasProbs) "
"should be equal to the number of total classes. But Received: "
"Input(CustomDistAliasProbs).numel() = %d, "
"Attr(num_total_classes) = %d."
,
dist_alias_probs
->
numel
(),
num_total_classes
);
platform
::
errors
::
InvalidArgument
(
"ShapeError: The number of elements in "
"Input(CustomDistAliasProbs) "
"should be equal to the number of total classes. But Received: "
"Input(CustomDistAliasProbs).numel() = %d, "
"Attr(num_total_classes) = %d."
,
dist_alias_probs
->
numel
(),
num_total_classes
));
const
float
*
probs_data
=
dist_probs
->
data
<
float
>
();
const
int
*
alias_data
=
dist_alias
->
data
<
int
>
();
...
...
paddle/fluid/operators/positive_negative_pair_op.cc
浏览文件 @
0a7bab4e
...
...
@@ -37,13 +37,15 @@ class PositiveNegativePairOp : public framework::OperatorWithKernel {
if
(
ctx
->
HasInput
(
"AccumulatePositivePair"
)
||
ctx
->
HasInput
(
"AccumulateNegativePair"
)
||
ctx
->
HasInput
(
"AccumulateNeutralPair"
))
{
PADDLE_ENFORCE
(
ctx
->
HasInput
(
"AccumulatePositivePair"
)
&&
ctx
->
HasInput
(
"AccumulateNegativePair"
)
&&
ctx
->
HasInput
(
"AccumulateNeutralPair"
),
"All optional inputs(AccumulatePositivePair, "
"AccumulateNegativePair, AccumulateNeutralPair) of "
"PositiveNegativePairOp are required if one of them is "
"specified."
);
PADDLE_ENFORCE_EQ
(
ctx
->
HasInput
(
"AccumulatePositivePair"
)
&&
ctx
->
HasInput
(
"AccumulateNegativePair"
)
&&
ctx
->
HasInput
(
"AccumulateNeutralPair"
),
true
,
platform
::
errors
::
InvalidArgument
(
"All optional inputs(AccumulatePositivePair, "
"AccumulateNegativePair, AccumulateNeutralPair) of "
"PositiveNegativePairOp are required if one of them "
"is specified."
));
PADDLE_ENFORCE_EQ
(
ctx
->
GetInputDim
(
"AccumulatePositivePair"
),
scalar_dim
,
platform
::
errors
::
InvalidArgument
(
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录