Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
P
pytensor
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
testgroup
pytensor
Commits
77c20a3b
提交
77c20a3b
authored
2月 23, 2011
作者:
David Warde-Farley
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Another whitespace cleanup.
上级
8bad060c
隐藏空白字符变更
内嵌
并排
正在显示
5 个修改的文件
包含
31 行增加
和
31 行删除
+31
-31
test_debugmode.py
theano/compile/tests/test_debugmode.py
+10
-10
test_inplace_opt_for_value.py
theano/compile/tests/test_inplace_opt_for_value.py
+4
-4
test_cc.py
theano/gof/tests/test_cc.py
+9
-9
test_link.py
theano/gof/tests/test_link.py
+5
-5
test_gradient.py
theano/tests/test_gradient.py
+3
-3
没有找到文件。
theano/compile/tests/test_debugmode.py
浏览文件 @
77c20a3b
...
...
@@ -36,7 +36,7 @@ class BROKEN_ON_PURPOSE_Add(gof.Op):
#ERROR TO ADD THIS CRAPPY OFFSET
if
self
.
py_offset
:
out
[
0
]
=
z
+
0.5
else
:
out
[
0
]
=
z
else
:
out
[
0
]
=
z
def
c_code
(
self
,
node
,
name
,
(
a
,
b
),
(
z
,),
sub
):
return
"""
...
...
@@ -75,7 +75,7 @@ class BROKEN_ON_PURPOSE_Add(gof.Op):
# inconsistent is a invalid op, whose perform and c_code do not match
inconsistent
=
BROKEN_ON_PURPOSE_Add
(
False
)
# off_by_half is a good op, that is different from theano.sparse.sd_csc
off_by_half
=
BROKEN_ON_PURPOSE_Add
(
True
)
off_by_half
=
BROKEN_ON_PURPOSE_Add
(
True
)
class
WeirdBrokenOp
(
gof
.
Op
):
"""
...
...
@@ -172,11 +172,11 @@ def test_badclinkeroutput():
a
=
theano
.
tensor
.
dvector
()
b
=
theano
.
tensor
.
dvector
()
f_good
=
theano
.
function
([
a
,
b
],
off_by_half
(
a
,
b
),
f_good
=
theano
.
function
([
a
,
b
],
off_by_half
(
a
,
b
),
mode
=
debugmode
.
DebugMode
(
check_c_code
=
True
))
f_inconsistent
=
theano
.
function
([
a
,
b
],
inconsistent
(
a
,
b
),
f_inconsistent
=
theano
.
function
([
a
,
b
],
inconsistent
(
a
,
b
),
mode
=
debugmode
.
DebugMode
(
check_c_code
=
True
))
#this should evaluate with no error
...
...
@@ -189,7 +189,7 @@ def test_badclinkeroutput():
return
#TEST PASS
assert
False
#an error should have been detected
def
test_badoptimization
():
@gof.local_optimizer
([
theano
.
tensor
.
add
])
...
...
@@ -204,7 +204,7 @@ def test_badoptimization():
a
=
theano
.
tensor
.
dvector
()
b
=
theano
.
tensor
.
dvector
()
f
=
theano
.
function
([
a
,
b
],
a
+
b
,
f
=
theano
.
function
([
a
,
b
],
a
+
b
,
mode
=
debugmode
.
DebugMode
(
optimizer
=
opt
,
check_c_code
=
True
))
try
:
...
...
@@ -235,8 +235,8 @@ def test_stochasticoptimization():
b
=
theano
.
tensor
.
dvector
()
try
:
f
=
theano
.
function
([
a
,
b
],
theano
.
tensor
.
add
(
a
,
b
),
f
=
theano
.
function
([
a
,
b
],
theano
.
tensor
.
add
(
a
,
b
),
mode
=
debugmode
.
DebugMode
(
optimizer
=
opt
,
check_c_code
=
True
))
except
debugmode
.
StochasticOrder
:
return
#TEST PASS
...
...
theano/compile/tests/test_inplace_opt_for_value.py
浏览文件 @
77c20a3b
...
...
@@ -73,7 +73,7 @@ class TanhRnn(Op):
This class implements the recurrent part of a recurrent neural network.
There is not a neat way to include this in a more fine-grained way in Theano at the moment,
so to get something working, I'm implementing a relatively complicated Op that could be
so to get something working, I'm implementing a relatively complicated Op that could be
broken down later into constituents.
Anyway, this Op implements recursive computation of the form:
...
...
@@ -81,7 +81,7 @@ class TanhRnn(Op):
.. latex-eqn:
z_t &=
\t
anh( z_{t-1} A + x_{t-1})
For z0 a vector, and x a TxM matrix, it returns a matrix z of shape (T+1, M),
For z0 a vector, and x a TxM matrix, it returns a matrix z of shape (T+1, M),
in which z[0] = z0.
"""
...
...
@@ -275,7 +275,7 @@ def test_WEIRD_STUFF():
print
rnn1
.
minimizer
.
step
.
maker
.
inputs
print
rnn2
.
minimizer
.
step
.
maker
.
inputs
# for i in range(1,len(rnn1.minimizer.step.maker.inputs)):
# print "valid update:",theano.printing.pp(rnn1.minimizer.step.maker.inputs[i].update),
...
...
@@ -284,7 +284,7 @@ def test_WEIRD_STUFF():
# print rnn2.minimizer.step.maker.inputs[i].update.name
# print dir(rnn1.minimizer.step.maker.inputs[5].update)
# print dir(rnn2.minimizer.step.maker.inputs[5].update)
niter
=
3
...
...
theano/gof/tests/test_cc.py
浏览文件 @
77c20a3b
...
...
@@ -24,7 +24,7 @@ class TDouble(Type):
return
"""
%(name)
s = 0;
%(name)
s_bad_thing = malloc(100000);
//printf("Initializing
%(name)
s
\\
n");
//printf("Initializing
%(name)
s
\\
n");
"""
%
locals
()
def
c_literal
(
self
,
data
):
...
...
@@ -40,7 +40,7 @@ class TDouble(Type):
%(name)
s_bad_thing = NULL;
//printf("Extracting
%(name)
s
\\
n");
"""
%
dict
(
locals
(),
**
sub
)
def
c_sync
(
self
,
name
,
sub
):
return
"""
Py_XDECREF(py_
%(name)
s);
...
...
@@ -71,7 +71,7 @@ class MyOp(Op):
def
__init__
(
self
,
nin
,
name
):
self
.
nin
=
nin
self
.
name
=
name
def
make_node
(
self
,
*
inputs
):
assert
len
(
inputs
)
==
self
.
nin
inputs
=
map
(
as_variable
,
inputs
)
...
...
@@ -98,28 +98,28 @@ class Binary(MyOp):
def
__init__
(
self
):
MyOp
.
__init__
(
self
,
2
,
self
.
__class__
.
__name__
)
class
Add
(
Binary
):
def
c_code
(
self
,
node
,
name
,
(
x
,
y
),
(
z
,
),
sub
):
return
"
%(z)
s =
%(x)
s +
%(y)
s;"
%
locals
()
def
impl
(
self
,
x
,
y
):
return
x
+
y
add
=
Add
()
class
Sub
(
Binary
):
def
c_code
(
self
,
node
,
name
,
(
x
,
y
),
(
z
,
),
sub
):
return
"
%(z)
s =
%(x)
s -
%(y)
s;"
%
locals
()
def
impl
(
self
,
x
,
y
):
return
-
10
# erroneous (most of the time)
sub
=
Sub
()
class
Mul
(
Binary
):
def
c_code
(
self
,
node
,
name
,
(
x
,
y
),
(
z
,
),
sub
):
return
"
%(z)
s =
%(x)
s *
%(y)
s;"
%
locals
()
def
impl
(
self
,
x
,
y
):
return
x
*
y
mul
=
Mul
()
class
Div
(
Binary
):
def
c_code
(
self
,
node
,
name
,
(
x
,
y
),
(
z
,
),
sub
):
return
"
%(z)
s =
%(x)
s /
%(y)
s;"
%
locals
()
...
...
@@ -185,7 +185,7 @@ def test_clinker_dups_inner():
lnk
=
CLinker
()
.
accept
(
Env
([
x
,
y
,
z
],
[
e
]))
fn
=
lnk
.
make_function
()
assert
fn
(
1.0
,
2.0
,
3.0
)
==
8.0
######################
...
...
@@ -254,7 +254,7 @@ def test_duallinker_mismatch():
################################
# Test that failure code works #
################################
class
AddFail
(
Binary
):
def
c_code
(
self
,
node
,
name
,
(
x
,
y
),
(
z
,
),
sub
):
fail
=
sub
[
'fail'
]
...
...
theano/gof/tests/test_link.py
浏览文件 @
77c20a3b
...
...
@@ -32,7 +32,7 @@ class MyOp(Op):
self
.
name
=
name
if
impl
:
self
.
impl
=
impl
def
make_node
(
self
,
*
inputs
):
assert
len
(
inputs
)
==
self
.
nin
inputs
=
map
(
as_variable
,
inputs
)
...
...
@@ -85,7 +85,7 @@ class TestPerformLinker:
i
[
1
]
.
data
=
2
fn
()
assert
o
[
0
]
.
data
==
1.5
def
test_function
(
self
):
x
,
y
,
z
=
inputs
()
e
=
mul
(
add
(
x
,
y
),
div
(
x
,
y
))
...
...
@@ -130,7 +130,7 @@ class TestWrapLinker:
nodes
=
[]
def
wrap
(
i
,
node
,
th
):
nodes
.
append
(
node
.
op
)
x
,
y
,
z
=
inputs
()
e
=
mul
(
add
(
x
,
y
),
div
(
x
,
y
))
fn
,
i
,
o
=
wrap_linker
(
Env
([
x
,
y
,
z
],
[
e
]),
[
PerformLinker
(
allow_gc
=
False
)],
wrap
)
.
make_thunk
()
...
...
@@ -154,8 +154,8 @@ class TestWrapLinker:
fn
()
assert
nodes
==
[
div
,
add
,
mul
]
assert
o
[
0
]
.
data
==
1.5
theano/tests/test_gradient.py
浏览文件 @
77c20a3b
...
...
@@ -15,7 +15,7 @@ def _grad_sources_inputs(*args):
return
grad_sources_inputs
(
warn_type
=
False
,
*
args
)
class
test_grad_sources_inputs
(
unittest
.
TestCase
):
def
test_retNone1
(
self
):
def
test_retNone1
(
self
):
"""Test that it is not ok to return None from op.grad()"""
class
retNone
(
gof
.
op
.
Op
):
def
make_node
(
self
):
...
...
@@ -31,7 +31,7 @@ class test_grad_sources_inputs(unittest.TestCase):
self
.
failUnless
(
e
[
0
]
is
gradient
.
_msg_retType
)
return
self
.
fail
()
def
test_retNone1_b
(
self
):
def
test_retNone1_b
(
self
):
"""Test that it is ok to return [None] from op.grad()"""
class
retNone
(
gof
.
op
.
Op
):
def
make_node
(
self
,
*
inputs
):
...
...
@@ -44,7 +44,7 @@ class test_grad_sources_inputs(unittest.TestCase):
g
=
_grad_sources_inputs
([(
a
.
out
,
1
)],
None
)
self
.
failUnless
(
not
i
in
g
)
def
test_wrong_rval_len1
(
self
):
def
test_wrong_rval_len1
(
self
):
"""Test that it is not ok to return the wrong number of gradients"""
class
retNone
(
gof
.
op
.
Op
):
def
make_node
(
self
,
*
inputs
):
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论