Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
P
pytensor
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
testgroup
pytensor
Commits
7b9c8bf9
提交
7b9c8bf9
authored
10月 07, 2008
作者:
James Bergstra
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fixed Split.__hash__, use default_mode for verify_grad in tensor/_test_basic
上级
280b9887
显示空白字符变更
内嵌
并排
正在显示
2 个修改的文件
包含
13 行增加
和
7 行删除
+13
-7
_test_basic.py
tensor/_test_basic.py
+9
-2
basic.py
tensor/basic.py
+4
-5
没有找到文件。
tensor/_test_basic.py
浏览文件 @
7b9c8bf9
...
@@ -28,6 +28,13 @@ def eval_outputs(outputs, mode = default_mode):
...
@@ -28,6 +28,13 @@ def eval_outputs(outputs, mode = default_mode):
return
results
[
0
]
return
results
[
0
]
return
results
return
results
_public_verify_grad
=
verify_grad
def
verify_grad
(
*
args
,
**
kwargs
):
assert
'mode'
not
in
kwargs
kwargs
[
'mode'
]
=
default_mode
r
=
_public_verify_grad
(
*
args
,
**
kwargs
)
return
r
def
_numpy_checker
(
x
,
y
):
def
_numpy_checker
(
x
,
y
):
"""
"""
...
@@ -1774,14 +1781,14 @@ class T_op_cache(unittest.TestCase):
...
@@ -1774,14 +1781,14 @@ class T_op_cache(unittest.TestCase):
self
.
failUnless
(
numpy
.
all
(
fn_py
(
a
)
==
fn_c_or_py
(
a
)))
self
.
failUnless
(
numpy
.
all
(
fn_py
(
a
)
==
fn_c_or_py
(
a
)))
if
__name__
==
'__main__'
:
if
__name__
==
'__main__'
:
if
1
:
if
len
(
sys
.
argv
)
>=
2
and
sys
.
argv
[
1
]
==
'OPT'
:
if
len
(
sys
.
argv
)
>=
2
and
sys
.
argv
[
1
]
==
'OPT'
:
default_mode
=
compile
.
Mode
(
linker
=
'c&py'
,
default_mode
=
compile
.
Mode
(
linker
=
'c&py'
,
optimizer
=
'math'
)
optimizer
=
'math'
)
sys
.
argv
[
1
:]
=
sys
.
argv
[
2
:]
sys
.
argv
[
1
:]
=
sys
.
argv
[
2
:]
if
1
:
unittest
.
main
()
unittest
.
main
()
else
:
else
:
testcase
=
DotTester
testcase
=
T_Join_and_Split
suite
=
unittest
.
TestLoader
()
suite
=
unittest
.
TestLoader
()
suite
=
suite
.
loadTestsFromTestCase
(
testcase
)
suite
=
suite
.
loadTestsFromTestCase
(
testcase
)
...
...
tensor/basic.py
浏览文件 @
7b9c8bf9
...
@@ -1394,7 +1394,7 @@ class Split(Op):
...
@@ -1394,7 +1394,7 @@ class Split(Op):
self
.
len_splits
==
other
.
len_splits
)
self
.
len_splits
==
other
.
len_splits
)
def
__hash__
(
self
):
def
__hash__
(
self
):
return
76612131345
^
len
(
self
.
len_splits
)
return
hash
(
Split
)
^
self
.
len_splits
def
make_node
(
self
,
x
,
axis
,
splits
):
def
make_node
(
self
,
x
,
axis
,
splits
):
"""WRITEME"""
"""WRITEME"""
...
@@ -2161,7 +2161,7 @@ class numeric_grad:
...
@@ -2161,7 +2161,7 @@ class numeric_grad:
return
numpy
.
max
(
errs
)
return
numpy
.
max
(
errs
)
def
verify_grad
(
testcase
,
op
,
pt
,
n_tests
=
1
,
rng
=
numpy
.
random
,
eps
=
1.0e-7
,
tol
=
0.0001
,
def
verify_grad
(
testcase
,
op
,
pt
,
n_tests
=
1
,
rng
=
numpy
.
random
,
eps
=
1.0e-7
,
tol
=
0.0001
,
linker
=
'c&py'
):
mode
=
compile
.
Mode
(
optimizer
=
None
,
linker
=
'c&py'
)
):
""" WRITEME
""" WRITEME
testcase.failUnless(analytic gradient matches finite-diff gradient)
testcase.failUnless(analytic gradient matches finite-diff gradient)
...
@@ -2172,9 +2172,8 @@ def verify_grad(testcase, op, pt, n_tests=1, rng=numpy.random, eps=1.0e-7, tol=0
...
@@ -2172,9 +2172,8 @@ def verify_grad(testcase, op, pt, n_tests=1, rng=numpy.random, eps=1.0e-7, tol=0
#print "PT", pt
#print "PT", pt
def
function
(
inputs
,
output
):
def
function
(
inputs
,
output
):
return
compile
.
function
(
inputs
,
output
,
f
=
compile
.
function
(
inputs
,
output
,
mode
=
mode
,
accept_inplace
=
True
)
mode
=
compile
.
Mode
(
optimizer
=
None
,
linker
=
linker
),
return
f
accept_inplace
=
True
)
for
test_num
in
xrange
(
n_tests
):
for
test_num
in
xrange
(
n_tests
):
tensor_pt
=
[
value
(
p
.
copy
(),
name
=
'input
%
i'
%
i
)
for
i
,
p
in
enumerate
(
pt
)]
tensor_pt
=
[
value
(
p
.
copy
(),
name
=
'input
%
i'
%
i
)
for
i
,
p
in
enumerate
(
pt
)]
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论