Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
P
pytensor
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
testgroup
pytensor
Commits
dda7258b
提交
dda7258b
authored
7月 28, 2017
作者:
João Victor Risso
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Use values in range [0,1] in inputs and lower error tolerance in spatialtf tests
Signed-off-by:
João Victor Risso
<
joaovictor.risso@gmail.com
>
上级
c28761fe
显示空白字符变更
内嵌
并排
正在显示
1 个修改的文件
包含
13 行增加
和
17 行删除
+13
-17
test_dnn.py
theano/gpuarray/tests/test_dnn.py
+13
-17
没有找到文件。
theano/gpuarray/tests/test_dnn.py
浏览文件 @
dda7258b
...
@@ -2436,10 +2436,9 @@ def test_dnn_spatialtf():
...
@@ -2436,10 +2436,9 @@ def test_dnn_spatialtf():
grid
=
T
.
concatenate
([
x_t_flat
,
y_t_flat
,
ones
],
axis
=
0
)
grid
=
T
.
concatenate
([
x_t_flat
,
y_t_flat
,
ones
],
axis
=
0
)
return
grid
return
grid
# Generate random set of RGB images (pixel values in [0, 255]). The set of
# images is generated in the expected (NCHW) format
img_dims
=
(
5
,
3
,
16
,
16
)
img_dims
=
(
5
,
3
,
16
,
16
)
img
=
np
.
random
.
randint
(
low
=
0
,
high
=
256
,
size
=
img_dims
)
.
astype
(
theano
.
config
.
floatX
)
img
=
np
.
random
.
random
(
size
=
img_dims
)
.
astype
(
theano
.
config
.
floatX
)
scale_height
=
0.25
scale_height
=
0.25
scale_width
=
0.75
scale_width
=
0.75
...
@@ -2452,9 +2451,7 @@ def test_dnn_spatialtf():
...
@@ -2452,9 +2451,7 @@ def test_dnn_spatialtf():
t_img
=
T
.
tensor4
(
'img'
)
t_img
=
T
.
tensor4
(
'img'
)
t_theta
=
T
.
tensor3
(
'theta'
)
t_theta
=
T
.
tensor3
(
'theta'
)
st_dnn
=
dnn
.
dnn_spatialtf
(
t_img
,
t_theta
,
st_dnn
=
dnn
.
dnn_spatialtf
(
t_img
,
t_theta
,
scale_height
=
scale_height
,
scale_width
=
scale_width
)
scale_height
=
scale_height
,
scale_width
=
scale_width
)
st_dnn_func
=
theano
.
function
([
t_img
,
t_theta
],
st_dnn
)
st_dnn_func
=
theano
.
function
([
t_img
,
t_theta
],
st_dnn
)
# Check if function graph contains the spatial transformer's grid and sampler Ops
# Check if function graph contains the spatial transformer's grid and sampler Ops
apply_nodes
=
st_dnn_func
.
maker
.
fgraph
.
apply_nodes
apply_nodes
=
st_dnn_func
.
maker
.
fgraph
.
apply_nodes
...
@@ -2469,9 +2466,10 @@ def test_dnn_spatialtf():
...
@@ -2469,9 +2466,10 @@ def test_dnn_spatialtf():
st_cpu_func
=
theano
.
function
([
t_img
,
t_theta
],
st_cpu
,
mode
=
mode_without_gpu
)
st_cpu_func
=
theano
.
function
([
t_img
,
t_theta
],
st_cpu
,
mode
=
mode_without_gpu
)
img_out_cpu
=
st_cpu_func
(
img
,
theta
)
img_out_cpu
=
st_cpu_func
(
img
,
theta
)
atol
,
rtol
=
None
,
None
# use default absolute and relative error tolerances
atol
,
rtol
=
None
,
None
if
theano
.
config
.
floatX
==
'float16'
:
# float16 requires higher tolerances
if
theano
.
config
.
floatX
==
'float16'
:
atol
,
rtol
=
1e-0
,
1e-2
# Raise relative error tolerance when using float16
rtol
=
5e-2
utt
.
assert_allclose
(
img_out_cpu
,
img_out_gpu
,
atol
=
atol
,
rtol
=
rtol
)
utt
.
assert_allclose
(
img_out_cpu
,
img_out_gpu
,
atol
=
atol
,
rtol
=
rtol
)
...
@@ -2497,12 +2495,12 @@ def test_dnn_spatialtf_grad():
...
@@ -2497,12 +2495,12 @@ def test_dnn_spatialtf_grad():
assert
any
([
isinstance
(
node
.
op
,
dnn
.
GpuDnnTransformerGradT
)
assert
any
([
isinstance
(
node
.
op
,
dnn
.
GpuDnnTransformerGradT
)
for
node
in
f_gt
.
maker
.
fgraph
.
apply_nodes
])
for
node
in
f_gt
.
maker
.
fgraph
.
apply_nodes
])
# Generate random set of RGB images(pixel values in [0, 255]). The set of
# images is generated in the expected (NCHW) format
input_dims
=
(
5
,
3
,
16
,
16
)
input_dims
=
(
5
,
3
,
16
,
16
)
inputs_val
=
np
.
random
.
randint
(
low
=
0
,
high
=
256
,
size
=
input_dims
)
.
astype
(
theano
.
config
.
floatX
)
inputs_val
=
np
.
random
.
random
(
size
=
input_dims
)
.
astype
(
theano
.
config
.
floatX
)
# Tensor with transformations
# Tensor with transformations
theta_val
=
np
.
random
.
random
((
input_dims
[
0
],
2
,
3
))
.
astype
(
theano
.
config
.
floatX
)
theta_val
=
np
.
random
.
random
((
input_dims
[
0
],
2
,
3
))
.
astype
(
theano
.
config
.
floatX
)
theta
/=
100
# Check that the gradients are computed
# Check that the gradients are computed
f_gi
(
inputs_val
,
theta_val
)
f_gi
(
inputs_val
,
theta_val
)
...
@@ -2512,11 +2510,9 @@ def test_dnn_spatialtf_grad():
...
@@ -2512,11 +2510,9 @@ def test_dnn_spatialtf_grad():
out
=
dnn
.
dnn_spatialtf
(
inputs
,
theta
)
out
=
dnn
.
dnn_spatialtf
(
inputs
,
theta
)
return
out
return
out
atol
,
rtol
=
1e-3
,
1e-3
atol
,
rtol
=
None
,
None
if
theano
.
config
.
floatX
==
'float
32'
:
# use higher error tolerances with float32
if
theano
.
config
.
floatX
==
'float
16'
or
theano
.
config
.
floatX
==
'float32'
:
atol
,
rtol
=
1e-0
,
1e-1
atol
,
rtol
=
5e-2
,
5e-2
# Using float16 currently produces an infinite absolute error,
# thus the following test fails
utt
.
verify_grad
(
grad_functor
,
[
inputs_val
,
theta_val
],
mode
=
mode_with_gpu
,
utt
.
verify_grad
(
grad_functor
,
[
inputs_val
,
theta_val
],
mode
=
mode_with_gpu
,
abs_tol
=
atol
,
rel_tol
=
rtol
)
abs_tol
=
atol
,
rel_tol
=
rtol
)
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论