Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
P
pytensor
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
testgroup
pytensor
Commits
e78c6f90
提交
e78c6f90
authored
8月 28, 2008
作者:
Pascal Lamblin
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Cosmetic changes.
上级
0e361fb5
隐藏空白字符变更
内嵌
并排
正在显示
1 个修改的文件
包含
11 行增加
和
11 行删除
+11
-11
_test_tensor.py
_test_tensor.py
+11
-11
没有找到文件。
_test_tensor.py
浏览文件 @
e78c6f90
...
...
@@ -30,7 +30,7 @@ def make_tester(name, op, expected, checks = {}, good = {}, bad_build = {}, bad_
grad
=
good
_op
,
_expected
,
_checks
,
_good
,
_bad_build
,
_bad_runtime
,
_grad
=
op
,
expected
,
checks
,
good
,
bad_build
,
bad_runtime
,
grad
class
Checker
(
unittest
.
TestCase
):
op
=
_op
...
...
@@ -67,7 +67,7 @@ def make_tester(name, op, expected, checks = {}, good = {}, bad_build = {}, bad_
raise
type
,
exc_value
,
traceback
expecteds
=
self
.
expected
(
*
inputs
)
try
:
results
=
f
(
*
inputs
)
except
:
...
...
@@ -129,7 +129,7 @@ def make_tester(name, op, expected, checks = {}, good = {}, bad_build = {}, bad_
results
=
f
(
*
inputs
)
except
:
return
self
.
fail
(
"Test
%
s::
%
s: Successful call on the following bad inputs:
%
s"
%
(
self
.
op
,
testname
,
inputs
))
...
...
@@ -148,7 +148,7 @@ def make_tester(name, op, expected, checks = {}, good = {}, bad_build = {}, bad_
Checker
.
__name__
=
name
return
Checker
rand
=
lambda
*
shape
:
2
*
numpy
.
random
.
rand
(
*
shape
)
-
1
randint
=
lambda
*
shape
:
numpy
.
random
.
random_integers
(
-
5
,
5
,
shape
)
...
...
@@ -513,7 +513,7 @@ DotTester = make_tester(name = 'DotTester',
def
verify_grad
(
testcase
,
op
,
pt
,
n_tests
=
1
,
rng
=
numpy
.
random
,
eps
=
0.0000001
,
tol
=
0.0001
,
linker
=
'c&py'
):
"""testcase.failUnless(
analytic gradient matches finite-diff gradient)
"""
"""testcase.failUnless(
analytic gradient matches finite-diff gradient)
"""
pt
=
[
numpy
.
asarray
(
p
)
for
p
in
pt
]
for
test_num
in
xrange
(
n_tests
):
...
...
@@ -550,7 +550,7 @@ def verify_grad(testcase, op, pt, n_tests=1, rng=numpy.random, eps=0.0000001, to
print
op
grad_fn
=
function
(
tensor_pt
,
symbolic_grad
,
linker
=
linker
)
analytic_grad
=
grad_fn
(
*
pt
)
if
not
isinstance
(
analytic_grad
,
(
list
,
tuple
)):
analytic_grad
=
[
analytic_grad
]
...
...
@@ -697,7 +697,7 @@ class T_transpose(unittest.TestCase):
#test aliasing
tval
+=
55.0
self
.
failUnless
(
n
.
data
==
1.0
)
def
test1
(
self
):
n
=
as_tensor
(
numpy
.
ones
(
5
))
t
=
transpose
(
n
)
...
...
@@ -708,7 +708,7 @@ class T_transpose(unittest.TestCase):
#test aliasing
tval
+=
55.0
self
.
failUnless
(
n
.
data
[
0
]
==
1.0
)
def
test2
(
self
):
n
=
as_tensor
(
numpy
.
ones
((
5
,
3
)))
t
=
transpose
(
n
)
...
...
@@ -749,7 +749,7 @@ class T_subtensor(unittest.TestCase):
self
.
failUnless
(
e
[
0
]
is
Subtensor
.
e_invalid
)
return
self
.
fail
()
def
test1_err_bounds
(
self
):
n
=
as_tensor
(
numpy
.
ones
(
3
))
t
=
n
[
7
]
...
...
@@ -1025,7 +1025,7 @@ class _test_bitwise(unittest.TestCase):
r
=
numpy
.
asarray
([
0
,
1
,
0
,
1
],
dtype
=
'int8'
)
v
=
fn
(
l
,
r
)
self
.
failUnless
(
numpy
.
all
(
v
==
(
operator
.
and_
(
l
,
r
))),
(
l
,
r
,
v
))
def
test_inv
(
self
):
x
,
y
=
bvector
(),
bvector
()
fn
=
function
([
x
,
y
],
[
~
x
])
...
...
@@ -1473,7 +1473,7 @@ class t_gemm(unittest.TestCase):
A
=
self
.
rand
(
4
,
5
)[:,:
4
]
B
=
self
.
rand
(
4
,
5
)[:,:
4
]
C
=
self
.
rand
(
4
,
5
)[:,:
4
]
def
t
(
z
,
x
,
y
,
a
=
1.0
,
b
=
0.0
,
l
=
'c|py'
,
dt
=
'float64'
):
z
,
a
,
x
,
y
,
b
=
[
numpy
.
asarray
(
p
,
dtype
=
dt
)
for
p
in
z
,
a
,
x
,
y
,
b
]
z_orig
=
z
.
copy
()
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论