Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
P
pytensor
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
testgroup
pytensor
Commits
c41e0a4a
提交
c41e0a4a
authored
1月 07, 2010
作者:
Frederic Bastien
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
backport to python2.4
上级
cf7f9f7e
隐藏空白字符变更
内嵌
并排
正在显示
6 个修改的文件
包含
29 行增加
和
12 行删除
+29
-12
shared_randomstreams.py
theano/compile/sandbox/shared_randomstreams.py
+5
-3
test_pfunc.py
theano/compile/sandbox/tests/test_pfunc.py
+4
-4
test_debugmode.py
theano/compile/tests/test_debugmode.py
+4
-1
test_inplace_opt_for_value.py
theano/compile/tests/test_inplace_opt_for_value.py
+4
-1
test_module.py
theano/compile/tests/test_module.py
+8
-2
test_opt.py
theano/gof/tests/test_opt.py
+4
-1
没有找到文件。
theano/compile/sandbox/shared_randomstreams.py
浏览文件 @
c41e0a4a
...
@@ -4,8 +4,8 @@ __docformat__ = "restructuredtext en"
...
@@ -4,8 +4,8 @@ __docformat__ = "restructuredtext en"
import
sys
import
sys
import
numpy
import
numpy
from
..
.gof
import
Container
from
theano
.gof
import
Container
from
..
.tensor
import
raw_random
from
theano
.tensor
import
raw_random
from
sharedvalue
import
SharedVariable
,
shared_constructor
,
shared
from
sharedvalue
import
SharedVariable
,
shared_constructor
,
shared
...
@@ -64,7 +64,9 @@ class RandomStreams(object):
...
@@ -64,7 +64,9 @@ class RandomStreams(object):
:rtype: None
:rtype: None
"""
"""
seed
=
self
.
default_instance_seed
if
seed
is
None
else
seed
if
seed
is
None
:
seed
=
self
.
default_instance_seed
seedgen
=
numpy
.
random
.
RandomState
(
seed
)
seedgen
=
numpy
.
random
.
RandomState
(
seed
)
for
old_r
,
new_r
in
self
.
random_state_variables
:
for
old_r
,
new_r
in
self
.
random_state_variables
:
old_r_seed
=
seedgen
.
randint
(
2
**
30
)
old_r_seed
=
seedgen
.
randint
(
2
**
30
)
...
...
theano/compile/sandbox/tests/test_pfunc.py
浏览文件 @
c41e0a4a
...
@@ -141,13 +141,13 @@ class Test_pfunc(unittest.TestCase):
...
@@ -141,13 +141,13 @@ class Test_pfunc(unittest.TestCase):
# by default, shared are not mutable unless doing an explicit update
# by default, shared are not mutable unless doing an explicit update
f
=
pfunc
([],
[
b_out
],
mode
=
'FAST_RUN'
)
f
=
pfunc
([],
[
b_out
],
mode
=
'FAST_RUN'
)
assert
(
f
()
==
numpy
.
arange
(
5
)
*
2
)
.
all
()
assert
(
f
()
==
numpy
.
arange
(
5
)
*
2
)
.
all
()
assert
all
(
b
.
value
==
numpy
.
arange
(
5
))
assert
numpy
.
all
(
b
.
value
==
numpy
.
arange
(
5
))
# using updates, b is now a mutable parameter
# using updates, b is now a mutable parameter
f
=
pfunc
([],
[
b_out
],
updates
=
[(
b
,
b_out
)],
mode
=
'FAST_RUN'
)
f
=
pfunc
([],
[
b_out
],
updates
=
[(
b
,
b_out
)],
mode
=
'FAST_RUN'
)
assert
(
f
()
==
numpy
.
arange
(
5
)
*
2
)
.
all
()
assert
(
f
()
==
numpy
.
arange
(
5
)
*
2
)
.
all
()
assert
all
(
b
.
value
==
numpy
.
arange
(
5
)
*
2
)
# because of the update
assert
(
b
.
value
==
numpy
.
arange
(
5
)
*
2
)
.
all
(
)
# because of the update
assert
all
(
bval
==
numpy
.
arange
(
5
)
*
2
)
# because of mutable=True
assert
(
bval
==
numpy
.
arange
(
5
)
*
2
)
.
all
(
)
# because of mutable=True
# do not depend on updates being in-place though!
# do not depend on updates being in-place though!
bval
=
numpy
.
arange
(
5
)
bval
=
numpy
.
arange
(
5
)
...
@@ -156,7 +156,7 @@ class Test_pfunc(unittest.TestCase):
...
@@ -156,7 +156,7 @@ class Test_pfunc(unittest.TestCase):
assert
(
f
()
==
numpy
.
arange
(
5
)
*
2
)
.
all
()
assert
(
f
()
==
numpy
.
arange
(
5
)
*
2
)
.
all
()
assert
(
b
.
value
==
((
numpy
.
arange
(
5
)
*
2
)
+
3
))
.
all
()
# because of the update
assert
(
b
.
value
==
((
numpy
.
arange
(
5
)
*
2
)
+
3
))
.
all
()
# because of the update
# bval got modified to something...
# bval got modified to something...
assert
not
all
(
bval
==
numpy
.
arange
(
5
)
)
assert
not
(
bval
==
numpy
.
arange
(
5
))
.
all
(
)
# ... but not to b.value !
# ... but not to b.value !
assert
not
(
bval
==
b
.
value
)
.
all
()
assert
not
(
bval
==
b
.
value
)
.
all
()
...
...
theano/compile/tests/test_debugmode.py
浏览文件 @
c41e0a4a
...
@@ -36,7 +36,10 @@ class BROKEN_ON_PURPOSE_StructuredDotCSC(gof.Op):
...
@@ -36,7 +36,10 @@ class BROKEN_ON_PURPOSE_StructuredDotCSC(gof.Op):
copy
=
False
)
copy
=
False
)
# TODO: todense() is automatic in 0.7.0, just remove the following line:
# TODO: todense() is automatic in 0.7.0, just remove the following line:
z
=
a
*
b
z
=
a
*
b
out
[
0
]
=
z
+
0.5
if
self
.
py_offset
else
z
#ERROR TO ADD THIS CRAPPY OFFSET
#ERROR TO ADD THIS CRAPPY OFFSET
if
self
.
py_offset
:
out
[
0
]
=
z
+
0.5
else
:
out
[
0
]
=
z
def
c_code
(
self
,
node
,
name
,
(
a_val
,
a_ind
,
a_ptr
,
a_nrows
,
b
),
(
z
,),
sub
):
def
c_code
(
self
,
node
,
name
,
(
a_val
,
a_ind
,
a_ptr
,
a_nrows
,
b
),
(
z
,),
sub
):
return
"""
return
"""
...
...
theano/compile/tests/test_inplace_opt_for_value.py
浏览文件 @
c41e0a4a
...
@@ -42,7 +42,10 @@ class StochasticGradientDescent(module.FancyModule):
...
@@ -42,7 +42,10 @@ class StochasticGradientDescent(module.FancyModule):
raise
ValueError
(
'stepsize must be a scalar'
,
stepsize
)
raise
ValueError
(
'stepsize must be a scalar'
,
stepsize
)
self
.
params
=
params
self
.
params
=
params
self
.
gparams
=
T
.
grad
(
cost
,
self
.
params
)
if
gradients
is
None
else
gradients
if
gradients
is
None
:
self
.
gparams
=
T
.
grad
(
cost
,
self
.
params
)
else
:
self
.
gparams
=
gradients
self
.
updates
=
dict
((
p
,
p
-
self
.
stepsize
*
g
)
for
p
,
g
in
zip
(
self
.
params
,
self
.
gparams
))
self
.
updates
=
dict
((
p
,
p
-
self
.
stepsize
*
g
)
for
p
,
g
in
zip
(
self
.
params
,
self
.
gparams
))
...
...
theano/compile/tests/test_module.py
浏览文件 @
c41e0a4a
...
@@ -695,6 +695,12 @@ def test_method_implicit_ticket_384():
...
@@ -695,6 +695,12 @@ def test_method_implicit_ticket_384():
if
not
str
(
e
)
.
startswith
(
'Tried to provide value for implicit input'
):
if
not
str
(
e
)
.
startswith
(
'Tried to provide value for implicit input'
):
raise
raise
def
get_mode
():
if
default_mode
!=
'DEBUG_MODE'
:
mode
=
default_mode
else
:
mode
=
'FAST_RUN'
return
mode
def
test_pickle
():
def
test_pickle
():
"""Test that a module can be pickled"""
"""Test that a module can be pickled"""
M
=
Module
()
M
=
Module
()
...
@@ -704,7 +710,7 @@ def test_pickle():
...
@@ -704,7 +710,7 @@ def test_pickle():
M
.
f
=
Method
([
a
],
a
+
M
.
x
+
M
.
y
)
M
.
f
=
Method
([
a
],
a
+
M
.
x
+
M
.
y
)
M
.
g
=
Method
([
a
],
a
*
M
.
x
*
M
.
y
)
M
.
g
=
Method
([
a
],
a
*
M
.
x
*
M
.
y
)
mode
=
default_mode
if
default_mode
!=
'DEBUG_MODE'
else
'FAST_RUN'
mode
=
get_mode
()
m
=
M
.
make
(
x
=
numpy
.
zeros
((
4
,
5
)),
y
=
numpy
.
ones
((
2
,
3
)),
mode
=
mode
)
m
=
M
.
make
(
x
=
numpy
.
zeros
((
4
,
5
)),
y
=
numpy
.
ones
((
2
,
3
)),
mode
=
mode
)
m_dup
=
cPickle
.
loads
(
cPickle
.
dumps
(
m
))
m_dup
=
cPickle
.
loads
(
cPickle
.
dumps
(
m
))
...
@@ -729,7 +735,7 @@ def test_pickle_aliased_memory():
...
@@ -729,7 +735,7 @@ def test_pickle_aliased_memory():
M
.
f
=
Method
([
a
],
a
+
M
.
x
+
M
.
y
)
M
.
f
=
Method
([
a
],
a
+
M
.
x
+
M
.
y
)
M
.
g
=
Method
([
a
],
a
*
M
.
x
*
M
.
y
)
M
.
g
=
Method
([
a
],
a
*
M
.
x
*
M
.
y
)
mode
=
default_mode
if
default_mode
!=
'DEBUG_MODE'
else
'FAST_RUN'
mode
=
get_mode
()
m
=
M
.
make
(
x
=
numpy
.
zeros
((
4
,
5
)),
y
=
numpy
.
ones
((
2
,
3
)),
mode
=
mode
)
m
=
M
.
make
(
x
=
numpy
.
zeros
((
4
,
5
)),
y
=
numpy
.
ones
((
2
,
3
)),
mode
=
mode
)
m
.
y
=
m
.
x
[:]
m
.
y
=
m
.
x
[:]
...
...
theano/gof/tests/test_opt.py
浏览文件 @
c41e0a4a
...
@@ -57,7 +57,10 @@ class MyOp(Op):
...
@@ -57,7 +57,10 @@ class MyOp(Op):
def
__hash__
(
self
):
def
__hash__
(
self
):
#return hash(self.x if self.x is not None else id(self)) ^ hash(self.name)
#return hash(self.x if self.x is not None else id(self)) ^ hash(self.name)
return
hash
(
self
.
x
if
self
.
x
is
not
None
else
id
(
self
))
if
self
.
x
is
not
None
:
return
hash
(
self
.
x
)
else
:
return
id
(
self
)
op1
=
MyOp
(
'Op1'
)
op1
=
MyOp
(
'Op1'
)
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论