Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
P
pytensor
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
testgroup
pytensor
Commits
471aa985
提交
471aa985
authored
2月 28, 2012
作者:
Pascal Lamblin
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Ignore unused inputs in some tests.
上级
287ffba8
显示空白字符变更
内嵌
并排
正在显示
5 个修改的文件
包含
54 行增加
和
16 行删除
+54
-16
test_function_module.py
theano/compile/tests/test_function_module.py
+36
-3
test_basic.py
theano/tensor/tests/test_basic.py
+4
-2
test_blas.py
theano/tensor/tests/test_blas.py
+6
-4
test_opt.py
theano/tensor/tests/test_opt.py
+3
-2
test_rop.py
theano/tests/test_rop.py
+5
-5
没有找到文件。
theano/compile/tests/test_function_module.py
浏览文件 @
471aa985
...
...
@@ -54,26 +54,45 @@ class T_function(unittest.TestCase):
def
test_missing_inputs
(
self
):
MissingInputException
=
TypeError
UnusedInputException
=
ValueError
def
fn
():
x
,
s
=
T
.
scalars
(
'xs'
)
fn
=
function
([],
[
x
])
checkfor
(
self
,
fn
,
MissingInputException
)
def
fn
():
x
,
s
=
T
.
scalars
(
'xs'
)
# Ignore unused input s, as it hides the other error
fn
=
function
([
s
],
[
x
],
on_unused_input
=
'ignore'
)
checkfor
(
self
,
fn
,
MissingInputException
)
def
fn
():
x
,
s
=
T
.
scalars
(
'xs'
)
fn
=
function
([
s
],
[
x
])
checkfor
(
self
,
fn
,
UnusedInputException
)
def
fn
():
x
,
s
=
T
.
scalars
(
'xs'
)
# Ignore unused input s, as it hides the other error
fn
=
function
([
s
],
x
,
on_unused_input
=
'ignore'
)
checkfor
(
self
,
fn
,
MissingInputException
)
def
fn
():
x
,
s
=
T
.
scalars
(
'xs'
)
fn
=
function
([
s
],
x
)
checkfor
(
self
,
fn
,
UnusedInputException
)
def
fn
():
x
,
s
=
T
.
scalars
(
'xs'
)
# Ignore unused input s, as it hides the other error
fn
=
function
([
s
],
Out
(
x
),
on_unused_input
=
'ignore'
)
checkfor
(
self
,
fn
,
MissingInputException
)
def
fn
():
x
,
s
=
T
.
scalars
(
'xs'
)
fn
=
function
([
s
],
Out
(
x
))
checkfor
(
self
,
fn
,
Missing
InputException
)
checkfor
(
self
,
fn
,
Unused
InputException
)
def
fn
():
x
,
s
=
T
.
scalars
(
'xs'
)
...
...
@@ -124,7 +143,8 @@ class T_function(unittest.TestCase):
x
,
s
=
T
.
scalars
(
'xs'
)
#x's name is ignored because it is followed by anonymous parameter a.
f
=
function
([
x
,
a
,
s
],
a
/
s
)
# Ignore unused input x, as it hides the other error
f
=
function
([
x
,
a
,
s
],
a
/
s
,
on_unused_input
=
'ignore'
)
self
.
assertTrue
(
f
(
9
,
1
,
2
)
==
0.5
)
self
.
assertTrue
(
f
(
9
,
2
,
1
)
==
2.0
)
self
.
assertTrue
(
f
(
9
,
2
,
s
=
1
)
==
2.0
)
...
...
@@ -355,6 +375,20 @@ class T_function(unittest.TestCase):
f
(
o
+.
1
)
#should clobber the memory used to store four
assert
not
numpy
.
all
(
four
==
4
)
def
test_disconnected_input
(
self
):
a
=
T
.
scalar
(
'a'
)
v
=
T
.
vector
(
'v'
)
self
.
assertRaises
(
ValueError
,
function
,
[
a
,
v
],
v
*
2
)
f
=
function
([
a
,
v
],
v
*
2
,
on_unused_input
=
'ignore'
)
def
test_masked_input
(
self
):
m
=
T
.
matrix
(
'm'
)
mt
=
m
.
T
mt
.
name
=
'm.T'
self
.
assertRaises
(
ValueError
,
function
,
[
m
,
mt
],
mt
*
2
)
f
=
function
([
m
,
mt
],
mt
*
2
,
on_unused_input
=
'ignore'
)
class
T_picklefunction
(
unittest
.
TestCase
):
def
test_deepcopy
(
self
):
...
...
@@ -631,7 +665,6 @@ class T_picklefunction(unittest.TestCase):
assert
blah
.
f1
[
blah
.
s
]
!=
blah2
.
f1
[
blah2
.
s
]
class
SomethingToPickle
(
object
):
def
__init__
(
self
):
a
=
T
.
scalar
()
# the a is for 'anonymous' (un-named).
...
...
theano/tensor/tests/test_basic.py
浏览文件 @
471aa985
...
...
@@ -57,13 +57,15 @@ else:
utt
.
seed_rng
()
def
inplace_func
(
inputs
,
outputs
,
mode
=
None
,
allow_input_downcast
=
False
):
def
inplace_func
(
inputs
,
outputs
,
mode
=
None
,
allow_input_downcast
=
False
,
on_unused_input
=
'raise'
):
if
mode
is
None
:
mode
=
get_default_mode
()
return
function
(
inputs
,
outputs
,
mode
=
mode
,
allow_input_downcast
=
allow_input_downcast
,
accept_inplace
=
True
)
accept_inplace
=
True
,
on_unused_input
=
on_unused_input
)
def
eval_outputs
(
outputs
):
...
...
theano/tensor/tests/test_blas.py
浏览文件 @
471aa985
...
...
@@ -399,7 +399,8 @@ def just_gemm(i, o, ishapes = [(4,3), (3,5), (4,5), (), ()], max_graphlen=0):
f
=
inplace_func
(
[
Param
(
ii
,
mutable
=
True
,
allow_downcast
=
True
)
for
ii
in
i
],
o
,
mode
=
'FAST_RUN'
)
mode
=
'FAST_RUN'
,
on_unused_input
=
'ignore'
)
at_least_one_gemm
=
False
for
node
in
f
.
maker
.
env
.
nodes
:
if
node
.
op
==
T
.
dot
:
...
...
@@ -410,7 +411,7 @@ def just_gemm(i, o, ishapes = [(4,3), (3,5), (4,5), (), ()], max_graphlen=0):
at_least_one_gemm
=
True
assert
at_least_one_gemm
g
=
inplace_func
(
i
,
o
,
mode
=
compile
.
Mode
(
linker
=
'py'
,
optimizer
=
None
),
allow_input_downcast
=
True
)
allow_input_downcast
=
True
,
on_unused_input
=
'ignore'
)
for
node
in
g
.
maker
.
env
.
nodes
:
if
node
.
op
==
gemm_inplace
:
raise
Exception
(
'gemm_inplace in original graph'
)
...
...
@@ -475,11 +476,12 @@ def test_gemm_opt_double_gemm():
+
gemm_inplace
(
Z
,
b
,
S
.
T
,
R
.
T
,
T
.
constant
(
1.0
)
.
astype
(
'float64'
)))]
try
:
f
=
inplace_func
([
Param
(
ii
,
mutable
=
True
)
for
ii
in
i
],
o
,
mode
=
'FAST_RUN'
)
mode
=
'FAST_RUN'
,
on_unused_input
=
'ignore'
)
for
node
in
f
.
maker
.
env
.
nodes
:
if
node
.
op
==
T
.
dot
:
raise
Failure
(
'dot in graph'
)
if
node
.
op
==
_dot22
:
raise
Failure
(
'_dot22 in graph'
)
g
=
inplace_func
(
i
,
o
,
mode
=
compile
.
Mode
(
linker
=
'py'
,
optimizer
=
None
))
g
=
inplace_func
(
i
,
o
,
mode
=
compile
.
Mode
(
linker
=
'py'
,
optimizer
=
None
),
on_unused_input
=
'ignore'
)
#for node in g.maker.env.nodes:
# if node.op == gemm_inplace: raise Failure('gemm_inplace in graph')
...
...
theano/tensor/tests/test_opt.py
浏览文件 @
471aa985
...
...
@@ -3256,7 +3256,8 @@ class T_local_sum_dimshuffle(unittest.TestCase):
try
:
for
i
,
s
in
enumerate
(
sums
):
print
i
f
=
theano
.
function
([
a
,
b
,
c
,
d
],
s
,
mode
=
self
.
mode
)
f
=
theano
.
function
([
a
,
b
,
c
,
d
],
s
,
mode
=
self
.
mode
,
on_unused_input
=
'ignore'
)
theano
.
printing
.
debugprint
(
f
)
g
=
f
.
maker
.
env
.
toposort
()
#print 'g =', g
...
...
@@ -3294,7 +3295,7 @@ def test_make_vector():
]:
mv
=
opt
.
MakeVector
(
dtype
=
dtype
)(
*
inputs
)
assert
mv
.
dtype
==
dtype
f
=
theano
.
function
([
b
,
i
,
d
],
mv
)
f
=
theano
.
function
([
b
,
i
,
d
],
mv
,
on_unused_input
=
'ignore'
)
f_val
=
f
(
val
[
b
],
val
[
i
],
val
[
d
])
#print 'f_val =', f_val
...
...
theano/tests/test_rop.py
浏览文件 @
471aa985
...
...
@@ -106,12 +106,12 @@ class RopLop_checker(unittest.TestCase):
vv
=
numpy
.
asarray
(
self
.
rng
.
uniform
(
size
=
self
.
mat_in_shape
),
theano
.
config
.
floatX
)
yv
=
tensor
.
Rop
(
y
,
self
.
mx
,
self
.
mv
)
rop_f
=
function
([
self
.
mx
,
self
.
mv
],
yv
)
rop_f
=
function
([
self
.
mx
,
self
.
mv
],
yv
,
on_unused_input
=
'ignore'
)
sy
,
_
=
theano
.
scan
(
lambda
i
,
y
,
x
,
v
:
\
(
tensor
.
grad
(
y
[
i
],
x
)
*
v
)
.
sum
(),
sequences
=
tensor
.
arange
(
y
.
shape
[
0
]),
non_sequences
=
[
y
,
self
.
mx
,
self
.
mv
])
scan_f
=
function
([
self
.
mx
,
self
.
mv
],
sy
)
scan_f
=
function
([
self
.
mx
,
self
.
mv
],
sy
,
on_unused_input
=
'ignore'
)
v1
=
rop_f
(
vx
,
vv
)
v2
=
scan_f
(
vx
,
vv
)
...
...
@@ -146,13 +146,13 @@ class RopLop_checker(unittest.TestCase):
theano
.
config
.
floatX
)
yv
=
tensor
.
Rop
(
y
,
self
.
x
,
self
.
v
)
rop_f
=
function
([
self
.
x
,
self
.
v
],
yv
)
rop_f
=
function
([
self
.
x
,
self
.
v
],
yv
,
on_unused_input
=
'ignore'
)
J
,
_
=
theano
.
scan
(
lambda
i
,
y
,
x
:
tensor
.
grad
(
y
[
i
],
x
),
sequences
=
tensor
.
arange
(
y
.
shape
[
0
]),
non_sequences
=
[
y
,
self
.
x
])
sy
=
tensor
.
dot
(
J
,
self
.
v
)
scan_f
=
function
([
self
.
x
,
self
.
v
],
sy
)
scan_f
=
function
([
self
.
x
,
self
.
v
],
sy
,
on_unused_input
=
'ignore'
)
v1
=
rop_f
(
vx
,
vv
)
v2
=
scan_f
(
vx
,
vv
)
...
...
@@ -168,7 +168,7 @@ class RopLop_checker(unittest.TestCase):
theano
.
config
.
floatX
)
yv
=
tensor
.
Lop
(
y
,
self
.
x
,
self
.
v
)
lop_f
=
function
([
self
.
x
,
self
.
v
],
yv
)
lop_f
=
function
([
self
.
x
,
self
.
v
],
yv
,
on_unused_input
=
'ignore'
)
J
,
_
=
theano
.
scan
(
lambda
i
,
y
,
x
:
tensor
.
grad
(
y
[
i
],
x
),
sequences
=
tensor
.
arange
(
y
.
shape
[
0
]),
non_sequences
=
[
y
,
self
.
x
])
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论