Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
Paddle
提交
88744e4a
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看板
提交
88744e4a
编写于
1月 24, 2019
作者:
T
tink2123
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fixed some errors
test=develop
上级
48cc4846
变更
7
隐藏空白更改
内联
并排
Showing
7 changed file
with
58 addition
and
55 deletion
+58
-55
paddle/fluid/API.spec
paddle/fluid/API.spec
+4
-3
paddle/fluid/operators/interpolate_op.cc
paddle/fluid/operators/interpolate_op.cc
+7
-10
paddle/fluid/operators/interpolate_op.cu
paddle/fluid/operators/interpolate_op.cu
+4
-0
paddle/fluid/operators/interpolate_op.h
paddle/fluid/operators/interpolate_op.h
+4
-0
python/paddle/fluid/layers/nn.py
python/paddle/fluid/layers/nn.py
+11
-16
python/paddle/fluid/tests/unittests/test_bilinear_interp_op.py
...n/paddle/fluid/tests/unittests/test_bilinear_interp_op.py
+27
-25
python/paddle/fluid/tests/unittests/test_nearest_interp_op.py
...on/paddle/fluid/tests/unittests/test_nearest_interp_op.py
+1
-1
未找到文件。
paddle/fluid/API.spec
浏览文件 @
88744e4a
...
@@ -140,10 +140,10 @@ paddle.fluid.layers.label_smooth ArgSpec(args=['label', 'prior_dist', 'epsilon',
...
@@ -140,10 +140,10 @@ paddle.fluid.layers.label_smooth ArgSpec(args=['label', 'prior_dist', 'epsilon',
paddle.fluid.layers.roi_pool ArgSpec(args=['input', 'rois', 'pooled_height', 'pooled_width', 'spatial_scale'], varargs=None, keywords=None, defaults=(1, 1, 1.0))
paddle.fluid.layers.roi_pool ArgSpec(args=['input', 'rois', 'pooled_height', 'pooled_width', 'spatial_scale'], varargs=None, keywords=None, defaults=(1, 1, 1.0))
paddle.fluid.layers.roi_align ArgSpec(args=['input', 'rois', 'pooled_height', 'pooled_width', 'spatial_scale', 'sampling_ratio', 'name'], varargs=None, keywords=None, defaults=(1, 1, 1.0, -1, None))
paddle.fluid.layers.roi_align ArgSpec(args=['input', 'rois', 'pooled_height', 'pooled_width', 'spatial_scale', 'sampling_ratio', 'name'], varargs=None, keywords=None, defaults=(1, 1, 1.0, -1, None))
paddle.fluid.layers.dice_loss ArgSpec(args=['input', 'label', 'epsilon'], varargs=None, keywords=None, defaults=(1e-05,))
paddle.fluid.layers.dice_loss ArgSpec(args=['input', 'label', 'epsilon'], varargs=None, keywords=None, defaults=(1e-05,))
paddle.fluid.layers.image_resize ArgSpec(args=['input', 'out_shape', 'scale', 'name', 'resample', 'actual_shape'
], varargs=None, keywords=None, defaults=(None, None, None, 'BILINEAR', None
))
paddle.fluid.layers.image_resize ArgSpec(args=['input', 'out_shape', 'scale', 'name', 'resample', 'actual_shape'
, 'align_corners', 'align_mode'], varargs=None, keywords=None, defaults=(None, None, None, 'BILINEAR', None, True, 1
))
paddle.fluid.layers.image_resize_short ArgSpec(args=['input', 'out_short_len', 'resample'], varargs=None, keywords=None, defaults=('BILINEAR',))
paddle.fluid.layers.image_resize_short ArgSpec(args=['input', 'out_short_len', 'resample'], varargs=None, keywords=None, defaults=('BILINEAR',))
paddle.fluid.layers.resize_bilinear ArgSpec(args=['input', 'out_shape', 'scale', 'name', 'actual_shape'
], varargs=None, keywords=None, defaults=(None, None, None, None
))
paddle.fluid.layers.resize_bilinear ArgSpec(args=['input', 'out_shape', 'scale', 'name', 'actual_shape'
, 'align_corners', 'align_mode'], varargs=None, keywords=None, defaults=(None, None, None, None, True, 1
))
paddle.fluid.layers.resize_nearest ArgSpec(args=['input', 'out_shape', 'scale', 'name', 'actual_shape'
], varargs=None, keywords=None, defaults=(None, None, None, Non
e))
paddle.fluid.layers.resize_nearest ArgSpec(args=['input', 'out_shape', 'scale', 'name', 'actual_shape'
, 'align_corners'], varargs=None, keywords=None, defaults=(None, None, None, None, Tru
e))
paddle.fluid.layers.gather ArgSpec(args=['input', 'index'], varargs=None, keywords=None, defaults=None)
paddle.fluid.layers.gather ArgSpec(args=['input', 'index'], varargs=None, keywords=None, defaults=None)
paddle.fluid.layers.scatter ArgSpec(args=['input', 'index', 'updates', 'name'], varargs=None, keywords=None, defaults=(None,))
paddle.fluid.layers.scatter ArgSpec(args=['input', 'index', 'updates', 'name'], varargs=None, keywords=None, defaults=(None,))
paddle.fluid.layers.sequence_scatter ArgSpec(args=['input', 'index', 'updates', 'name'], varargs=None, keywords=None, defaults=(None,))
paddle.fluid.layers.sequence_scatter ArgSpec(args=['input', 'index', 'updates', 'name'], varargs=None, keywords=None, defaults=(None,))
...
@@ -505,3 +505,4 @@ paddle.reader.Fake.__init__ ArgSpec(args=['self'], varargs=None, keywords=None,
...
@@ -505,3 +505,4 @@ paddle.reader.Fake.__init__ ArgSpec(args=['self'], varargs=None, keywords=None,
paddle.reader.creator.np_array ArgSpec(args=['x'], varargs=None, keywords=None, defaults=None)
paddle.reader.creator.np_array ArgSpec(args=['x'], varargs=None, keywords=None, defaults=None)
paddle.reader.creator.text_file ArgSpec(args=['path'], varargs=None, keywords=None, defaults=None)
paddle.reader.creator.text_file ArgSpec(args=['path'], varargs=None, keywords=None, defaults=None)
paddle.reader.creator.recordio ArgSpec(args=['paths', 'buf_size'], varargs=None, keywords=None, defaults=(100,))
paddle.reader.creator.recordio ArgSpec(args=['paths', 'buf_size'], varargs=None, keywords=None, defaults=(100,))
paddle/fluid/operators/interpolate_op.cc
浏览文件 @
88744e4a
...
@@ -90,10 +90,10 @@ class InterpolateOpMaker : public framework::OpProtoAndCheckerMaker {
...
@@ -90,10 +90,10 @@ class InterpolateOpMaker : public framework::OpProtoAndCheckerMaker {
"if Flase, are not aligned"
)
"if Flase, are not aligned"
)
.
SetDefault
(
true
);
.
SetDefault
(
true
);
AddAttr
<
int
>
(
"align_mode"
,
AddAttr
<
int
>
(
"align_mode"
,
"(int, default
\'
0
\'
), align_corners mode , can be
\'
0
\'
"
"(int, default
\'
1
\'
), can be
\'
0
\'
for
"
"
for pytorch calculation method
, can be
\'
1
\'
for "
"
src_idx = scale*(dst_indx+0.5)-0.5
, can be
\'
1
\'
for "
"
tensorflow calculation method
."
)
"
src_idx = scale*dst_index
."
)
.
SetDefault
(
0
);
.
SetDefault
(
1
);
AddComment
(
R"DOC(
AddComment
(
R"DOC(
This operator samples input X to given output shape by using specified
This operator samples input X to given output shape by using specified
interpolation method, the interpolation methods can be \"nearest\"
interpolation method, the interpolation methods can be \"nearest\"
...
@@ -115,7 +115,7 @@ class InterpolateOpMaker : public framework::OpProtoAndCheckerMaker {
...
@@ -115,7 +115,7 @@ class InterpolateOpMaker : public framework::OpProtoAndCheckerMaker {
Example:
Example:
f
or scale:
F
or scale:
if align_corners = True and out_{size}>1 :
if align_corners = True and out_{size}>1 :
...
@@ -148,7 +148,7 @@ class InterpolateOpMaker : public framework::OpProtoAndCheckerMaker {
...
@@ -148,7 +148,7 @@ class InterpolateOpMaker : public framework::OpProtoAndCheckerMaker {
Bilinear interpolation:
Bilinear interpolation:
case 1
:
if
:
align_corners = False , align_mode = 0
align_corners = False , align_mode = 0
input : (N,C,H_in,W_in)
input : (N,C,H_in,W_in)
...
@@ -158,10 +158,7 @@ class InterpolateOpMaker : public framework::OpProtoAndCheckerMaker {
...
@@ -158,10 +158,7 @@ class InterpolateOpMaker : public framework::OpProtoAndCheckerMaker {
W_out = (W_{in}+0.5) * scale_{factor} - 0.5
W_out = (W_{in}+0.5) * scale_{factor} - 0.5
case 2:
else:
align_corners = False , align_mode = 1
or
align_corners = True
input : (N,C,H_in,W_in)
input : (N,C,H_in,W_in)
output: (N,C,H_out,W_out) where:
output: (N,C,H_out,W_out) where:
...
...
paddle/fluid/operators/interpolate_op.cu
浏览文件 @
88744e4a
...
@@ -105,6 +105,7 @@ __global__ void KeBilinearInterpFw(
...
@@ -105,6 +105,7 @@ __global__ void KeBilinearInterpFw(
int
in_img_idy
=
(
align_mode
==
0
&&
!
align_corners
)
int
in_img_idy
=
(
align_mode
==
0
&&
!
align_corners
)
?
static_cast
<
int
>
(
ratio_h
*
(
out_img_idy
+
0.5
)
-
0.5
)
?
static_cast
<
int
>
(
ratio_h
*
(
out_img_idy
+
0.5
)
-
0.5
)
:
static_cast
<
int
>
(
ratio_h
*
out_img_idy
);
:
static_cast
<
int
>
(
ratio_h
*
out_img_idy
);
in_img_idy
=
(
in_img_idy
>
0
)
?
in_img_idy
:
0
;
int
h_id
=
(
in_img_idy
<
in_img_h
-
1
)
?
1
:
0
;
int
h_id
=
(
in_img_idy
<
in_img_h
-
1
)
?
1
:
0
;
T
h1lambda
=
(
align_mode
==
0
&&
!
align_corners
)
T
h1lambda
=
(
align_mode
==
0
&&
!
align_corners
)
?
ratio_h
*
(
out_img_idy
+
0.5
)
-
0.5
-
in_img_idy
?
ratio_h
*
(
out_img_idy
+
0.5
)
-
0.5
-
in_img_idy
...
@@ -115,6 +116,7 @@ __global__ void KeBilinearInterpFw(
...
@@ -115,6 +116,7 @@ __global__ void KeBilinearInterpFw(
int
in_img_idx
=
(
align_mode
==
0
&&
!
align_corners
)
int
in_img_idx
=
(
align_mode
==
0
&&
!
align_corners
)
?
static_cast
<
int
>
(
ratio_w
*
(
out_img_idx
+
0.5
)
-
0.5
)
?
static_cast
<
int
>
(
ratio_w
*
(
out_img_idx
+
0.5
)
-
0.5
)
:
static_cast
<
int
>
(
ratio_w
*
out_img_idx
);
:
static_cast
<
int
>
(
ratio_w
*
out_img_idx
);
in_img_idx
=
(
in_img_idx
>
0
)
?
in_img_idx
:
0
;
int
w_id
=
(
in_img_idx
<
in_img_w
-
1
)
?
1
:
0
;
int
w_id
=
(
in_img_idx
<
in_img_w
-
1
)
?
1
:
0
;
T
w1lambda
=
(
align_mode
==
0
&&
!
align_corners
)
T
w1lambda
=
(
align_mode
==
0
&&
!
align_corners
)
?
ratio_w
*
(
out_img_idx
+
0.5
)
-
0.5
-
in_img_idx
?
ratio_w
*
(
out_img_idx
+
0.5
)
-
0.5
-
in_img_idx
...
@@ -153,6 +155,7 @@ __global__ void KeBilinearInterpBw(
...
@@ -153,6 +155,7 @@ __global__ void KeBilinearInterpBw(
int
in_img_idy
=
(
align_mode
==
0
&&
!
align_corners
)
int
in_img_idy
=
(
align_mode
==
0
&&
!
align_corners
)
?
ratio_h
*
(
out_img_idy
+
0.5
)
-
0.5
?
ratio_h
*
(
out_img_idy
+
0.5
)
-
0.5
:
ratio_h
*
out_img_idy
;
:
ratio_h
*
out_img_idy
;
in_img_idy
=
(
in_img_idy
>
0
)
?
in_img_idy
:
0
;
int
h_id
=
(
in_img_idy
<
in_img_h
-
1
)
?
1
:
0
;
int
h_id
=
(
in_img_idy
<
in_img_h
-
1
)
?
1
:
0
;
T
h1lambda
=
(
align_mode
==
0
&&
!
align_corners
)
T
h1lambda
=
(
align_mode
==
0
&&
!
align_corners
)
?
ratio_h
*
(
out_img_idy
+
0.5
)
-
0.5
-
in_img_idy
?
ratio_h
*
(
out_img_idy
+
0.5
)
-
0.5
-
in_img_idy
...
@@ -164,6 +167,7 @@ __global__ void KeBilinearInterpBw(
...
@@ -164,6 +167,7 @@ __global__ void KeBilinearInterpBw(
int
in_img_idx
=
(
align_mode
==
0
&&
!
align_corners
)
int
in_img_idx
=
(
align_mode
==
0
&&
!
align_corners
)
?
ratio_w
*
(
out_img_idx
+
0.5
)
-
0.5
?
ratio_w
*
(
out_img_idx
+
0.5
)
-
0.5
:
ratio_w
*
out_img_idx
;
:
ratio_w
*
out_img_idx
;
in_img_idx
=
(
in_img_idx
>
0
)
?
in_img_idx
:
0
;
int
w_id
=
(
in_img_idx
<
in_img_w
-
1
)
?
1
:
0
;
int
w_id
=
(
in_img_idx
<
in_img_w
-
1
)
?
1
:
0
;
T
w1lambda
=
(
align_mode
==
0
&&
!
align_corners
)
T
w1lambda
=
(
align_mode
==
0
&&
!
align_corners
)
?
ratio_w
*
(
out_img_idx
+
0.5
)
-
0.5
-
in_img_idx
?
ratio_w
*
(
out_img_idx
+
0.5
)
-
0.5
-
in_img_idx
...
...
paddle/fluid/operators/interpolate_op.h
浏览文件 @
88744e4a
...
@@ -60,6 +60,7 @@ static void BilinearInterpolation(const Tensor& input, Tensor* output,
...
@@ -60,6 +60,7 @@ static void BilinearInterpolation(const Tensor& input, Tensor* output,
int
y_n
=
(
align_mode
==
0
&&
!
align_corners
)
int
y_n
=
(
align_mode
==
0
&&
!
align_corners
)
?
static_cast
<
int
>
(
ratio_h
*
(
k
+
0.5
)
-
0.5
)
?
static_cast
<
int
>
(
ratio_h
*
(
k
+
0.5
)
-
0.5
)
:
static_cast
<
int
>
(
ratio_h
*
k
);
:
static_cast
<
int
>
(
ratio_h
*
k
);
y_n
=
(
y_n
>
0
)
?
y_n
:
0
;
int
y_s
=
(
y_n
+
1
)
<
(
in_h
-
1
)
?
(
y_n
+
1
)
:
(
in_h
-
1
);
int
y_s
=
(
y_n
+
1
)
<
(
in_h
-
1
)
?
(
y_n
+
1
)
:
(
in_h
-
1
);
float
d_n
=
(
align_mode
==
0
&&
!
align_corners
)
float
d_n
=
(
align_mode
==
0
&&
!
align_corners
)
?
ratio_h
*
(
k
+
0.5
)
-
0.5
-
y_n
?
ratio_h
*
(
k
+
0.5
)
-
0.5
-
y_n
...
@@ -70,6 +71,7 @@ static void BilinearInterpolation(const Tensor& input, Tensor* output,
...
@@ -70,6 +71,7 @@ static void BilinearInterpolation(const Tensor& input, Tensor* output,
int
x_w
=
(
align_mode
==
0
&&
!
align_corners
)
int
x_w
=
(
align_mode
==
0
&&
!
align_corners
)
?
static_cast
<
int
>
(
ratio_w
*
(
l
+
0.5
)
-
0.5
)
?
static_cast
<
int
>
(
ratio_w
*
(
l
+
0.5
)
-
0.5
)
:
static_cast
<
int
>
(
ratio_w
*
l
);
:
static_cast
<
int
>
(
ratio_w
*
l
);
x_w
=
(
x_w
>
0
)
?
x_w
:
0
;
int
x_e
=
(
x_w
+
1
)
<
(
in_w
-
1
)
?
(
x_w
+
1
)
:
(
in_w
-
1
);
int
x_e
=
(
x_w
+
1
)
<
(
in_w
-
1
)
?
(
x_w
+
1
)
:
(
in_w
-
1
);
float
d_w
=
(
align_mode
==
0
&&
!
align_corners
)
float
d_w
=
(
align_mode
==
0
&&
!
align_corners
)
?
ratio_w
*
(
l
+
0.5
)
-
0.5
-
x_w
?
ratio_w
*
(
l
+
0.5
)
-
0.5
-
x_w
...
@@ -128,6 +130,7 @@ static void BilinearInterpolationGrad(const Tensor& output_grad,
...
@@ -128,6 +130,7 @@ static void BilinearInterpolationGrad(const Tensor& output_grad,
int
y_n
=
(
align_mode
==
0
&&
!
align_corners
)
int
y_n
=
(
align_mode
==
0
&&
!
align_corners
)
?
static_cast
<
int
>
(
ratio_h
*
(
k
+
0.5
)
-
0.5
)
?
static_cast
<
int
>
(
ratio_h
*
(
k
+
0.5
)
-
0.5
)
:
static_cast
<
int
>
(
ratio_h
*
k
);
:
static_cast
<
int
>
(
ratio_h
*
k
);
y_n
=
(
y_n
>
0
)
?
y_n
:
0
;
int
y_s
=
(
y_n
+
1
)
<
(
in_h
-
1
)
?
(
y_n
+
1
)
:
(
in_h
-
1
);
int
y_s
=
(
y_n
+
1
)
<
(
in_h
-
1
)
?
(
y_n
+
1
)
:
(
in_h
-
1
);
float
d_n
=
(
align_mode
==
0
&&
!
align_corners
)
float
d_n
=
(
align_mode
==
0
&&
!
align_corners
)
?
ratio_h
*
(
k
+
0.5
)
-
0.5
-
y_n
?
ratio_h
*
(
k
+
0.5
)
-
0.5
-
y_n
...
@@ -138,6 +141,7 @@ static void BilinearInterpolationGrad(const Tensor& output_grad,
...
@@ -138,6 +141,7 @@ static void BilinearInterpolationGrad(const Tensor& output_grad,
int
x_w
=
(
align_mode
==
0
&&
!
align_corners
)
int
x_w
=
(
align_mode
==
0
&&
!
align_corners
)
?
static_cast
<
int
>
(
ratio_w
*
(
l
+
0.5
)
-
0.5
)
?
static_cast
<
int
>
(
ratio_w
*
(
l
+
0.5
)
-
0.5
)
:
static_cast
<
int
>
(
ratio_w
*
l
);
:
static_cast
<
int
>
(
ratio_w
*
l
);
x_w
=
(
x_w
>
0
)
?
x_w
:
0
;
int
x_e
=
(
x_w
+
1
)
<
(
in_w
-
1
)
?
(
x_w
+
1
)
:
(
in_w
-
1
);
int
x_e
=
(
x_w
+
1
)
<
(
in_w
-
1
)
?
(
x_w
+
1
)
:
(
in_w
-
1
);
float
d_w
=
(
align_mode
==
0
&&
!
align_corners
)
float
d_w
=
(
align_mode
==
0
&&
!
align_corners
)
?
ratio_w
*
(
l
+
0.5
)
-
0.5
-
x_w
?
ratio_w
*
(
l
+
0.5
)
-
0.5
-
x_w
...
...
python/paddle/fluid/layers/nn.py
浏览文件 @
88744e4a
...
@@ -6557,7 +6557,7 @@ def image_resize(input,
...
@@ -6557,7 +6557,7 @@ def image_resize(input,
Example:
Example:
f
or scale:
F
or scale:
if align_corners = True && out_size > 1 :
if align_corners = True && out_size > 1 :
...
@@ -6590,7 +6590,7 @@ def image_resize(input,
...
@@ -6590,7 +6590,7 @@ def image_resize(input,
Bilinear interpolation:
Bilinear interpolation:
case 1
:
if
:
align_corners = False , align_mode = 0
align_corners = False , align_mode = 0
input : (N,C,H_in,W_in)
input : (N,C,H_in,W_in)
...
@@ -6600,10 +6600,7 @@ def image_resize(input,
...
@@ -6600,10 +6600,7 @@ def image_resize(input,
W_out = (W_{in}+0.5) * scale_{factor} - 0.5
W_out = (W_{in}+0.5) * scale_{factor} - 0.5
case 2:
else:
align_corners = False , align_mode = 1
or
align_corners = True
input : (N,C,H_in,W_in)
input : (N,C,H_in,W_in)
output: (N,C,H_out,W_out) where:
output: (N,C,H_out,W_out) where:
...
@@ -6652,8 +6649,9 @@ def image_resize(input,
...
@@ -6652,8 +6649,9 @@ def image_resize(input,
input and output tensors are aligned, preserving the values at the
input and output tensors are aligned, preserving the values at the
corner pixels.
corner pixels.
Default: True
Default: True
align_mode(int) : An optional input to specify align_corners mode. can be
\'
0
\'
align_mode(int) : An optional input to specify src_idx calculation. can be
\'
0
\'
for pytorch calculation method, can be
\'
1'\ for tensorflow calculation method.
for src_idx = scale*(dst_indx+0.5)-0.5 , can be
\'
1
\'
for
src_idx = scale*dst_index .
Returns:
Returns:
Variable: The output is a 4-D tensor of the shape
Variable: The output is a 4-D tensor of the shape
...
@@ -6769,7 +6767,7 @@ def resize_bilinear(input,
...
@@ -6769,7 +6767,7 @@ def resize_bilinear(input,
Example:
Example:
f
or scale:
F
or scale:
if align_corners = True && out_size > 1 :
if align_corners = True && out_size > 1 :
...
@@ -6781,7 +6779,7 @@ def resize_bilinear(input,
...
@@ -6781,7 +6779,7 @@ def resize_bilinear(input,
Bilinear interpolation:
Bilinear interpolation:
case 1
:
if
:
align_corners = False , align_mode = 0
align_corners = False , align_mode = 0
input : (N,C,H_in,W_in)
input : (N,C,H_in,W_in)
...
@@ -6791,11 +6789,8 @@ def resize_bilinear(input,
...
@@ -6791,11 +6789,8 @@ def resize_bilinear(input,
W_out = (W_{in}+0.5) * scale_{factor} - 0.5
W_out = (W_{in}+0.5) * scale_{factor} - 0.5
case 2:
else:
align_corners = False , align_mode = 1
or
align_corners = True
input : (N,C,H_in,W_in)
input : (N,C,H_in,W_in)
output: (N,C,H_out,W_out) where:
output: (N,C,H_out,W_out) where:
...
@@ -6858,7 +6853,7 @@ def resize_nearest(input,
...
@@ -6858,7 +6853,7 @@ def resize_nearest(input,
Example:
Example:
f
or scale:
F
or scale:
if align_corners = True && out_size > 1 :
if align_corners = True && out_size > 1 :
...
...
python/paddle/fluid/tests/unittests/test_bilinear_interp_op.py
浏览文件 @
88744e4a
...
@@ -54,6 +54,7 @@ def bilinear_interp_np(input,
...
@@ -54,6 +54,7 @@ def bilinear_interp_np(input,
else
:
else
:
h
=
int
(
ratio_h
*
i
)
h
=
int
(
ratio_h
*
i
)
h
=
max
(
0
,
h
)
hid
=
1
if
h
<
in_h
-
1
else
0
hid
=
1
if
h
<
in_h
-
1
else
0
if
(
align_mode
==
0
and
not
align_corners
):
if
(
align_mode
==
0
and
not
align_corners
):
h1lambda
=
ratio_h
*
(
i
+
0.5
)
-
0.5
-
h
h1lambda
=
ratio_h
*
(
i
+
0.5
)
-
0.5
-
h
...
@@ -65,6 +66,7 @@ def bilinear_interp_np(input,
...
@@ -65,6 +66,7 @@ def bilinear_interp_np(input,
w
=
int
(
ratio_w
*
(
j
+
0.5
)
-
0.5
)
w
=
int
(
ratio_w
*
(
j
+
0.5
)
-
0.5
)
else
:
else
:
w
=
int
(
ratio_w
*
j
)
w
=
int
(
ratio_w
*
j
)
w
=
max
(
0
,
w
)
wid
=
1
if
w
<
in_w
-
1
else
0
wid
=
1
if
w
<
in_w
-
1
else
0
if
(
align_mode
==
0
and
not
align_corners
):
if
(
align_mode
==
0
and
not
align_corners
):
w1lambda
=
ratio_w
*
(
j
+
0.5
)
-
0.5
-
w
w1lambda
=
ratio_w
*
(
j
+
0.5
)
-
0.5
-
w
...
@@ -116,8 +118,8 @@ class TestBilinearInterpOp(OpTest):
...
@@ -116,8 +118,8 @@ class TestBilinearInterpOp(OpTest):
self
.
out_h
=
2
self
.
out_h
=
2
self
.
out_w
=
2
self
.
out_w
=
2
self
.
out_size
=
np
.
array
([
3
,
3
]).
astype
(
"int32"
)
self
.
out_size
=
np
.
array
([
3
,
3
]).
astype
(
"int32"
)
self
.
align_corners
=
Fals
e
self
.
align_corners
=
Tru
e
self
.
align_mode
=
0
self
.
align_mode
=
1
class
TestBilinearInterpCase1
(
TestBilinearInterpOp
):
class
TestBilinearInterpCase1
(
TestBilinearInterpOp
):
...
@@ -126,8 +128,8 @@ class TestBilinearInterpCase1(TestBilinearInterpOp):
...
@@ -126,8 +128,8 @@ class TestBilinearInterpCase1(TestBilinearInterpOp):
self
.
input_shape
=
[
4
,
1
,
7
,
8
]
self
.
input_shape
=
[
4
,
1
,
7
,
8
]
self
.
out_h
=
1
self
.
out_h
=
1
self
.
out_w
=
1
self
.
out_w
=
1
self
.
align_corners
=
Fals
e
self
.
align_corners
=
Tru
e
self
.
align_mode
=
0
self
.
align_mode
=
1
class
TestBilinearInterpCase2
(
TestBilinearInterpOp
):
class
TestBilinearInterpCase2
(
TestBilinearInterpOp
):
...
@@ -136,8 +138,8 @@ class TestBilinearInterpCase2(TestBilinearInterpOp):
...
@@ -136,8 +138,8 @@ class TestBilinearInterpCase2(TestBilinearInterpOp):
self
.
input_shape
=
[
3
,
3
,
9
,
6
]
self
.
input_shape
=
[
3
,
3
,
9
,
6
]
self
.
out_h
=
12
self
.
out_h
=
12
self
.
out_w
=
12
self
.
out_w
=
12
self
.
align_corners
=
Fals
e
self
.
align_corners
=
Tru
e
self
.
align_mode
=
0
self
.
align_mode
=
1
class
TestBilinearInterpCase3
(
TestBilinearInterpOp
):
class
TestBilinearInterpCase3
(
TestBilinearInterpOp
):
...
@@ -146,8 +148,8 @@ class TestBilinearInterpCase3(TestBilinearInterpOp):
...
@@ -146,8 +148,8 @@ class TestBilinearInterpCase3(TestBilinearInterpOp):
self
.
input_shape
=
[
1
,
1
,
128
,
64
]
self
.
input_shape
=
[
1
,
1
,
128
,
64
]
self
.
out_h
=
64
self
.
out_h
=
64
self
.
out_w
=
128
self
.
out_w
=
128
self
.
align_corners
=
Fals
e
self
.
align_corners
=
Tru
e
self
.
align_mode
=
0
self
.
align_mode
=
1
class
TestBilinearInterpCase4
(
TestBilinearInterpOp
):
class
TestBilinearInterpCase4
(
TestBilinearInterpOp
):
...
@@ -157,8 +159,8 @@ class TestBilinearInterpCase4(TestBilinearInterpOp):
...
@@ -157,8 +159,8 @@ class TestBilinearInterpCase4(TestBilinearInterpOp):
self
.
out_h
=
1
self
.
out_h
=
1
self
.
out_w
=
1
self
.
out_w
=
1
self
.
out_size
=
np
.
array
([
2
,
2
]).
astype
(
"int32"
)
self
.
out_size
=
np
.
array
([
2
,
2
]).
astype
(
"int32"
)
self
.
align_corners
=
Fals
e
self
.
align_corners
=
Tru
e
self
.
align_mode
=
0
self
.
align_mode
=
1
class
TestBilinearInterpCase5
(
TestBilinearInterpOp
):
class
TestBilinearInterpCase5
(
TestBilinearInterpOp
):
...
@@ -168,8 +170,8 @@ class TestBilinearInterpCase5(TestBilinearInterpOp):
...
@@ -168,8 +170,8 @@ class TestBilinearInterpCase5(TestBilinearInterpOp):
self
.
out_h
=
12
self
.
out_h
=
12
self
.
out_w
=
12
self
.
out_w
=
12
self
.
out_size
=
np
.
array
([
11
,
11
]).
astype
(
"int32"
)
self
.
out_size
=
np
.
array
([
11
,
11
]).
astype
(
"int32"
)
self
.
align_corners
=
Fals
e
self
.
align_corners
=
Tru
e
self
.
align_mode
=
0
self
.
align_mode
=
1
class
TestBilinearInterpCase6
(
TestBilinearInterpOp
):
class
TestBilinearInterpCase6
(
TestBilinearInterpOp
):
...
@@ -179,8 +181,8 @@ class TestBilinearInterpCase6(TestBilinearInterpOp):
...
@@ -179,8 +181,8 @@ class TestBilinearInterpCase6(TestBilinearInterpOp):
self
.
out_h
=
64
self
.
out_h
=
64
self
.
out_w
=
128
self
.
out_w
=
128
self
.
out_size
=
np
.
array
([
65
,
129
]).
astype
(
"int32"
)
self
.
out_size
=
np
.
array
([
65
,
129
]).
astype
(
"int32"
)
self
.
align_corners
=
Fals
e
self
.
align_corners
=
Tru
e
self
.
align_mode
=
0
self
.
align_mode
=
1
class
TestBilinearInterpActualShape
(
TestBilinearInterpOp
):
class
TestBilinearInterpActualShape
(
TestBilinearInterpOp
):
...
@@ -190,8 +192,8 @@ class TestBilinearInterpActualShape(TestBilinearInterpOp):
...
@@ -190,8 +192,8 @@ class TestBilinearInterpActualShape(TestBilinearInterpOp):
self
.
out_h
=
64
self
.
out_h
=
64
self
.
out_w
=
32
self
.
out_w
=
32
self
.
out_size
=
np
.
array
([
66
,
40
]).
astype
(
"int32"
)
self
.
out_size
=
np
.
array
([
66
,
40
]).
astype
(
"int32"
)
self
.
align_corners
=
Fals
e
self
.
align_corners
=
Tru
e
self
.
align_mode
=
0
self
.
align_mode
=
1
class
TestBilinearInterpOpUint8
(
OpTest
):
class
TestBilinearInterpOpUint8
(
OpTest
):
...
@@ -225,8 +227,8 @@ class TestBilinearInterpOpUint8(OpTest):
...
@@ -225,8 +227,8 @@ class TestBilinearInterpOpUint8(OpTest):
self
.
input_shape
=
[
1
,
3
,
9
,
6
]
self
.
input_shape
=
[
1
,
3
,
9
,
6
]
self
.
out_h
=
10
self
.
out_h
=
10
self
.
out_w
=
9
self
.
out_w
=
9
self
.
align_corners
=
Fals
e
self
.
align_corners
=
Tru
e
self
.
align_mode
=
0
self
.
align_mode
=
1
class
TestBilinearInterpCase1Uint8
(
TestBilinearInterpOpUint8
):
class
TestBilinearInterpCase1Uint8
(
TestBilinearInterpOpUint8
):
...
@@ -235,8 +237,8 @@ class TestBilinearInterpCase1Uint8(TestBilinearInterpOpUint8):
...
@@ -235,8 +237,8 @@ class TestBilinearInterpCase1Uint8(TestBilinearInterpOpUint8):
self
.
input_shape
=
[
2
,
3
,
128
,
64
]
self
.
input_shape
=
[
2
,
3
,
128
,
64
]
self
.
out_h
=
120
self
.
out_h
=
120
self
.
out_w
=
50
self
.
out_w
=
50
self
.
align_corners
=
Fals
e
self
.
align_corners
=
Tru
e
self
.
align_mode
=
0
self
.
align_mode
=
1
class
TestBilinearInterpCase2Uint8
(
TestBilinearInterpOpUint8
):
class
TestBilinearInterpCase2Uint8
(
TestBilinearInterpOpUint8
):
...
@@ -246,20 +248,20 @@ class TestBilinearInterpCase2Uint8(TestBilinearInterpOpUint8):
...
@@ -246,20 +248,20 @@ class TestBilinearInterpCase2Uint8(TestBilinearInterpOpUint8):
self
.
out_h
=
5
self
.
out_h
=
5
self
.
out_w
=
13
self
.
out_w
=
13
self
.
out_size
=
np
.
array
([
6
,
15
]).
astype
(
"int32"
)
self
.
out_size
=
np
.
array
([
6
,
15
]).
astype
(
"int32"
)
self
.
align_corners
=
Fals
e
self
.
align_corners
=
Tru
e
self
.
align_mode
=
0
self
.
align_mode
=
1
class
TestBilinearInterpOtherMethod1
(
TestBilinearInterpOp
):
class
TestBilinearInterpOtherMethod1
(
TestBilinearInterpOp
):
def
set_align_mode
(
self
):
def
set_align_mode
(
self
):
self
.
align_mode
=
1
self
.
align_corners
=
False
self
.
align_corners
=
False
self
.
align_mode
=
1
class
TestBilinearInterpWithMethod2
(
TestBilinearInterpOp
):
class
TestBilinearInterpWithMethod2
(
TestBilinearInterpOp
):
def
set_align_mode
(
self
):
def
set_align_mode
(
self
):
self
.
align_corners
=
Tru
e
self
.
align_corners
=
Fals
e
self
.
align_mode
=
1
self
.
align_mode
=
0
class
TestBilinearInterpWithMethod3
(
TestBilinearInterpOp
):
class
TestBilinearInterpWithMethod3
(
TestBilinearInterpOp
):
...
...
python/paddle/fluid/tests/unittests/test_nearest_interp_op.py
浏览文件 @
88744e4a
...
@@ -108,7 +108,7 @@ class TestNearestNeighborInterpCase1(TestNearestInterpOp):
...
@@ -108,7 +108,7 @@ class TestNearestNeighborInterpCase1(TestNearestInterpOp):
self
.
input_shape
=
[
4
,
1
,
7
,
8
]
self
.
input_shape
=
[
4
,
1
,
7
,
8
]
self
.
out_h
=
1
self
.
out_h
=
1
self
.
out_w
=
1
self
.
out_w
=
1
self
.
align_corners
=
Fals
e
self
.
align_corners
=
Tru
e
class
TestNearestNeighborInterpCase2
(
TestNearestInterpOp
):
class
TestNearestNeighborInterpCase2
(
TestNearestInterpOp
):
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录