Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
Paddle
提交
4c01d6d5
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,发现更多精彩内容 >>
未验证
提交
4c01d6d5
编写于
6月 05, 2020
作者:
W
whs
提交者:
GitHub
6月 05, 2020
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Enhance checking in some operator. (#24473)
上级
4a702ef3
变更
10
隐藏空白更改
内联
并排
Showing
10 changed file
with
269 addition
and
113 deletion
+269
-113
paddle/fluid/operators/affine_grid_op.cc
paddle/fluid/operators/affine_grid_op.cc
+43
-15
paddle/fluid/operators/detection/generate_proposal_labels_op.cc
.../fluid/operators/detection/generate_proposal_labels_op.cc
+72
-35
paddle/fluid/operators/detection/generate_proposals_op.cc
paddle/fluid/operators/detection/generate_proposals_op.cc
+15
-9
paddle/fluid/operators/detection/generate_proposals_op.cu
paddle/fluid/operators/detection/generate_proposals_op.cu
+5
-1
paddle/fluid/operators/detection/rpn_target_assign_op.cc
paddle/fluid/operators/detection/rpn_target_assign_op.cc
+53
-31
paddle/fluid/operators/im2sequence_op.cc
paddle/fluid/operators/im2sequence_op.cc
+19
-9
paddle/fluid/operators/label_smooth_op.cc
paddle/fluid/operators/label_smooth_op.cc
+14
-8
python/paddle/fluid/layers/detection.py
python/paddle/fluid/layers/detection.py
+35
-1
python/paddle/fluid/layers/nn.py
python/paddle/fluid/layers/nn.py
+12
-2
python/paddle/fluid/tests/unittests/test_layers.py
python/paddle/fluid/tests/unittests/test_layers.py
+1
-2
未找到文件。
paddle/fluid/operators/affine_grid_op.cc
浏览文件 @
4c01d6d5
...
@@ -42,29 +42,57 @@ class AffineGridOp : public framework::OperatorWithKernel {
...
@@ -42,29 +42,57 @@ class AffineGridOp : public framework::OperatorWithKernel {
public:
public:
using
framework
::
OperatorWithKernel
::
OperatorWithKernel
;
using
framework
::
OperatorWithKernel
::
OperatorWithKernel
;
void
InferShape
(
framework
::
InferShapeContext
*
ctx
)
const
override
{
void
InferShape
(
framework
::
InferShapeContext
*
ctx
)
const
override
{
PADDLE_ENFORCE
(
ctx
->
HasInput
(
"Theta"
),
PADDLE_ENFORCE_EQ
(
ctx
->
HasInput
(
"Theta"
),
true
,
"Input(Theta) of AffineGridOp should not be null."
);
platform
::
errors
::
NotFound
(
PADDLE_ENFORCE
(
ctx
->
HasOutput
(
"Output"
),
"The input 'Theta' of AffineGridOp is not found."
));
"Output(Output) of AffineGridOp should not be null."
);
PADDLE_ENFORCE_EQ
(
ctx
->
HasOutput
(
"Output"
),
true
,
platform
::
errors
::
NotFound
(
"The output 'Output' of AffineGridOp is not found."
));
auto
theta_dims
=
ctx
->
GetInputDim
(
"Theta"
);
auto
theta_dims
=
ctx
->
GetInputDim
(
"Theta"
);
PADDLE_ENFORCE
(
theta_dims
.
size
()
==
3
,
PADDLE_ENFORCE_EQ
(
"AffineGrid's Input(Theta) should be 3-D tensor."
);
theta_dims
.
size
(),
3
,
platform
::
errors
::
InvalidArgument
(
"The input Theta's dimensions size should be 3. But received "
"Theta's demensions size=[%d], Theta's dimensions=[%s]."
,
theta_dims
.
size
(),
theta_dims
));
auto
output_shape
=
ctx
->
Attrs
().
Get
<
std
::
vector
<
int
>>
(
"output_shape"
);
auto
output_shape
=
ctx
->
Attrs
().
Get
<
std
::
vector
<
int
>>
(
"output_shape"
);
if
(
output_shape
.
size
()
==
0
)
{
if
(
output_shape
.
size
()
==
0
)
{
PADDLE_ENFORCE
(
ctx
->
HasInput
(
"OutputShape"
),
PADDLE_ENFORCE_EQ
(
"Input(OutputShape) of AffineGridOp should not be null if "
ctx
->
HasInput
(
"OutputShape"
),
true
,
"attr(output_shape) is not configured."
);
platform
::
errors
::
NotFound
(
"The input 'OutputShape' of AffineGridOp should not be null if "
"'output_shape' is not configured."
));
auto
output_shape_dims
=
ctx
->
GetInputDim
(
"OutputShape"
);
auto
output_shape_dims
=
ctx
->
GetInputDim
(
"OutputShape"
);
PADDLE_ENFORCE
(
output_shape_dims
.
size
()
==
1
,
PADDLE_ENFORCE_EQ
(
"AffineGrid's Input(OutputShape) should be 1-D tensor."
);
output_shape_dims
.
size
(),
1
,
platform
::
errors
::
InvalidArgument
(
"The dimesions size of input OutputShape in AffineGridOp should "
"be 1. But received OutputShape's dimesions size=[%d], "
"OutputShape's dimesions=[%s]"
,
output_shape_dims
.
size
(),
output_shape_dims
));
}
else
{
}
else
{
PADDLE_ENFORCE
(
output_shape
.
size
()
==
4
,
PADDLE_ENFORCE_EQ
(
"The size of attr(output_shape) should be 4."
);
output_shape
.
size
(),
4
,
platform
::
errors
::
InvalidArgument
(
"The size of attribute 'output_shape' in AffineGridOp should be "
"4. But received output_shape's size=[%d]."
,
output_shape
.
size
()));
}
}
PADDLE_ENFORCE
(
theta_dims
[
1
]
==
2
,
"Input(theta) dims[1] should be 2."
);
PADDLE_ENFORCE_EQ
(
PADDLE_ENFORCE
(
theta_dims
[
2
]
==
3
,
"Input(theta) dims[2] should be 3."
);
theta_dims
[
1
],
2
,
platform
::
errors
::
InvalidArgument
(
"The second dimesion of input 'theta' in AffineGridOp should be 2. "
"But received second dimesion=[%d], dimesions=[%s]"
,
theta_dims
[
1
],
theta_dims
));
PADDLE_ENFORCE_EQ
(
theta_dims
[
2
],
3
,
platform
::
errors
::
InvalidArgument
(
"The third dimesion of input 'theta' in AffineGridOp should be 3. "
"But received third dimesion=[%d], dimesions=[%s]"
,
theta_dims
[
2
],
theta_dims
));
// N * H * W * 2
// N * H * W * 2
ctx
->
SetOutputDim
(
"Output"
,
ctx
->
SetOutputDim
(
"Output"
,
framework
::
make_ddim
({
theta_dims
[
0
],
-
1
,
-
1
,
2
}));
framework
::
make_ddim
({
theta_dims
[
0
],
-
1
,
-
1
,
2
}));
...
...
paddle/fluid/operators/detection/generate_proposal_labels_op.cc
浏览文件 @
4c01d6d5
...
@@ -38,42 +38,64 @@ class GenerateProposalLabelsOp : public framework::OperatorWithKernel {
...
@@ -38,42 +38,64 @@ class GenerateProposalLabelsOp : public framework::OperatorWithKernel {
using
framework
::
OperatorWithKernel
::
OperatorWithKernel
;
using
framework
::
OperatorWithKernel
::
OperatorWithKernel
;
void
InferShape
(
framework
::
InferShapeContext
*
ctx
)
const
override
{
void
InferShape
(
framework
::
InferShapeContext
*
ctx
)
const
override
{
PADDLE_ENFORCE
(
ctx
->
HasInput
(
"RpnRois"
),
PADDLE_ENFORCE_EQ
(
"Input(RpnRois) shouldn't be null."
);
ctx
->
HasInput
(
"RpnRois"
),
true
,
PADDLE_ENFORCE
(
ctx
->
HasInput
(
"GtClasses"
),
platform
::
errors
::
NotFound
(
"Input(RpnRois) shouldn't be null."
));
"Input(GtClasses) shouldn't be null."
);
PADDLE_ENFORCE_EQ
(
PADDLE_ENFORCE
(
ctx
->
HasInput
(
"IsCrowd"
),
ctx
->
HasInput
(
"GtClasses"
),
true
,
"Input(IsCrowd) shouldn't be null."
);
platform
::
errors
::
NotFound
(
"Input(GtClasses) shouldn't be null."
));
PADDLE_ENFORCE
(
ctx
->
HasInput
(
"GtBoxes"
),
PADDLE_ENFORCE_EQ
(
"Input(GtBoxes) shouldn't be null."
);
ctx
->
HasInput
(
"IsCrowd"
),
true
,
PADDLE_ENFORCE
(
ctx
->
HasInput
(
"ImInfo"
),
"Input(ImInfo) shouldn't be null."
);
platform
::
errors
::
NotFound
(
"Input(IsCrowd) shouldn't be null."
));
PADDLE_ENFORCE_EQ
(
PADDLE_ENFORCE
(
ctx
->
HasInput
(
"GtBoxes"
),
true
,
ctx
->
HasOutput
(
"Rois"
),
platform
::
errors
::
NotFound
(
"Input(GtBoxes) shouldn't be null."
));
"Output(Rois) of GenerateProposalLabelsOp should not be null"
);
PADDLE_ENFORCE_EQ
(
PADDLE_ENFORCE
(
ctx
->
HasInput
(
"ImInfo"
),
true
,
ctx
->
HasOutput
(
"LabelsInt32"
),
platform
::
errors
::
NotFound
(
"Input(ImInfo) shouldn't be null."
));
"Output(LabelsInt32) of GenerateProposalLabelsOp should not be null"
);
PADDLE_ENFORCE
(
PADDLE_ENFORCE_EQ
(
ctx
->
HasOutput
(
"BboxTargets"
),
ctx
->
HasOutput
(
"Rois"
),
true
,
"Output(BboxTargets) of GenerateProposalLabelsOp should not be null"
);
platform
::
errors
::
NotFound
(
PADDLE_ENFORCE
(
ctx
->
HasOutput
(
"BboxInsideWeights"
),
"Output(Rois) of GenerateProposalLabelsOp should not be null"
));
"Output(BboxInsideWeights) of GenerateProposalLabelsOp "
PADDLE_ENFORCE_EQ
(
ctx
->
HasOutput
(
"LabelsInt32"
),
true
,
"should not be null"
);
platform
::
errors
::
NotFound
(
"Output(LabelsInt32) of "
PADDLE_ENFORCE
(
ctx
->
HasOutput
(
"BboxOutsideWeights"
),
"GenerateProposalLabelsOp "
"Output(BboxOutsideWeights) of GenerateProposalLabelsOp "
"should not be null"
));
"should not be null"
);
PADDLE_ENFORCE_EQ
(
ctx
->
HasOutput
(
"BboxTargets"
),
true
,
platform
::
errors
::
NotFound
(
"Output(BboxTargets) of "
"GenerateProposalLabelsOp "
"should not be null"
));
PADDLE_ENFORCE_EQ
(
ctx
->
HasOutput
(
"BboxInsideWeights"
),
true
,
platform
::
errors
::
NotFound
(
"Output(BboxInsideWeights) of GenerateProposalLabelsOp "
"should not be null"
));
PADDLE_ENFORCE_EQ
(
ctx
->
HasOutput
(
"BboxOutsideWeights"
),
true
,
platform
::
errors
::
NotFound
(
"Output(BboxOutsideWeights) of GenerateProposalLabelsOp "
"should not be null"
));
auto
rpn_rois_dims
=
ctx
->
GetInputDim
(
"RpnRois"
);
auto
rpn_rois_dims
=
ctx
->
GetInputDim
(
"RpnRois"
);
auto
gt_boxes_dims
=
ctx
->
GetInputDim
(
"GtBoxes"
);
auto
gt_boxes_dims
=
ctx
->
GetInputDim
(
"GtBoxes"
);
auto
im_info_dims
=
ctx
->
GetInputDim
(
"ImInfo"
);
auto
im_info_dims
=
ctx
->
GetInputDim
(
"ImInfo"
);
PADDLE_ENFORCE_EQ
(
rpn_rois_dims
.
size
(),
2
,
PADDLE_ENFORCE_EQ
(
rpn_rois_dims
.
size
(),
2
,
"The rank of Input(RpnRois) must be 2."
);
platform
::
errors
::
InvalidArgument
(
"The dimensions size of Input(RpnRois) must be 2. "
"But received dimensions size=[%d], dimensions=[%s]."
,
rpn_rois_dims
.
size
(),
rpn_rois_dims
));
PADDLE_ENFORCE_EQ
(
gt_boxes_dims
.
size
(),
2
,
PADDLE_ENFORCE_EQ
(
gt_boxes_dims
.
size
(),
2
,
"The rank of Input(GtBoxes) must be 2."
);
platform
::
errors
::
InvalidArgument
(
"The dimensions size of Input(GtBoxes) must be 2. "
"But received dimensions size=[%d], dimensions=[%s]."
,
gt_boxes_dims
.
size
(),
gt_boxes_dims
));
PADDLE_ENFORCE_EQ
(
im_info_dims
.
size
(),
2
,
PADDLE_ENFORCE_EQ
(
im_info_dims
.
size
(),
2
,
"The rank of Input(ImInfo) must be 2."
);
platform
::
errors
::
InvalidArgument
(
"The dimensions size of Input(ImInfo) must be 2. But "
"received dimensions size=[%d], dimensions=[%s]."
,
im_info_dims
.
size
(),
im_info_dims
));
int
class_nums
=
ctx
->
Attrs
().
Get
<
int
>
(
"class_nums"
);
int
class_nums
=
ctx
->
Attrs
().
Get
<
int
>
(
"class_nums"
);
...
@@ -399,15 +421,30 @@ class GenerateProposalLabelsKernel : public framework::OpKernel<T> {
...
@@ -399,15 +421,30 @@ class GenerateProposalLabelsKernel : public framework::OpKernel<T> {
bool
use_random
=
context
.
Attr
<
bool
>
(
"use_random"
);
bool
use_random
=
context
.
Attr
<
bool
>
(
"use_random"
);
bool
is_cascade_rcnn
=
context
.
Attr
<
bool
>
(
"is_cascade_rcnn"
);
bool
is_cascade_rcnn
=
context
.
Attr
<
bool
>
(
"is_cascade_rcnn"
);
bool
is_cls_agnostic
=
context
.
Attr
<
bool
>
(
"is_cls_agnostic"
);
bool
is_cls_agnostic
=
context
.
Attr
<
bool
>
(
"is_cls_agnostic"
);
PADDLE_ENFORCE_EQ
(
rpn_rois
->
lod
().
size
(),
1UL
,
PADDLE_ENFORCE_EQ
(
"GenerateProposalLabelsOp rpn_rois needs 1 level of LoD"
);
rpn_rois
->
lod
().
size
(),
1UL
,
platform
::
errors
::
InvalidArgument
(
"GenerateProposalLabelsOp rpn_rois needs 1 level of LoD. But "
"received level of LoD is [%d], LoD is [%s]."
,
rpn_rois
->
lod
().
size
(),
rpn_rois
->
lod
()));
PADDLE_ENFORCE_EQ
(
PADDLE_ENFORCE_EQ
(
gt_classes
->
lod
().
size
(),
1UL
,
gt_classes
->
lod
().
size
(),
1UL
,
"GenerateProposalLabelsOp gt_classes needs 1 level of LoD"
);
platform
::
errors
::
InvalidArgument
(
PADDLE_ENFORCE_EQ
(
is_crowd
->
lod
().
size
(),
1UL
,
"GenerateProposalLabelsOp gt_classes needs 1 level of LoD. But "
"GenerateProposalLabelsOp is_crowd needs 1 level of LoD"
);
"received level of LoD is [%d], LoD is [%s]."
,
PADDLE_ENFORCE_EQ
(
gt_boxes
->
lod
().
size
(),
1UL
,
gt_classes
->
lod
().
size
(),
gt_classes
->
lod
()));
"GenerateProposalLabelsOp gt_boxes needs 1 level of LoD"
);
PADDLE_ENFORCE_EQ
(
is_crowd
->
lod
().
size
(),
1UL
,
platform
::
errors
::
InvalidArgument
(
"GenerateProposalLabelsOp is_crowd needs 1 level of LoD. But "
"received level of LoD is [%d], LoD is [%s]."
,
is_crowd
->
lod
().
size
(),
is_crowd
->
lod
()));
PADDLE_ENFORCE_EQ
(
gt_boxes
->
lod
().
size
(),
1UL
,
platform
::
errors
::
InvalidArgument
(
"GenerateProposalLabelsOp gt_boxes needs 1 level of LoD. But "
"received level of LoD is [%d], LoD is [%s]."
,
gt_boxes
->
lod
().
size
(),
gt_boxes
->
lod
()));
int64_t
n
=
static_cast
<
int64_t
>
(
rpn_rois
->
lod
().
back
().
size
()
-
1
);
int64_t
n
=
static_cast
<
int64_t
>
(
rpn_rois
->
lod
().
back
().
size
()
-
1
);
rois
->
mutable_data
<
T
>
({
n
*
batch_size_per_im
,
kBoxDim
},
context
.
GetPlace
());
rois
->
mutable_data
<
T
>
({
n
*
batch_size_per_im
,
kBoxDim
},
context
.
GetPlace
());
...
...
paddle/fluid/operators/detection/generate_proposals_op.cc
浏览文件 @
4c01d6d5
...
@@ -43,14 +43,21 @@ class GenerateProposalsOp : public framework::OperatorWithKernel {
...
@@ -43,14 +43,21 @@ class GenerateProposalsOp : public framework::OperatorWithKernel {
using
framework
::
OperatorWithKernel
::
OperatorWithKernel
;
using
framework
::
OperatorWithKernel
::
OperatorWithKernel
;
void
InferShape
(
framework
::
InferShapeContext
*
ctx
)
const
override
{
void
InferShape
(
framework
::
InferShapeContext
*
ctx
)
const
override
{
PADDLE_ENFORCE
(
ctx
->
HasInput
(
"Scores"
),
"Input(Scores) shouldn't be null."
);
PADDLE_ENFORCE_EQ
(
PADDLE_ENFORCE
(
ctx
->
HasInput
(
"BboxDeltas"
),
ctx
->
HasInput
(
"Scores"
),
true
,
"Input(BboxDeltas) shouldn't be null."
);
platform
::
errors
::
NotFound
(
"Input(Scores) shouldn't be null."
));
PADDLE_ENFORCE
(
ctx
->
HasInput
(
"ImInfo"
),
"Input(ImInfo) shouldn't be null."
);
PADDLE_ENFORCE_EQ
(
PADDLE_ENFORCE
(
ctx
->
HasInput
(
"Anchors"
),
ctx
->
HasInput
(
"BboxDeltas"
),
true
,
"Input(Anchors) shouldn't be null."
);
platform
::
errors
::
NotFound
(
"Input(BboxDeltas) shouldn't be null."
));
PADDLE_ENFORCE
(
ctx
->
HasInput
(
"Variances"
),
PADDLE_ENFORCE_EQ
(
"Input(Variances) shouldn't be null."
);
ctx
->
HasInput
(
"ImInfo"
),
true
,
platform
::
errors
::
NotFound
(
"Input(ImInfo) shouldn't be null."
));
PADDLE_ENFORCE_EQ
(
ctx
->
HasInput
(
"Anchors"
),
true
,
platform
::
errors
::
NotFound
(
"Input(Anchors) shouldn't be null."
));
PADDLE_ENFORCE_EQ
(
ctx
->
HasInput
(
"Variances"
),
true
,
platform
::
errors
::
NotFound
(
"Input(Variances) shouldn't be null."
));
ctx
->
SetOutputDim
(
"RpnRois"
,
{
-
1
,
4
});
ctx
->
SetOutputDim
(
"RpnRois"
,
{
-
1
,
4
});
ctx
->
SetOutputDim
(
"RpnRoiProbs"
,
{
-
1
,
1
});
ctx
->
SetOutputDim
(
"RpnRoiProbs"
,
{
-
1
,
1
});
...
@@ -247,7 +254,6 @@ static inline Tensor VectorToTensor(const std::vector<T> &selected_indices,
...
@@ -247,7 +254,6 @@ static inline Tensor VectorToTensor(const std::vector<T> &selected_indices,
template
<
class
T
>
template
<
class
T
>
static
inline
Tensor
NMS
(
const
platform
::
DeviceContext
&
ctx
,
Tensor
*
bbox
,
static
inline
Tensor
NMS
(
const
platform
::
DeviceContext
&
ctx
,
Tensor
*
bbox
,
Tensor
*
scores
,
T
nms_threshold
,
float
eta
)
{
Tensor
*
scores
,
T
nms_threshold
,
float
eta
)
{
PADDLE_ENFORCE_NOT_NULL
(
bbox
);
int64_t
num_boxes
=
bbox
->
dims
()[
0
];
int64_t
num_boxes
=
bbox
->
dims
()[
0
];
// 4: [xmin ymin xmax ymax]
// 4: [xmin ymin xmax ymax]
int64_t
box_size
=
bbox
->
dims
()[
1
];
int64_t
box_size
=
bbox
->
dims
()[
1
];
...
...
paddle/fluid/operators/detection/generate_proposals_op.cu
浏览文件 @
4c01d6d5
...
@@ -379,7 +379,11 @@ class CUDAGenerateProposalsKernel : public framework::OpKernel<T> {
...
@@ -379,7 +379,11 @@ class CUDAGenerateProposalsKernel : public framework::OpKernel<T> {
float
nms_thresh
=
context
.
Attr
<
float
>
(
"nms_thresh"
);
float
nms_thresh
=
context
.
Attr
<
float
>
(
"nms_thresh"
);
float
min_size
=
context
.
Attr
<
float
>
(
"min_size"
);
float
min_size
=
context
.
Attr
<
float
>
(
"min_size"
);
float
eta
=
context
.
Attr
<
float
>
(
"eta"
);
float
eta
=
context
.
Attr
<
float
>
(
"eta"
);
PADDLE_ENFORCE_GE
(
eta
,
1.
,
"Not support adaptive NMS."
);
PADDLE_ENFORCE_GE
(
eta
,
1.
,
platform
::
errors
::
InvalidArgument
(
"Not support adaptive NMS. The attribute 'eta' "
"should not less than 1. But received eta=[%d]"
,
eta
));
auto
&
dev_ctx
=
context
.
template
device_context
<
DeviceContext
>();
auto
&
dev_ctx
=
context
.
template
device_context
<
DeviceContext
>();
...
...
paddle/fluid/operators/detection/rpn_target_assign_op.cc
浏览文件 @
4c01d6d5
...
@@ -31,40 +31,44 @@ class RpnTargetAssignOp : public framework::OperatorWithKernel {
...
@@ -31,40 +31,44 @@ class RpnTargetAssignOp : public framework::OperatorWithKernel {
using
framework
::
OperatorWithKernel
::
OperatorWithKernel
;
using
framework
::
OperatorWithKernel
::
OperatorWithKernel
;
void
InferShape
(
framework
::
InferShapeContext
*
ctx
)
const
override
{
void
InferShape
(
framework
::
InferShapeContext
*
ctx
)
const
override
{
PADDLE_ENFORCE
(
ctx
->
HasInput
(
"Anchor"
),
OP_INOUT_CHECK
(
ctx
->
HasInput
(
"Anchor"
),
"Input"
,
"Anchor"
,
"Input(Anchor) of RpnTargetAssignOp should not be null"
);
"rpn_target_assign"
);
PADDLE_ENFORCE
(
ctx
->
HasInput
(
"GtBoxes"
),
OP_INOUT_CHECK
(
ctx
->
HasInput
(
"GtBoxes"
),
"Input"
,
"GtBoxes"
,
"Input(GtBoxes) of RpnTargetAssignOp should not be null"
);
"rpn_target_assign"
);
PADDLE_ENFORCE
(
ctx
->
HasInput
(
"IsCrowd"
),
OP_INOUT_CHECK
(
ctx
->
HasInput
(
"IsCrowd"
),
"Input"
,
"IsCrowd"
,
"Input(Anchor) of RpnTargetAssignOp should not be null"
);
"rpn_target_assign"
);
PADDLE_ENFORCE
(
ctx
->
HasInput
(
"ImInfo"
),
OP_INOUT_CHECK
(
ctx
->
HasInput
(
"ImInfo"
),
"Input"
,
"ImInfo"
,
"Input(ImInfo) of RpnTargetAssignOp should not be null"
);
"rpn_target_assign"
);
PADDLE_ENFORCE
(
OP_INOUT_CHECK
(
ctx
->
HasOutput
(
"LocationIndex"
),
"Output"
,
"LocationIndex"
,
ctx
->
HasOutput
(
"LocationIndex"
),
"rpn_target_assign"
);
"Output(LocationIndex) of RpnTargetAssignOp should not be null"
);
OP_INOUT_CHECK
(
ctx
->
HasOutput
(
"ScoreIndex"
),
"Output"
,
"ScoreIndex"
,
PADDLE_ENFORCE
(
"rpn_target_assign"
);
ctx
->
HasOutput
(
"ScoreIndex"
),
OP_INOUT_CHECK
(
ctx
->
HasOutput
(
"TargetLabel"
),
"Output"
,
"TargetLabel"
,
"Output(ScoreIndex) of RpnTargetAssignOp should not be null"
);
"rpn_target_assign"
);
PADDLE_ENFORCE
(
OP_INOUT_CHECK
(
ctx
->
HasOutput
(
"TargetBBox"
),
"Output"
,
"TargetBBox"
,
ctx
->
HasOutput
(
"TargetLabel"
),
"rpn_target_assign"
);
"Output(TargetLabel) of RpnTargetAssignOp should not be null"
);
OP_INOUT_CHECK
(
ctx
->
HasOutput
(
"BBoxInsideWeight"
),
"Output"
,
PADDLE_ENFORCE
(
"BBoxInsideWeight"
,
"rpn_target_assign"
);
ctx
->
HasOutput
(
"TargetBBox"
),
"Output(TargetBBox) of RpnTargetAssignOp should not be null"
);
PADDLE_ENFORCE
(
ctx
->
HasOutput
(
"BBoxInsideWeight"
),
"Output(BBoxInsideWeight) of RpnTargetAssignOp should not be null"
);
auto
anchor_dims
=
ctx
->
GetInputDim
(
"Anchor"
);
auto
anchor_dims
=
ctx
->
GetInputDim
(
"Anchor"
);
auto
gt_boxes_dims
=
ctx
->
GetInputDim
(
"GtBoxes"
);
auto
gt_boxes_dims
=
ctx
->
GetInputDim
(
"GtBoxes"
);
auto
im_info_dims
=
ctx
->
GetInputDim
(
"ImInfo"
);
auto
im_info_dims
=
ctx
->
GetInputDim
(
"ImInfo"
);
PADDLE_ENFORCE_EQ
(
anchor_dims
.
size
(),
2
,
PADDLE_ENFORCE_EQ
(
anchor_dims
.
size
(),
2
,
"The rank of Input(Anchor) must be 2."
);
platform
::
errors
::
InvalidArgument
(
"The dimensions size of Input(Anchor) must be 2. But "
"received dimensions size=[%d], dimensions=[%s]."
,
anchor_dims
.
size
(),
anchor_dims
));
PADDLE_ENFORCE_EQ
(
gt_boxes_dims
.
size
(),
2
,
PADDLE_ENFORCE_EQ
(
gt_boxes_dims
.
size
(),
2
,
"The rank of Input(GtBoxes) must be 2."
);
platform
::
errors
::
InvalidArgument
(
"The dimensions size of Input(GtBoxes) must be 2. "
"But received dimensions size=[%d], dimensions=[%s]."
,
gt_boxes_dims
.
size
(),
gt_boxes_dims
));
PADDLE_ENFORCE_EQ
(
im_info_dims
.
size
(),
2
,
PADDLE_ENFORCE_EQ
(
im_info_dims
.
size
(),
2
,
"The rank of Input(ImInfo) must be 2."
);
platform
::
errors
::
InvalidArgument
(
"The dimensions size of Input(ImInfo) must be 2. But "
"received dimensions size=[%d], dimensions=[%s]."
,
im_info_dims
.
size
(),
im_info_dims
));
ctx
->
SetOutputDim
(
"LocationIndex"
,
{
-
1
});
ctx
->
SetOutputDim
(
"LocationIndex"
,
{
-
1
});
ctx
->
SetOutputDim
(
"ScoreIndex"
,
{
-
1
});
ctx
->
SetOutputDim
(
"ScoreIndex"
,
{
-
1
});
...
@@ -357,9 +361,15 @@ class RpnTargetAssignKernel : public framework::OpKernel<T> {
...
@@ -357,9 +361,15 @@ class RpnTargetAssignKernel : public framework::OpKernel<T> {
auto
*
bbox_inside_weight
=
context
.
Output
<
LoDTensor
>
(
"BBoxInsideWeight"
);
auto
*
bbox_inside_weight
=
context
.
Output
<
LoDTensor
>
(
"BBoxInsideWeight"
);
PADDLE_ENFORCE_EQ
(
gt_boxes
->
lod
().
size
(),
1UL
,
PADDLE_ENFORCE_EQ
(
gt_boxes
->
lod
().
size
(),
1UL
,
"RpnTargetAssignOp gt_boxes needs 1 level of LoD"
);
platform
::
errors
::
InvalidArgument
(
"RpnTargetAssignOp gt_boxes needs 1 level of LoD. "
"But received level of LoD is [%d], LoD is [%s]."
,
gt_boxes
->
lod
().
size
(),
gt_boxes
->
lod
()));
PADDLE_ENFORCE_EQ
(
is_crowd
->
lod
().
size
(),
1UL
,
PADDLE_ENFORCE_EQ
(
is_crowd
->
lod
().
size
(),
1UL
,
"RpnTargetAssignOp is_crowd needs 1 level of LoD"
);
platform
::
errors
::
InvalidArgument
(
"RpnTargetAssignOp is_crowd needs 1 level of LoD. "
"But received level of LoD is [%d], LoD is [%s]."
,
is_crowd
->
lod
().
size
(),
is_crowd
->
lod
()));
int64_t
anchor_num
=
static_cast
<
int64_t
>
(
anchor
->
dims
()[
0
]);
int64_t
anchor_num
=
static_cast
<
int64_t
>
(
anchor
->
dims
()[
0
]);
int64_t
batch_num
=
static_cast
<
int64_t
>
(
gt_boxes
->
lod
().
back
().
size
()
-
1
);
int64_t
batch_num
=
static_cast
<
int64_t
>
(
gt_boxes
->
lod
().
back
().
size
()
-
1
);
...
@@ -479,8 +489,20 @@ class RpnTargetAssignKernel : public framework::OpKernel<T> {
...
@@ -479,8 +489,20 @@ class RpnTargetAssignKernel : public framework::OpKernel<T> {
lod0_score
.
emplace_back
(
total_score_num
);
lod0_score
.
emplace_back
(
total_score_num
);
}
}
PADDLE_ENFORCE_LE
(
total_loc_num
,
max_num
);
PADDLE_ENFORCE_LE
(
PADDLE_ENFORCE_LE
(
total_score_num
,
max_num
);
total_loc_num
,
max_num
,
platform
::
errors
::
InvalidArgument
(
"The number of sampled bboxes should not be greater than the "
"number of all anchor boxes(%d), but the number of sampled "
"bboxes is :%d."
,
max_num
,
total_loc_num
));
PADDLE_ENFORCE_LE
(
total_score_num
,
max_num
,
platform
::
errors
::
InvalidArgument
(
"The number of sampled scores should not be greater than the "
"number of all anchor boxes(%d), but the number of sampled "
"scores is :%d."
,
max_num
,
total_score_num
));
lod_loc
.
emplace_back
(
lod0_loc
);
lod_loc
.
emplace_back
(
lod0_loc
);
loc_score
.
emplace_back
(
lod0_score
);
loc_score
.
emplace_back
(
lod0_score
);
...
...
paddle/fluid/operators/im2sequence_op.cc
浏览文件 @
4c01d6d5
...
@@ -26,14 +26,20 @@ class Im2SequenceOp : public framework::OperatorWithKernel {
...
@@ -26,14 +26,20 @@ class Im2SequenceOp : public framework::OperatorWithKernel {
protected:
protected:
void
InferShape
(
framework
::
InferShapeContext
*
ctx
)
const
override
{
void
InferShape
(
framework
::
InferShapeContext
*
ctx
)
const
override
{
PADDLE_ENFORCE
(
ctx
->
HasInput
(
"X"
),
PADDLE_ENFORCE_EQ
(
ctx
->
HasInput
(
"X"
),
true
,
"Input(X) of Im2SequenceOp should not be null."
);
platform
::
errors
::
NotFound
(
PADDLE_ENFORCE
(
ctx
->
HasOutput
(
"Out"
),
"The input 'X' of Im2SequenceOp is not found."
));
"Output(Out) of Im2SequenceOp op should not be null."
);
PADDLE_ENFORCE_EQ
(
ctx
->
HasOutput
(
"Out"
),
true
,
platform
::
errors
::
NotFound
(
"The output 'Out' of Im2SequenceOp is not found."
));
auto
in_dim
=
ctx
->
GetInputDim
(
"X"
);
auto
in_dim
=
ctx
->
GetInputDim
(
"X"
);
PADDLE_ENFORCE_EQ
(
in_dim
.
size
(),
4
,
PADDLE_ENFORCE_EQ
(
"Input(X) format must be 4D tensor, eg., NCHW."
);
in_dim
.
size
(),
4
,
platform
::
errors
::
InvalidArgument
(
"The dimesions size of input 'X' in Im2SequenceOp should be 4. But "
"received dimesions size=[%d], dimesions=[%s]."
,
in_dim
.
size
(),
in_dim
));
auto
img_channels
=
in_dim
[
1
];
auto
img_channels
=
in_dim
[
1
];
auto
kernels
=
ctx
->
Attrs
().
Get
<
std
::
vector
<
int
>>
(
"kernels"
);
auto
kernels
=
ctx
->
Attrs
().
Get
<
std
::
vector
<
int
>>
(
"kernels"
);
...
@@ -146,9 +152,13 @@ class Im2SequenceGradOp : public framework::OperatorWithKernel {
...
@@ -146,9 +152,13 @@ class Im2SequenceGradOp : public framework::OperatorWithKernel {
protected:
protected:
void
InferShape
(
framework
::
InferShapeContext
*
ctx
)
const
override
{
void
InferShape
(
framework
::
InferShapeContext
*
ctx
)
const
override
{
PADDLE_ENFORCE
(
ctx
->
HasInput
(
"X"
),
"Input(X) should not be null"
);
PADDLE_ENFORCE_EQ
(
ctx
->
HasInput
(
"X"
),
true
,
PADDLE_ENFORCE
(
ctx
->
HasInput
(
framework
::
GradVarName
(
"Out"
)),
platform
::
errors
::
NotFound
(
"Input(Out@GRAD) shouldn't be null."
);
"The input 'X' of Im2SequenceGradOp is not found."
));
PADDLE_ENFORCE_EQ
(
ctx
->
HasInput
(
framework
::
GradVarName
(
"Out"
)),
true
,
platform
::
errors
::
NotFound
(
"The input %s of Im2SequenceGradOp is not found."
,
framework
::
GradVarName
(
"Out"
)));
ctx
->
SetOutputDim
(
framework
::
GradVarName
(
"X"
),
ctx
->
GetInputDim
(
"X"
));
ctx
->
SetOutputDim
(
framework
::
GradVarName
(
"X"
),
ctx
->
GetInputDim
(
"X"
));
}
}
};
};
...
...
paddle/fluid/operators/label_smooth_op.cc
浏览文件 @
4c01d6d5
...
@@ -28,18 +28,24 @@ class LabelSmoothOp : public framework::OperatorWithKernel {
...
@@ -28,18 +28,24 @@ class LabelSmoothOp : public framework::OperatorWithKernel {
:
OperatorWithKernel
(
type
,
inputs
,
outputs
,
attrs
)
{}
:
OperatorWithKernel
(
type
,
inputs
,
outputs
,
attrs
)
{}
void
InferShape
(
framework
::
InferShapeContext
*
ctx
)
const
override
{
void
InferShape
(
framework
::
InferShapeContext
*
ctx
)
const
override
{
PADDLE_ENFORCE
(
ctx
->
HasInput
(
"X"
),
PADDLE_ENFORCE_EQ
(
ctx
->
HasInput
(
"X"
),
true
,
"Input(X) of LabelSmoothOp should not be null."
);
platform
::
errors
::
NotFound
(
PADDLE_ENFORCE
(
ctx
->
HasOutput
(
"Out"
),
"The input 'X' of LabelSmoothOp is not found."
));
"Output(Out) of LabelSmoothOp should not be null."
);
PADDLE_ENFORCE_EQ
(
ctx
->
HasOutput
(
"Out"
),
true
,
platform
::
errors
::
NotFound
(
"The output 'Out' of LabelSmoothOp is not found."
));
auto
in_dims
=
ctx
->
GetInputDim
(
"X"
);
auto
in_dims
=
ctx
->
GetInputDim
(
"X"
);
if
(
ctx
->
HasInput
(
"PriorDist"
))
{
if
(
ctx
->
HasInput
(
"PriorDist"
))
{
auto
noise_dims
=
ctx
->
GetInputDim
(
"PriorDist"
);
auto
noise_dims
=
ctx
->
GetInputDim
(
"PriorDist"
);
auto
noise_numel
=
paddle
::
framework
::
product
(
noise_dims
);
auto
noise_numel
=
paddle
::
framework
::
product
(
noise_dims
);
PADDLE_ENFORCE
(
PADDLE_ENFORCE_EQ
(
in_dims
[
in_dims
.
size
()
-
1
]
==
noise_numel
,
in_dims
[
in_dims
.
size
()
-
1
],
noise_numel
,
"The number of elements in Input(PriorDist) must be equal to the "
platform
::
errors
::
InvalidArgument
(
"dimension of each label."
);
"The number of elements in input 'PriorDist' must be equal to "
"the "
"dimension of each label. But received each label's "
"dimension=[%d], number of elements in input 'PriorDist' is [%d]"
,
in_dims
[
in_dims
.
size
()
-
1
],
noise_numel
));
}
}
ctx
->
ShareLoD
(
"X"
,
/*->*/
"Out"
);
ctx
->
ShareLoD
(
"X"
,
/*->*/
"Out"
);
ctx
->
SetOutputDim
(
"Out"
,
in_dims
);
ctx
->
SetOutputDim
(
"Out"
,
in_dims
);
...
...
python/paddle/fluid/layers/detection.py
浏览文件 @
4c01d6d5
...
@@ -406,6 +406,22 @@ def rpn_target_assign(bbox_pred,
...
@@ -406,6 +406,22 @@ def rpn_target_assign(bbox_pred,
"""
"""
helper
=
LayerHelper
(
'rpn_target_assign'
,
**
locals
())
helper
=
LayerHelper
(
'rpn_target_assign'
,
**
locals
())
check_variable_and_dtype
(
bbox_pred
,
'bbox_pred'
,
[
'float32'
,
'float64'
],
'rpn_target_assign'
)
check_variable_and_dtype
(
cls_logits
,
'cls_logits'
,
[
'float32'
,
'float64'
],
'rpn_target_assign'
)
check_variable_and_dtype
(
anchor_box
,
'anchor_box'
,
[
'float32'
,
'float64'
],
'rpn_target_assign'
)
check_variable_and_dtype
(
anchor_var
,
'anchor_var'
,
[
'float32'
,
'float64'
],
'rpn_target_assign'
)
check_variable_and_dtype
(
gt_boxes
,
'gt_boxes'
,
[
'float32'
,
'float64'
],
'rpn_target_assign'
)
check_variable_and_dtype
(
is_crowd
,
'is_crowd'
,
[
'int32'
],
'rpn_target_assign'
)
check_variable_and_dtype
(
im_info
,
'im_info'
,
[
'float32'
,
'float64'
],
'rpn_target_assign'
)
# Assign target label to anchors
# Assign target label to anchors
loc_index
=
helper
.
create_variable_for_type_inference
(
dtype
=
'int32'
)
loc_index
=
helper
.
create_variable_for_type_inference
(
dtype
=
'int32'
)
score_index
=
helper
.
create_variable_for_type_inference
(
dtype
=
'int32'
)
score_index
=
helper
.
create_variable_for_type_inference
(
dtype
=
'int32'
)
...
@@ -2662,6 +2678,13 @@ def generate_proposal_labels(rpn_rois,
...
@@ -2662,6 +2678,13 @@ def generate_proposal_labels(rpn_rois,
helper
=
LayerHelper
(
'generate_proposal_labels'
,
**
locals
())
helper
=
LayerHelper
(
'generate_proposal_labels'
,
**
locals
())
check_variable_and_dtype
(
rpn_rois
,
'rpn_rois'
,
[
'float32'
,
'float64'
],
'generate_proposal_labels'
)
check_variable_and_dtype
(
gt_classes
,
'gt_classes'
,
[
'int32'
],
'generate_proposal_labels'
)
check_variable_and_dtype
(
is_crowd
,
'is_crowd'
,
[
'int32'
],
'generate_proposal_labels'
)
rois
=
helper
.
create_variable_for_type_inference
(
dtype
=
rpn_rois
.
dtype
)
rois
=
helper
.
create_variable_for_type_inference
(
dtype
=
rpn_rois
.
dtype
)
labels_int32
=
helper
.
create_variable_for_type_inference
(
labels_int32
=
helper
.
create_variable_for_type_inference
(
dtype
=
gt_classes
.
dtype
)
dtype
=
gt_classes
.
dtype
)
...
@@ -2904,7 +2927,7 @@ def generate_proposals(scores,
...
@@ -2904,7 +2927,7 @@ def generate_proposals(scores,
im_info(Variable): A 2-D Tensor with shape [N, 3] represents origin
im_info(Variable): A 2-D Tensor with shape [N, 3] represents origin
image information for N batch. Height and width are the input sizes
image information for N batch. Height and width are the input sizes
and scale is the ratio of network input size and original size.
and scale is the ratio of network input size and original size.
The data type
must be int32
.
The data type
can be float32 or float64
.
anchors(Variable): A 4-D Tensor represents the anchors with a layout
anchors(Variable): A 4-D Tensor represents the anchors with a layout
of [H, W, A, 4]. H and W are height and width of the feature map,
of [H, W, A, 4]. H and W are height and width of the feature map,
num_anchors is the box count of each position. Each anchor is
num_anchors is the box count of each position. Each anchor is
...
@@ -2947,6 +2970,17 @@ def generate_proposals(scores,
...
@@ -2947,6 +2970,17 @@ def generate_proposals(scores,
"""
"""
helper
=
LayerHelper
(
'generate_proposals'
,
**
locals
())
helper
=
LayerHelper
(
'generate_proposals'
,
**
locals
())
check_variable_and_dtype
(
scores
,
'scores'
,
[
'float32'
],
'generate_proposals'
)
check_variable_and_dtype
(
bbox_deltas
,
'bbox_deltas'
,
[
'float32'
],
'generate_proposals'
)
check_variable_and_dtype
(
im_info
,
'im_info'
,
[
'float32'
,
'float64'
],
'generate_proposals'
)
check_variable_and_dtype
(
anchors
,
'anchors'
,
[
'float32'
],
'generate_proposals'
)
check_variable_and_dtype
(
variances
,
'variances'
,
[
'float32'
],
'generate_proposals'
)
rpn_rois
=
helper
.
create_variable_for_type_inference
(
rpn_rois
=
helper
.
create_variable_for_type_inference
(
dtype
=
bbox_deltas
.
dtype
)
dtype
=
bbox_deltas
.
dtype
)
rpn_roi_probs
=
helper
.
create_variable_for_type_inference
(
rpn_roi_probs
=
helper
.
create_variable_for_type_inference
(
...
...
python/paddle/fluid/layers/nn.py
浏览文件 @
4c01d6d5
...
@@ -5582,6 +5582,8 @@ def im2sequence(input,
...
@@ -5582,6 +5582,8 @@ def im2sequence(input,
assert not in_dygraph_mode(), (
assert not in_dygraph_mode(), (
"sequence layer is not supported in dygraph mode yet.")
"sequence layer is not supported in dygraph mode yet.")
check_variable_and_dtype(input, 'input', ['float32'], 'im2sequence')
if isinstance(filter_size, int):
if isinstance(filter_size, int):
filter_size = [filter_size, filter_size]
filter_size = [filter_size, filter_size]
if isinstance(stride, int):
if isinstance(stride, int):
...
@@ -6727,7 +6729,7 @@ def label_smooth(label,
...
@@ -6727,7 +6729,7 @@ def label_smooth(label,
label(Variable): The input variable containing the label data. The
label(Variable): The input variable containing the label data. The
label data should use one-hot representation. It's
label data should use one-hot representation. It's
a multidimensional tensor with a shape of
a multidimensional tensor with a shape of
:math:`[N_1, ..., Depth]`, where Depth is class number.
:math:`[N_1, ..., Depth]`, where Depth is class number.
The dtype can be "float32" and "float64".
prior_dist(Variable, optional): The prior distribution to be used to smooth
prior_dist(Variable, optional): The prior distribution to be used to smooth
labels. If not provided, an uniform distribution
labels. If not provided, an uniform distribution
is used. It's a multidimensional tensor with a shape of
is used. It's a multidimensional tensor with a shape of
...
@@ -6750,7 +6752,7 @@ def label_smooth(label,
...
@@ -6750,7 +6752,7 @@ def label_smooth(label,
import paddle.fluid as fluid
import paddle.fluid as fluid
import paddle.fluid.layers as layers
import paddle.fluid.layers as layers
label = layers.data(name="label", shape=[1], dtype="
floa
t32")
label = layers.data(name="label", shape=[1], dtype="
in
t32")
one_hot_label = layers.one_hot(input=label, depth=10)
one_hot_label = layers.one_hot(input=label, depth=10)
smooth_label = layers.label_smooth(
smooth_label = layers.label_smooth(
label=one_hot_label, epsilon=0.1, dtype="float32")
label=one_hot_label, epsilon=0.1, dtype="float32")
...
@@ -6762,6 +6764,9 @@ def label_smooth(label,
...
@@ -6762,6 +6764,9 @@ def label_smooth(label,
return core.ops.label_smooth(label, prior_dist, 'epsilon',
return core.ops.label_smooth(label, prior_dist, 'epsilon',
float(epsilon))
float(epsilon))
check_variable_and_dtype(label, 'label', ['float32', 'float64'],
'label_smooth')
helper = LayerHelper("label_smooth", **locals())
helper = LayerHelper("label_smooth", **locals())
label.stop_gradient = True
label.stop_gradient = True
smooth_label = helper.create_variable_for_type_inference(dtype)
smooth_label = helper.create_variable_for_type_inference(dtype)
...
@@ -9121,6 +9126,9 @@ def affine_grid(theta, out_shape, name=None):
...
@@ -9121,6 +9126,9 @@ def affine_grid(theta, out_shape, name=None):
"""
"""
helper = LayerHelper('affine_grid')
helper = LayerHelper('affine_grid')
check_variable_and_dtype(theta, 'theta', ['float32', 'float64'],
'affine_grid')
if not (isinstance(out_shape, list) or isinstance(out_shape, tuple) or \
if not (isinstance(out_shape, list) or isinstance(out_shape, tuple) or \
isinstance(out_shape, Variable)):
isinstance(out_shape, Variable)):
raise ValueError("The out_shape should be a list, tuple or Variable.")
raise ValueError("The out_shape should be a list, tuple or Variable.")
...
@@ -9133,6 +9141,8 @@ def affine_grid(theta, out_shape, name=None):
...
@@ -9133,6 +9141,8 @@ def affine_grid(theta, out_shape, name=None):
attrs = {}
attrs = {}
if isinstance(out_shape, Variable):
if isinstance(out_shape, Variable):
ipts['OutputShape'] = out_shape
ipts['OutputShape'] = out_shape
check_variable_and_dtype(out_shape, 'out_shape', ['int32'],
'affine_grid')
else:
else:
attrs['output_shape'] = out_shape
attrs['output_shape'] = out_shape
...
...
python/paddle/fluid/tests/unittests/test_layers.py
浏览文件 @
4c01d6d5
...
@@ -3055,8 +3055,7 @@ class TestBook(LayerTest):
...
@@ -3055,8 +3055,7 @@ class TestBook(LayerTest):
out
,
ids
=
layers
.
argsort
(
input
=
data
,
axis
=
1
)
out
,
ids
=
layers
.
argsort
(
input
=
data
,
axis
=
1
)
theta
=
layers
.
data
(
name
=
"theta"
,
shape
=
[
2
,
3
],
dtype
=
"float32"
)
theta
=
layers
.
data
(
name
=
"theta"
,
shape
=
[
2
,
3
],
dtype
=
"float32"
)
out_shape
=
layers
.
data
(
out_shape
=
layers
.
data
(
name
=
"out_shape"
,
shape
=
[
-
1
],
dtype
=
"int32"
)
name
=
"out_shape"
,
shape
=
[
-
1
],
dtype
=
"float32"
)
data_0
=
layers
.
affine_grid
(
theta
,
out_shape
)
data_0
=
layers
.
affine_grid
(
theta
,
out_shape
)
data_1
=
layers
.
affine_grid
(
theta
,
[
5
,
3
,
28
,
28
])
data_1
=
layers
.
affine_grid
(
theta
,
[
5
,
3
,
28
,
28
])
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录