Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
P
pytensor
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
testgroup
pytensor
Commits
7128cc76
提交
7128cc76
authored
9月 15, 2017
作者:
notoraptor
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Try to scale down outputs computed with an alpha != 1, to help
reduce number of WrongValue errors.
上级
3eba3e5a
隐藏空白字符变更
内嵌
并排
正在显示
1 个修改的文件
包含
14 行增加
和
8 行删除
+14
-8
check_dnn_conv.py
theano/gpuarray/tests/check_dnn_conv.py
+14
-8
没有找到文件。
theano/gpuarray/tests/check_dnn_conv.py
浏览文件 @
7128cc76
...
...
@@ -570,16 +570,22 @@ class BaseTestDnnConv(object):
val
//=
10
return
ten_exponent
def
scale_numpy_arrays_inplace
(
self
,
A
,
B
):
def
scale_numpy_arrays_inplace
(
self
,
A
,
B
,
alpha
):
scale_factor
=
1
# Scale down simultaneously A and B if alpha is not 1.
if
alpha
!=
1
:
scale_factor
*=
alpha
# Normalize A and B simultaneously so that any values in these tensors are in interval [0, 1)
max_a
=
math
.
floor
(
abs
(
A
.
max
()))
max_b
=
math
.
floor
(
abs
(
B
.
max
()))
if
max_a
>
0
or
max_b
>
0
:
if
max_a
or
max_b
:
m_a
=
self
.
_next_ten_exponent
(
max_a
)
m_b
=
self
.
_next_ten_exponent
(
max_b
)
max_m
=
max
(
m_a
,
m_b
)
A
/=
10
**
max_m
B
/=
10
**
max_m
scale_factor
*=
10
**
max_m
if
scale_factor
!=
1
:
A
/=
scale_factor
B
/=
scale_factor
def
__init__
(
self
):
utt
.
seed_rng
(
1234
)
...
...
@@ -644,7 +650,7 @@ class BaseTestDnnConv(object):
cpu_res
=
alpha
*
res_ref
else
:
cpu_res
=
alpha
*
res_ref
+
beta
*
out
self
.
scale_numpy_arrays_inplace
(
cpu_res
,
res
)
self
.
scale_numpy_arrays_inplace
(
cpu_res
,
res
,
alpha
)
utt
.
assert_allclose
(
cpu_res
,
res
,
rtol
=
rtol
)
def
run_conv_gradinput
(
self
,
algo
,
dtype
,
precision
,
parameters
):
...
...
@@ -701,7 +707,7 @@ class BaseTestDnnConv(object):
cpu_res
=
alpha
*
res_ref
else
:
cpu_res
=
alpha
*
res_ref
+
beta
*
inputs_val
self
.
scale_numpy_arrays_inplace
(
cpu_res
,
res
)
self
.
scale_numpy_arrays_inplace
(
cpu_res
,
res
,
alpha
)
utt
.
assert_allclose
(
cpu_res
,
res
,
rtol
=
rtol
)
def
run_conv_gradweight
(
self
,
algo
,
dtype
,
precision
,
parameters
):
...
...
@@ -753,7 +759,7 @@ class BaseTestDnnConv(object):
cpu_res
=
alpha
*
res_ref
else
:
cpu_res
=
alpha
*
res_ref
+
beta
*
filters_val
self
.
scale_numpy_arrays_inplace
(
cpu_res
,
res
)
self
.
scale_numpy_arrays_inplace
(
cpu_res
,
res
,
alpha
)
utt
.
assert_allclose
(
cpu_res
,
res
,
rtol
=
rtol
)
def
should_fail
(
self
,
function
,
*
args
):
...
...
@@ -886,7 +892,7 @@ class BaseTestDnnConv(object):
filters_val
=
np
.
random
.
random
(
filters_shape
)
.
astype
(
dtype
)
gpu_res
=
np
.
asarray
(
f
(
inputs_val
,
filters_val
))
cpu_res
=
f_ref
(
inputs_val
,
filters_val
)
self
.
scale_numpy_arrays_inplace
(
cpu_res
,
gpu_res
)
self
.
scale_numpy_arrays_inplace
(
cpu_res
,
gpu_res
,
1
)
utt
.
assert_allclose
(
cpu_res
,
gpu_res
)
for
algo
in
SUPPORTED_DNN_CONV_ALGO_RUNTIME
:
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论