Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
P
pytensor
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
testgroup
pytensor
Commits
c7c57776
提交
c7c57776
authored
3月 26, 2009
作者:
James Bergstra
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
cleaned up the printing of errors during testing tensor/test_basic
上级
24718ae9
隐藏空白字符变更
内嵌
并排
正在显示
4 个修改的文件
包含
31 行增加
和
13 行删除
+31
-13
opt.py
theano/gof/opt.py
+1
-2
optdb.py
theano/gof/optdb.py
+1
-1
basic.py
theano/tensor/basic.py
+1
-1
test_basic.py
theano/tensor/tests/test_basic.py
+28
-9
没有找到文件。
theano/gof/opt.py
浏览文件 @
c7c57776
...
@@ -900,9 +900,8 @@ class EquilibriumOptimizer(NavigatorOptimizer):
...
@@ -900,9 +900,8 @@ class EquilibriumOptimizer(NavigatorOptimizer):
lopt_change
=
self
.
process_node
(
env
,
node
,
lopt
)
lopt_change
=
self
.
process_node
(
env
,
node
,
lopt
)
process_count
[
lopt
]
+=
1
if
lopt_change
else
0
process_count
[
lopt
]
+=
1
if
lopt_change
else
0
changed
|=
lopt_change
changed
|=
lopt_change
except
:
finally
:
self
.
detach_updater
(
env
,
u
)
self
.
detach_updater
(
env
,
u
)
raise
self
.
detach_updater
(
env
,
u
)
self
.
detach_updater
(
env
,
u
)
if
max_use_abort
:
if
max_use_abort
:
print
>>
sys
.
stderr
,
"WARNING: EquilibriumOptimizer max'ed out"
print
>>
sys
.
stderr
,
"WARNING: EquilibriumOptimizer max'ed out"
...
...
theano/gof/optdb.py
浏览文件 @
c7c57776
...
@@ -120,7 +120,7 @@ class EquilibriumDB(DB):
...
@@ -120,7 +120,7 @@ class EquilibriumDB(DB):
return
opt
.
EquilibriumOptimizer
(
opts
,
return
opt
.
EquilibriumOptimizer
(
opts
,
max_depth
=
5
,
max_depth
=
5
,
max_use_ratio
=
10
,
max_use_ratio
=
10
,
failure_callback
=
opt
.
NavigatorOptimizer
.
warn
)
failure_callback
=
opt
.
NavigatorOptimizer
.
warn
_inplace
)
class
SequenceDB
(
DB
):
class
SequenceDB
(
DB
):
...
...
theano/tensor/basic.py
浏览文件 @
c7c57776
...
@@ -858,7 +858,7 @@ class MaxAndArgmax(Op):
...
@@ -858,7 +858,7 @@ class MaxAndArgmax(Op):
axis
=
x
.
type
.
ndim
-
1
axis
=
x
.
type
.
ndim
-
1
axis
=
_as_tensor_variable
(
axis
)
axis
=
_as_tensor_variable
(
axis
)
inputs
=
[
x
,
axis
]
inputs
=
[
x
,
axis
]
broadcastable
=
[
False
]
*
(
x
.
type
.
ndim
-
1
)
broadcastable
=
[
False
]
*
(
x
.
type
.
ndim
-
1
)
#TODO: be less conservative
outputs
=
[
tensor
(
x
.
type
.
dtype
,
broadcastable
),
outputs
=
[
tensor
(
x
.
type
.
dtype
,
broadcastable
),
tensor
(
axis
.
type
.
dtype
,
broadcastable
)]
tensor
(
axis
.
type
.
dtype
,
broadcastable
)]
return
Apply
(
self
,
inputs
,
outputs
)
return
Apply
(
self
,
inputs
,
outputs
)
...
...
theano/tensor/tests/test_basic.py
浏览文件 @
c7c57776
...
@@ -628,18 +628,26 @@ class T_max_and_argmax(unittest.TestCase):
...
@@ -628,18 +628,26 @@ class T_max_and_argmax(unittest.TestCase):
self
.
failUnless
(
numpy
.
all
(
i
==
numpy
.
argmax
(
data
,
0
)))
self
.
failUnless
(
numpy
.
all
(
i
==
numpy
.
argmax
(
data
,
0
)))
def
test2_invalid
(
self
):
def
test2_invalid
(
self
):
n
=
as_tensor_variable
(
numpy
.
random
.
rand
(
2
,
3
))
n
=
as_tensor_variable
(
numpy
.
random
.
rand
(
2
,
3
))
old_stderr
=
sys
.
stderr
sys
.
stderr
=
StringIO
.
StringIO
()
try
:
try
:
eval_outputs
(
max_and_argmax
(
n
,
3
))
eval_outputs
(
max_and_argmax
(
n
,
3
))
assert
False
except
ValueError
,
e
:
except
ValueError
,
e
:
return
pass
self
.
fail
()
finally
:
sys
.
stderr
=
old_stderr
def
test2_invalid_neg
(
self
):
def
test2_invalid_neg
(
self
):
n
=
as_tensor_variable
(
numpy
.
random
.
rand
(
2
,
3
))
n
=
as_tensor_variable
(
numpy
.
random
.
rand
(
2
,
3
))
old_stderr
=
sys
.
stderr
sys
.
stderr
=
StringIO
.
StringIO
()
try
:
try
:
eval_outputs
(
max_and_argmax
(
n
,
-
3
))
eval_outputs
(
max_and_argmax
(
n
,
-
3
))
assert
False
except
ValueError
,
e
:
except
ValueError
,
e
:
return
pass
self
.
fail
()
finally
:
sys
.
stderr
=
old_stderr
def
test2_valid_neg
(
self
):
def
test2_valid_neg
(
self
):
n
=
as_tensor_variable
(
numpy
.
random
.
rand
(
2
,
3
))
n
=
as_tensor_variable
(
numpy
.
random
.
rand
(
2
,
3
))
v
,
i
=
eval_outputs
(
max_and_argmax
(
n
,
-
1
))
v
,
i
=
eval_outputs
(
max_and_argmax
(
n
,
-
1
))
...
@@ -678,13 +686,16 @@ class T_subtensor(unittest.TestCase):
...
@@ -678,13 +686,16 @@ class T_subtensor(unittest.TestCase):
n
=
as_tensor_variable
(
numpy
.
ones
(
3
))
n
=
as_tensor_variable
(
numpy
.
ones
(
3
))
t
=
n
[
7
]
t
=
n
[
7
]
self
.
failUnless
(
isinstance
(
t
.
owner
.
op
,
Subtensor
))
self
.
failUnless
(
isinstance
(
t
.
owner
.
op
,
Subtensor
))
old_stderr
=
sys
.
stderr
sys
.
stderr
=
StringIO
.
StringIO
()
try
:
try
:
tval
=
eval_outputs
([
t
])
tval
=
eval_outputs
([
t
])
assert
0
except
Exception
,
e
:
except
Exception
,
e
:
if
e
[
0
]
!=
'index out of bounds'
:
if
e
[
0
]
!=
'index out of bounds'
:
raise
raise
return
finally
:
self
.
fail
()
sys
.
stderr
=
old_stderr
def
test1_err_subslice
(
self
):
def
test1_err_subslice
(
self
):
n
=
as_tensor_variable
(
numpy
.
ones
(
3
))
n
=
as_tensor_variable
(
numpy
.
ones
(
3
))
try
:
try
:
...
@@ -748,20 +759,28 @@ class T_subtensor(unittest.TestCase):
...
@@ -748,20 +759,28 @@ class T_subtensor(unittest.TestCase):
n
=
as_tensor_variable
(
numpy
.
ones
((
2
,
3
))
*
5
)
n
=
as_tensor_variable
(
numpy
.
ones
((
2
,
3
))
*
5
)
t
=
n
[
0
,
4
]
t
=
n
[
0
,
4
]
self
.
failUnless
(
isinstance
(
t
.
owner
.
op
,
Subtensor
))
self
.
failUnless
(
isinstance
(
t
.
owner
.
op
,
Subtensor
))
old_stderr
=
sys
.
stderr
sys
.
stderr
=
StringIO
.
StringIO
()
try
:
try
:
tval
=
eval_outputs
([
t
])
tval
=
eval_outputs
([
t
])
assert
0
except
IndexError
,
e
:
except
IndexError
,
e
:
return
pass
self
.
fail
()
finally
:
sys
.
stderr
=
old_stderr
def
test2_err_bounds1
(
self
):
def
test2_err_bounds1
(
self
):
n
=
as_tensor_variable
(
numpy
.
ones
((
2
,
3
))
*
5
)
n
=
as_tensor_variable
(
numpy
.
ones
((
2
,
3
))
*
5
)
t
=
n
[
4
:
5
,
2
]
t
=
n
[
4
:
5
,
2
]
self
.
failUnless
(
isinstance
(
t
.
owner
.
op
,
Subtensor
))
self
.
failUnless
(
isinstance
(
t
.
owner
.
op
,
Subtensor
))
old_stderr
=
sys
.
stderr
sys
.
stderr
=
StringIO
.
StringIO
()
try
:
try
:
tval
=
eval_outputs
([
t
])
tval
=
eval_outputs
([
t
])
except
Exception
,
e
:
except
Exception
,
e
:
if
e
[
0
]
!=
'index out of bounds'
:
if
e
[
0
]
!=
'index out of bounds'
:
raise
raise
finally
:
sys
.
stderr
=
old_stderr
def
test2_ok_elem
(
self
):
def
test2_ok_elem
(
self
):
n
=
as_tensor_variable
(
numpy
.
asarray
(
range
(
6
))
.
reshape
((
2
,
3
)))
n
=
as_tensor_variable
(
numpy
.
asarray
(
range
(
6
))
.
reshape
((
2
,
3
)))
t
=
n
[
0
,
2
]
t
=
n
[
0
,
2
]
...
@@ -1364,9 +1383,9 @@ class t_dot(unittest.TestCase):
...
@@ -1364,9 +1383,9 @@ class t_dot(unittest.TestCase):
def
not_aligned
(
self
,
x
,
y
):
def
not_aligned
(
self
,
x
,
y
):
z
=
dot
(
x
,
y
)
z
=
dot
(
x
,
y
)
old_stderr
=
sys
.
stderr
# constant folding will complain to stderr that things are not aligned
# constant folding will complain to stderr that things are not aligned
# this is normal, testers are not interested in seeing that output.
# this is normal, testers are not interested in seeing that output.
old_stderr
=
sys
.
stderr
sys
.
stderr
=
StringIO
.
StringIO
()
sys
.
stderr
=
StringIO
.
StringIO
()
try
:
try
:
tz
=
eval_outputs
([
z
])
tz
=
eval_outputs
([
z
])
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论