Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
P
pytensor
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
testgroup
pytensor
Commits
d464ec4c
提交
d464ec4c
authored
3月 23, 2017
作者:
amrithasuresh
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Updated numpy as np
上级
3076ff52
显示空白字符变更
内嵌
并排
正在显示
1 个修改的文件
包含
23 行增加
和
23 行删除
+23
-23
unittest_tools.py
theano/tests/unittest_tools.py
+23
-23
没有找到文件。
theano/tests/unittest_tools.py
浏览文件 @
d464ec4c
...
@@ -17,7 +17,7 @@ except ImportError:
...
@@ -17,7 +17,7 @@ except ImportError:
def
func
(
f
):
def
func
(
f
):
return
f
return
f
return
func
return
func
import
numpy
import
numpy
as
np
import
theano
import
theano
import
theano.tensor
as
T
import
theano.tensor
as
T
...
@@ -48,7 +48,7 @@ def fetch_seed(pseed=None):
...
@@ -48,7 +48,7 @@ def fetch_seed(pseed=None):
None, which is equivalent to seeding with a random seed.
None, which is equivalent to seeding with a random seed.
Useful for seeding RandomState objects.
Useful for seeding RandomState objects.
>>> rng = n
umpy
.random.RandomState(unittest_tools.fetch_seed())
>>> rng = n
p
.random.RandomState(unittest_tools.fetch_seed())
"""
"""
seed
=
pseed
or
config
.
unittests
.
rseed
seed
=
pseed
or
config
.
unittests
.
rseed
...
@@ -76,7 +76,7 @@ def seed_rng(pseed=None):
...
@@ -76,7 +76,7 @@ def seed_rng(pseed=None):
seed
=
fetch_seed
(
pseed
)
seed
=
fetch_seed
(
pseed
)
if
pseed
and
pseed
!=
seed
:
if
pseed
and
pseed
!=
seed
:
print
(
'Warning: using seed given by config.unittests.rseed=
%
i'
'instead of seed
%
i given as parameter'
%
(
seed
,
pseed
),
file
=
sys
.
stderr
)
print
(
'Warning: using seed given by config.unittests.rseed=
%
i'
'instead of seed
%
i given as parameter'
%
(
seed
,
pseed
),
file
=
sys
.
stderr
)
n
umpy
.
random
.
seed
(
seed
)
n
p
.
random
.
seed
(
seed
)
return
seed
return
seed
...
@@ -87,7 +87,7 @@ def verify_grad(op, pt, n_tests=2, rng=None, *args, **kwargs):
...
@@ -87,7 +87,7 @@ def verify_grad(op, pt, n_tests=2, rng=None, *args, **kwargs):
"""
"""
if
rng
is
None
:
if
rng
is
None
:
seed_rng
()
seed_rng
()
rng
=
n
umpy
.
random
rng
=
n
p
.
random
T
.
verify_grad
(
op
,
pt
,
n_tests
,
rng
,
*
args
,
**
kwargs
)
T
.
verify_grad
(
op
,
pt
,
n_tests
,
rng
,
*
args
,
**
kwargs
)
#
#
...
@@ -110,12 +110,12 @@ class MockRandomState:
...
@@ -110,12 +110,12 @@ class MockRandomState:
self
.
val
=
val
self
.
val
=
val
def
rand
(
self
,
*
shape
):
def
rand
(
self
,
*
shape
):
return
n
umpy
.
zeros
(
shape
,
dtype
=
'float64'
)
+
self
.
val
return
n
p
.
zeros
(
shape
,
dtype
=
'float64'
)
+
self
.
val
def
randint
(
self
,
minval
,
maxval
=
None
,
size
=
1
):
def
randint
(
self
,
minval
,
maxval
=
None
,
size
=
1
):
if
maxval
is
None
:
if
maxval
is
None
:
minval
,
maxval
=
0
,
minval
minval
,
maxval
=
0
,
minval
out
=
n
umpy
.
zeros
(
size
,
dtype
=
'int64'
)
out
=
n
p
.
zeros
(
size
,
dtype
=
'int64'
)
if
self
.
val
==
0
:
if
self
.
val
==
0
:
return
out
+
minval
return
out
+
minval
else
:
else
:
...
@@ -270,7 +270,7 @@ class InferShapeTester(unittest.TestCase):
...
@@ -270,7 +270,7 @@ class InferShapeTester(unittest.TestCase):
numeric_outputs
=
outputs_function
(
*
numeric_inputs
)
numeric_outputs
=
outputs_function
(
*
numeric_inputs
)
numeric_shapes
=
shapes_function
(
*
numeric_inputs
)
numeric_shapes
=
shapes_function
(
*
numeric_inputs
)
for
out
,
shape
in
zip
(
numeric_outputs
,
numeric_shapes
):
for
out
,
shape
in
zip
(
numeric_outputs
,
numeric_shapes
):
assert
n
umpy
.
all
(
out
.
shape
==
shape
),
(
out
.
shape
,
shape
)
assert
n
p
.
all
(
out
.
shape
==
shape
),
(
out
.
shape
,
shape
)
def
str_diagnostic
(
expected
,
value
,
rtol
,
atol
):
def
str_diagnostic
(
expected
,
value
,
rtol
,
atol
):
...
@@ -287,8 +287,8 @@ def str_diagnostic(expected, value, rtol, atol):
...
@@ -287,8 +287,8 @@ def str_diagnostic(expected, value, rtol, atol):
print
(
expected
.
strides
,
end
=
' '
,
file
=
ssio
)
print
(
expected
.
strides
,
end
=
' '
,
file
=
ssio
)
print
(
expected
.
min
(),
end
=
' '
,
file
=
ssio
)
print
(
expected
.
min
(),
end
=
' '
,
file
=
ssio
)
print
(
expected
.
max
(),
end
=
' '
,
file
=
ssio
)
print
(
expected
.
max
(),
end
=
' '
,
file
=
ssio
)
print
(
n
umpy
.
isinf
(
expected
)
.
sum
(),
end
=
' '
,
file
=
ssio
)
print
(
n
p
.
isinf
(
expected
)
.
sum
(),
end
=
' '
,
file
=
ssio
)
print
(
n
umpy
.
isnan
(
expected
)
.
sum
(),
end
=
' '
,
file
=
ssio
)
print
(
n
p
.
isnan
(
expected
)
.
sum
(),
end
=
' '
,
file
=
ssio
)
# only if all succeeds to we add anything to sio
# only if all succeeds to we add anything to sio
print
(
ssio
.
getvalue
(),
file
=
sio
)
print
(
ssio
.
getvalue
(),
file
=
sio
)
except
Exception
:
except
Exception
:
...
@@ -301,8 +301,8 @@ def str_diagnostic(expected, value, rtol, atol):
...
@@ -301,8 +301,8 @@ def str_diagnostic(expected, value, rtol, atol):
print
(
value
.
strides
,
end
=
' '
,
file
=
ssio
)
print
(
value
.
strides
,
end
=
' '
,
file
=
ssio
)
print
(
value
.
min
(),
end
=
' '
,
file
=
ssio
)
print
(
value
.
min
(),
end
=
' '
,
file
=
ssio
)
print
(
value
.
max
(),
end
=
' '
,
file
=
ssio
)
print
(
value
.
max
(),
end
=
' '
,
file
=
ssio
)
print
(
n
umpy
.
isinf
(
value
)
.
sum
(),
end
=
' '
,
file
=
ssio
)
print
(
n
p
.
isinf
(
value
)
.
sum
(),
end
=
' '
,
file
=
ssio
)
print
(
n
umpy
.
isnan
(
value
)
.
sum
(),
end
=
' '
,
file
=
ssio
)
print
(
n
p
.
isnan
(
value
)
.
sum
(),
end
=
' '
,
file
=
ssio
)
# only if all succeeds to we add anything to sio
# only if all succeeds to we add anything to sio
print
(
ssio
.
getvalue
(),
file
=
sio
)
print
(
ssio
.
getvalue
(),
file
=
sio
)
except
Exception
:
except
Exception
:
...
@@ -312,19 +312,19 @@ def str_diagnostic(expected, value, rtol, atol):
...
@@ -312,19 +312,19 @@ def str_diagnostic(expected, value, rtol, atol):
print
(
" value :"
,
value
,
file
=
sio
)
print
(
" value :"
,
value
,
file
=
sio
)
try
:
try
:
ov
=
n
umpy
.
asarray
(
expected
)
ov
=
n
p
.
asarray
(
expected
)
nv
=
n
umpy
.
asarray
(
value
)
nv
=
n
p
.
asarray
(
value
)
ssio
=
StringIO
()
ssio
=
StringIO
()
absdiff
=
n
umpy
.
absolute
(
nv
-
ov
)
absdiff
=
n
p
.
absolute
(
nv
-
ov
)
print
(
" Max Abs Diff: "
,
n
umpy
.
max
(
absdiff
),
file
=
ssio
)
print
(
" Max Abs Diff: "
,
n
p
.
max
(
absdiff
),
file
=
ssio
)
print
(
" Mean Abs Diff: "
,
n
umpy
.
mean
(
absdiff
),
file
=
ssio
)
print
(
" Mean Abs Diff: "
,
n
p
.
mean
(
absdiff
),
file
=
ssio
)
print
(
" Median Abs Diff: "
,
n
umpy
.
median
(
absdiff
),
file
=
ssio
)
print
(
" Median Abs Diff: "
,
n
p
.
median
(
absdiff
),
file
=
ssio
)
print
(
" Std Abs Diff: "
,
n
umpy
.
std
(
absdiff
),
file
=
ssio
)
print
(
" Std Abs Diff: "
,
n
p
.
std
(
absdiff
),
file
=
ssio
)
reldiff
=
n
umpy
.
absolute
(
nv
-
ov
)
/
numpy
.
absolute
(
ov
)
reldiff
=
n
p
.
absolute
(
nv
-
ov
)
/
np
.
absolute
(
ov
)
print
(
" Max Rel Diff: "
,
n
umpy
.
max
(
reldiff
),
file
=
ssio
)
print
(
" Max Rel Diff: "
,
n
p
.
max
(
reldiff
),
file
=
ssio
)
print
(
" Mean Rel Diff: "
,
n
umpy
.
mean
(
reldiff
),
file
=
ssio
)
print
(
" Mean Rel Diff: "
,
n
p
.
mean
(
reldiff
),
file
=
ssio
)
print
(
" Median Rel Diff: "
,
n
umpy
.
median
(
reldiff
),
file
=
ssio
)
print
(
" Median Rel Diff: "
,
n
p
.
median
(
reldiff
),
file
=
ssio
)
print
(
" Std Rel Diff: "
,
n
umpy
.
std
(
reldiff
),
file
=
ssio
)
print
(
" Std Rel Diff: "
,
n
p
.
std
(
reldiff
),
file
=
ssio
)
# only if all succeeds to we add anything to sio
# only if all succeeds to we add anything to sio
print
(
ssio
.
getvalue
(),
file
=
sio
)
print
(
ssio
.
getvalue
(),
file
=
sio
)
except
Exception
:
except
Exception
:
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论