Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
P
pytensor
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
testgroup
pytensor
Commits
edd21a1d
提交
edd21a1d
authored
3月 28, 2012
作者:
Pascal Lamblin
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Do not test div on denominator too close to 0.
The numeric estimation of the gradient was sometimes quite off.
上级
2d2923f1
隐藏空白字符变更
内嵌
并排
正在显示
1 个修改的文件
包含
36 行增加
和
19 行删除
+36
-19
test_basic.py
theano/tensor/tests/test_basic.py
+36
-19
没有找到文件。
theano/tensor/tests/test_basic.py
浏览文件 @
edd21a1d
...
...
@@ -345,6 +345,17 @@ def rand(*shape):
return
r
*
2
-
1
def
rand_nonzero
(
shape
,
eps
=
3e-4
):
"""Like rand, but the absolute value has to be at least eps"""
# covers [0, 1)
r
=
numpy
.
asarray
(
numpy
.
random
.
rand
(
*
shape
),
dtype
=
config
.
floatX
)
# covers [0, (1 - eps) / 2) U [(1 + eps) / 2, 1)
r
=
r
*
(
1
-
eps
)
+
eps
*
(
r
>=
0.5
)
# covers [-1, -eps) U [eps, 1)
r
=
r
*
2
-
1
return
r
def
randint
(
*
shape
):
return
numpy
.
random
.
random_integers
(
-
5
,
5
,
shape
)
...
...
@@ -355,6 +366,10 @@ def randcomplex(*shape):
return
numpy
.
complex128
(
2
*
r
-
1
)
def
randcomplex_nonzero
(
shape
,
eps
=
1e-4
):
return
numpy
.
complex128
(
rand_nonzero
(
shape
,
eps
))
def
randint_nonzero
(
*
shape
):
r
=
numpy
.
random
.
random_integers
(
-
5
,
4
,
shape
)
return
r
+
(
r
==
0
)
*
5
...
...
@@ -559,6 +574,7 @@ MulInplaceTester = makeBroadcastTester(op = inplace.mul_inplace,
grad
=
_grad_broadcast_binary_normal
,
inplace
=
True
)
def
copymod
(
dct
,
without
=
[],
**
kwargs
):
"""Return dct but with the keys named by args removed, and with
kwargs added.
...
...
@@ -572,12 +588,12 @@ def copymod(dct, without=[], **kwargs):
return
rval
_good_broadcast_div_mod_normal_float_no_complex
=
dict
(
same_shapes
=
(
rand
(
2
,
3
),
rand
(
2
,
3
)),
scalar
=
(
rand
(
2
,
3
),
rand
(
1
,
1
)),
row
=
(
rand
(
2
,
3
),
rand
(
1
,
3
)),
column
=
(
rand
(
2
,
3
),
rand
(
2
,
1
)),
same_shapes
=
(
rand
(
2
,
3
),
rand
_nonzero
((
2
,
3
)
)),
scalar
=
(
rand
(
2
,
3
),
rand
_nonzero
((
1
,
1
)
)),
row
=
(
rand
(
2
,
3
),
rand
_nonzero
((
1
,
3
)
)),
column
=
(
rand
(
2
,
3
),
rand
_nonzero
((
2
,
1
)
)),
dtype_mixup_1
=
(
rand
(
2
,
3
),
randint_nonzero
(
2
,
3
)),
dtype_mixup_2
=
(
randint_nonzero
(
2
,
3
),
rand
(
2
,
3
)),
dtype_mixup_2
=
(
randint_nonzero
(
2
,
3
),
rand
_nonzero
((
2
,
3
)
)),
integer
=
(
randint
(
2
,
3
),
randint_nonzero
(
2
,
3
)),
uinteger
=
(
randint
(
2
,
3
)
.
astype
(
"uint8"
),
randint_nonzero
(
2
,
3
)
.
astype
(
"uint8"
)),
...
...
@@ -588,8 +604,8 @@ _good_broadcast_div_mod_normal_float_no_complex = dict(
_good_broadcast_div_mod_normal_float_inplace
=
copymod
(
_good_broadcast_div_mod_normal_float_no_complex
,
empty1
=
(
numpy
.
asarray
([]),
numpy
.
asarray
([
1
])),
complex1
=
(
randcomplex
(
2
,
3
),
randcomplex
(
2
,
3
)),
complex2
=
(
randcomplex
(
2
,
3
),
rand
(
2
,
3
)),
complex1
=
(
randcomplex
(
2
,
3
),
randcomplex
_nonzero
((
2
,
3
)
)),
complex2
=
(
randcomplex
(
2
,
3
),
rand
_nonzero
((
2
,
3
)
)),
# Inplace on the first element. Must have the same type.
#complex3=(rand(2, 3) ,randcomplex(2, 3)),
)
...
...
@@ -600,18 +616,19 @@ _good_broadcast_div_mod_normal_float = copymod(
)
_grad_broadcast_div_mod_normal
=
dict
(
same_shapes
=
(
rand
(
2
,
3
),
rand
(
2
,
3
)),
scalar
=
(
rand
(
2
,
3
),
rand
(
1
,
1
)),
row
=
(
rand
(
2
,
3
),
rand
(
1
,
3
)),
column
=
(
rand
(
2
,
3
),
rand
(
2
,
1
)),
#complex1 = (randcomplex(2,3),randcomplex(2,3)),
#complex2 = (randcomplex(2,3),rand(2,3)),
#complex3 = (rand(2,3),randcomplex(2,3)),
#dtype_mixup_1 = (rand(2, 3), randint_nonzero(2, 3)),
#dtype_mixup_2 = (randint_nonzero(2, 3), rand(2, 3)),
#empty1 = (numpy.asarray([]), numpy.asarray([1.])),
#empty2 = (numpy.asarray([0]), numpy.asarray([])),
)
_grad_broadcast_div_mod_normal
=
dict
(
same_shapes
=
(
rand
(
2
,
3
),
rand_nonzero
((
2
,
3
))),
scalar
=
(
rand
(
2
,
3
),
rand_nonzero
((
1
,
1
))),
row
=
(
rand
(
2
,
3
),
rand_nonzero
((
1
,
3
))),
column
=
(
rand
(
2
,
3
),
rand_nonzero
((
2
,
1
))),
#complex1=(randcomplex(2, 3), randcomplex_nonzero((2, 3))),
#complex2=(randcomplex(2, 3), rand_nonzero((2, 3))),
#complex3=(rand(2, 3), randcomplex_nonzero((2, 3))),
#dtype_mixup_1=(rand(2, 3), randint_nonzero(2, 3)),
#dtype_mixup_2=(randint_nonzero(2, 3), rand_nonzero((2, 3))),
#empty1=(numpy.asarray([]), numpy.asarray([1.])),
#empty2=(numpy.asarray([0]), numpy.asarray([])),
)
div_grad_rtol
=
None
if
config
.
floatX
==
'float32'
:
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论