Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
P
pytensor
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
testgroup
pytensor
Commits
27ca63bf
提交
27ca63bf
authored
8月 18, 2017
作者:
notoraptor
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Fix some failing tests.
上级
e63cea9b
隐藏空白字符变更
内嵌
并排
正在显示
1 个修改的文件
包含
14 行增加
和
13 行删除
+14
-13
test_dnn.py
theano/gpuarray/tests/test_dnn.py
+14
-13
没有找到文件。
theano/gpuarray/tests/test_dnn.py
浏览文件 @
27ca63bf
...
...
@@ -2302,6 +2302,9 @@ class TestDnnConv2DRuntimeAlgorithms(object):
]
def
__init__
(
self
):
if
not
dnn
.
dnn_available
(
test_ctx_name
):
raise
SkipTest
(
dnn
.
dnn_available
.
msg
)
utt
.
seed_rng
()
self
.
runtime_algorithms
=
(
'time_once'
,
'guess_once'
,
'time_on_shape_change'
,
'guess_on_shape_change'
)
def
test_fwd_runtime_algorithms
(
self
):
...
...
@@ -2312,16 +2315,18 @@ class TestDnnConv2DRuntimeAlgorithms(object):
def
run_fwd_runtime_algorithm
(
algo
):
inputs
=
theano
.
tensor
.
TensorType
(
dtype
,
_broadcastable
)()
filters
=
theano
.
tensor
.
TensorType
(
dtype
,
_broadcastable
)()
inputs
/=
10
filters
/=
10
conv
=
dnn
.
dnn_conv
(
img
=
inputs
,
kerns
=
filters
,
algo
=
algo
,
precision
=
dtype
,
# Scale down the input values to prevent very large absolute errors
# due to float rounding
lower_inputs
=
inputs
/
10
lower_filters
=
filters
/
10
conv
=
dnn
.
dnn_conv
(
img
=
lower_inputs
,
kerns
=
lower_filters
,
algo
=
algo
,
precision
=
dtype
,
subsample
=
unit_shape
,
dilation
=
unit_shape
)
f
=
theano
.
function
([
inputs
,
filters
],
conv
,
mode
=
mode_with_gpu
)
if
self
.
ndim
==
3
:
flipped_filters
=
filters
[:,
:,
::
-
1
,
::
-
1
,
::
-
1
]
flipped_filters
=
lower_
filters
[:,
:,
::
-
1
,
::
-
1
,
::
-
1
]
else
:
flipped_filters
=
filters
[:,
:,
::
-
1
,
::
-
1
]
conv_ref
=
self
.
cpu_conv_class
(
subsample
=
unit_shape
)(
ref_cast
(
inputs
),
flipped_filters
)
flipped_filters
=
lower_
filters
[:,
:,
::
-
1
,
::
-
1
]
conv_ref
=
self
.
cpu_conv_class
(
subsample
=
unit_shape
)(
ref_cast
(
lower_
inputs
),
flipped_filters
)
f_ref
=
theano
.
function
([
inputs
,
filters
],
conv_ref
,
mode
=
'FAST_RUN'
)
runtime_shapes
=
self
.
runtime_shapes
if
algo
in
(
'time_once'
,
'guess_once'
):
...
...
@@ -2333,7 +2338,7 @@ class TestDnnConv2DRuntimeAlgorithms(object):
filters_val
=
np
.
random
.
random
(
filters_shape
)
.
astype
(
dtype
)
gpu_res
=
f
(
inputs_val
,
filters_val
)
cpu_res
=
f_ref
(
inputs_val
,
filters_val
)
utt
.
assert_allclose
(
cpu_res
,
gpu_res
)
utt
.
assert_allclose
(
cpu_res
,
np
.
asarray
(
gpu_res
)
)
for
algo
in
self
.
runtime_algorithms
:
yield
(
run_fwd_runtime_algorithm
,
algo
)
...
...
@@ -2347,8 +2352,6 @@ class TestDnnConv2DRuntimeAlgorithms(object):
theano
.
config
.
dnn
.
conv
.
algo_bwd_data
=
algo
inputs
=
theano
.
tensor
.
TensorType
(
dtype
,
_broadcastable
)()
filters
=
theano
.
tensor
.
TensorType
(
dtype
,
_broadcastable
)()
inputs
/=
10
filters
/=
10
conv
=
dnn
.
dnn_conv
(
img
=
inputs
,
kerns
=
filters
,
algo
=
algo
,
precision
=
dtype
,
subsample
=
unit_shape
,
dilation
=
unit_shape
)
grad_i
=
theano
.
tensor
.
grad
(
conv
.
sum
(),
[
inputs
])
...
...
@@ -2373,7 +2376,7 @@ class TestDnnConv2DRuntimeAlgorithms(object):
filters_val
=
np
.
random
.
random
(
filters_shape
)
.
astype
(
dtype
)
gpu_res
=
f
(
inputs_val
,
filters_val
)
cpu_res
=
f_ref
(
inputs_val
,
filters_val
)
utt
.
assert_allclose
(
cpu_res
,
gpu_res
)
utt
.
assert_allclose
(
cpu_res
,
np
.
asarray
(
gpu_res
)
)
for
algo
in
self
.
runtime_algorithms
:
yield
(
run_gradinput_runtime_algorithm
,
algo
)
...
...
@@ -2387,8 +2390,6 @@ class TestDnnConv2DRuntimeAlgorithms(object):
theano
.
config
.
dnn
.
conv
.
algo_bwd_filter
=
algo
inputs
=
theano
.
tensor
.
TensorType
(
dtype
,
_broadcastable
)()
filters
=
theano
.
tensor
.
TensorType
(
dtype
,
_broadcastable
)()
inputs
/=
10
filters
/=
10
conv
=
dnn
.
dnn_conv
(
img
=
inputs
,
kerns
=
filters
,
algo
=
algo
,
precision
=
dtype
,
subsample
=
unit_shape
,
dilation
=
unit_shape
)
grad_w
=
theano
.
tensor
.
grad
(
conv
.
sum
(),
[
filters
])
...
...
@@ -2413,7 +2414,7 @@ class TestDnnConv2DRuntimeAlgorithms(object):
filters_val
=
np
.
random
.
random
(
filters_shape
)
.
astype
(
dtype
)
gpu_res
=
f
(
inputs_val
,
filters_val
)
cpu_res
=
f_ref
(
inputs_val
,
filters_val
)
utt
.
assert_allclose
(
cpu_res
,
gpu_res
)
utt
.
assert_allclose
(
cpu_res
,
np
.
asarray
(
gpu_res
)
)
for
algo
in
self
.
runtime_algorithms
:
yield
(
run_gradweight_runtime_algorithm
,
algo
)
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论