Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
P
pytensor
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
testgroup
pytensor
Commits
8604fcc2
提交
8604fcc2
authored
1月 07, 2010
作者:
Frederic Bastien
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
more backport to python 2.4
上级
c41e0a4a
隐藏空白字符变更
内嵌
并排
正在显示
4 个修改的文件
包含
42 行增加
和
15 行删除
+42
-15
basic.py
theano/tensor/basic.py
+4
-0
test_merge.py
theano/tensor/tests/test_merge.py
+3
-1
test_naacl09.py
theano/tensor/tests/test_naacl09.py
+28
-11
test_opt.py
theano/tensor/tests/test_opt.py
+7
-3
没有找到文件。
theano/tensor/basic.py
浏览文件 @
8604fcc2
...
@@ -2185,6 +2185,10 @@ class Split(Op):
...
@@ -2185,6 +2185,10 @@ class Split(Op):
def
perform
(
self
,
node
,
(
x
,
axis
,
splits
),
outputs
):
def
perform
(
self
,
node
,
(
x
,
axis
,
splits
),
outputs
):
"""WRITEME"""
"""WRITEME"""
#in python 2.4, x.shape[numpy.asarray(1)] don't work.
if
sys
.
version_info
[
0
:
2
]
==
(
2
,
4
)
and
axis
.
size
==
1
:
axis
=
int
(
axis
)
try
:
try
:
len_along_axis
=
x
.
shape
[
axis
]
len_along_axis
=
x
.
shape
[
axis
]
except
:
except
:
...
...
theano/tensor/tests/test_merge.py
浏览文件 @
8604fcc2
...
@@ -44,7 +44,9 @@ class MyOp(Op):
...
@@ -44,7 +44,9 @@ class MyOp(Op):
return
self
is
other
or
isinstance
(
other
,
MyOp
)
and
self
.
x
is
not
None
and
self
.
x
==
other
.
x
return
self
is
other
or
isinstance
(
other
,
MyOp
)
and
self
.
x
is
not
None
and
self
.
x
==
other
.
x
def
__hash__
(
self
):
def
__hash__
(
self
):
return
self
.
x
if
self
.
x
is
not
None
else
id
(
self
)
if
self
.
x
is
not
None
:
return
self
.
x
else
:
return
id
(
self
)
op1
=
MyOp
(
'Op1'
)
op1
=
MyOp
(
'Op1'
)
...
...
theano/tensor/tests/test_naacl09.py
浏览文件 @
8604fcc2
...
@@ -3,7 +3,6 @@
...
@@ -3,7 +3,6 @@
import
theano
import
theano
from
theano
import
tensor
as
T
from
theano
import
tensor
as
T
from
theano.tensor
import
nnet
as
NN
from
theano.tensor
import
nnet
as
NN
import
numpy
as
N
from
theano.compile
import
module
from
theano.compile
import
module
from
theano.compile.mode
import
default_mode
from
theano.compile.mode
import
default_mode
from
theano
import
tensor
as
T
,
sparse
as
S
from
theano
import
tensor
as
T
,
sparse
as
S
...
@@ -88,7 +87,9 @@ class QuadraticDenoisingAA(module.Module):
...
@@ -88,7 +87,9 @@ class QuadraticDenoisingAA(module.Module):
self
.
qfilters
=
[(
q
)
for
q
in
_qfilters
]
self
.
qfilters
=
[(
q
)
for
q
in
_qfilters
]
#self.w1 = theano.Member(T.matrix('w1')) if _w1 is None else theano.Member(_w1)
#self.w1 = theano.Member(T.matrix('w1')) if _w1 is None else theano.Member(_w1)
self
.
w1
=
(
T
.
matrix
(
'w1'
))
if
_w1
is
None
else
(
_w1
)
if
_w1
is
None
:
self
.
w1
=
(
T
.
matrix
(
'w1'
))
else
:
self
.
w1
=
(
_w1
)
if
_w2
is
None
:
if
_w2
is
None
:
if
not
tie_weights
:
if
not
tie_weights
:
#self.w2 = theano.Member(T.matrix())
#self.w2 = theano.Member(T.matrix())
...
@@ -99,9 +100,13 @@ class QuadraticDenoisingAA(module.Module):
...
@@ -99,9 +100,13 @@ class QuadraticDenoisingAA(module.Module):
#self.w2 = theano.Member(_w2)
#self.w2 = theano.Member(_w2)
self
.
w2
=
(
_w2
)
self
.
w2
=
(
_w2
)
#self.b1 = theano.Member(T.vector('b1')) if _b1 is None else theano.Member(_b1)
#self.b1 = theano.Member(T.vector('b1')) if _b1 is None else theano.Member(_b1)
self
.
b1
=
(
T
.
vector
(
'b1'
))
if
_b1
is
None
else
(
_b1
)
if
_b1
is
None
:
self
.
b1
=
(
T
.
vector
(
'b1'
))
else
:
self
.
b1
=
(
_b1
)
#self.b2 = theano.Member(T.vector('b2')) if _b2 is None else theano.Member(_b2)
#self.b2 = theano.Member(T.vector('b2')) if _b2 is None else theano.Member(_b2)
self
.
b2
=
(
T
.
vector
(
'b2'
))
if
_b2
is
None
else
(
_b2
)
if
_b2
is
None
:
self
.
b2
=
(
T
.
vector
(
'b2'
))
else
:
self
.
b2
=
(
_b2
)
# # REGULARIZATION COST
# # REGULARIZATION COST
# self.regularization = self.build_regularization()
# self.regularization = self.build_regularization()
...
@@ -273,16 +278,26 @@ class Module_Nclass(module.FancyModule):
...
@@ -273,16 +278,26 @@ class Module_Nclass(module.FancyModule):
super
(
Module_Nclass
,
self
)
.
__init__
()
#boilerplate
super
(
Module_Nclass
,
self
)
.
__init__
()
#boilerplate
#self.x = module.Member(x) if x is not None else T.matrix('input')
#self.x = module.Member(x) if x is not None else T.matrix('input')
self
.
x
=
(
x
)
if
x
is
not
None
else
T
.
matrix
(
'input'
)
if
x
is
not
None
:
self
.
x
=
(
x
)
else
:
self
.
x
=
T
.
matrix
(
'input'
)
#self.targ = module.Member(targ) if targ is not None else T.lvector()
#self.targ = module.Member(targ) if targ is not None else T.lvector()
self
.
targ
=
(
targ
)
if
targ
is
not
None
else
T
.
lvector
()
if
targ
is
not
None
:
self
.
targ
=
(
targ
)
else
:
self
.
targ
=
T
.
lvector
()
#self.w = module.Member(w) if w is not None else module.Member(T.dmatrix())
#self.w = module.Member(w) if w is not None else module.Member(T.dmatrix())
self
.
w
=
(
w
)
if
w
is
not
None
else
(
T
.
dmatrix
())
if
w
is
not
None
:
self
.
w
=
(
w
)
else
:
self
.
w
=
(
T
.
dmatrix
())
#self.b = module.Member(b) if b is not None else module.Member(T.dvector())
#self.b = module.Member(b) if b is not None else module.Member(T.dvector())
self
.
b
=
(
b
)
if
b
is
not
None
else
(
T
.
dvector
())
if
b
is
not
None
:
self
.
b
=
(
b
)
else
:
self
.
b
=
(
T
.
dvector
())
#self.lr = module.Member(lr) if lr is not None else module.Member(T.dscalar())
#self.lr = module.Member(lr) if lr is not None else module.Member(T.dscalar())
self
.
lr
=
(
lr
)
if
lr
is
not
None
else
(
T
.
dscalar
())
if
lr
is
not
None
:
self
.
lr
=
(
lr
)
else
:
self
.
lr
=
(
T
.
dscalar
())
self
.
params
=
[
p
for
p
in
[
self
.
w
,
self
.
b
]
if
p
.
owner
is
None
]
self
.
params
=
[
p
for
p
in
[
self
.
w
,
self
.
b
]
if
p
.
owner
is
None
]
...
@@ -445,7 +460,7 @@ class ConvolutionalMLP(module.FancyModule):
...
@@ -445,7 +460,7 @@ class ConvolutionalMLP(module.FancyModule):
assert
(
i
.
w2
==
self
.
input_representations
[
0
]
.
w2
)
.
all
()
assert
(
i
.
w2
==
self
.
input_representations
[
0
]
.
w2
)
.
all
()
assert
(
i
.
b1
==
self
.
input_representations
[
0
]
.
b1
)
.
all
()
assert
(
i
.
b1
==
self
.
input_representations
[
0
]
.
b1
)
.
all
()
assert
(
i
.
b2
==
self
.
input_representations
[
0
]
.
b2
)
.
all
()
assert
(
i
.
b2
==
self
.
input_representations
[
0
]
.
b2
)
.
all
()
assert
all
((
a
==
b
)
.
all
()
for
a
,
b
in
zip
(
i
.
qfilters
,
self
.
input_representations
[
0
]
.
qfilters
))
assert
N
.
all
((
a
==
b
)
.
all
()
for
a
,
b
in
zip
(
i
.
qfilters
,
self
.
input_representations
[
0
]
.
qfilters
))
self
.
hidden
.
initialize
(
input_size
=
(
len
(
self
.
inputs
)
*
self
.
input_representation_size
),
self
.
hidden
.
initialize
(
input_size
=
(
len
(
self
.
inputs
)
*
self
.
input_representation_size
),
hidden_size
=
self
.
hidden_representation_size
,
noise_level
=
noise_level
,
hidden_size
=
self
.
hidden_representation_size
,
noise_level
=
noise_level
,
...
@@ -507,7 +522,9 @@ def test_naacl_model(iters_per_unsup=3, iters_per_sup=3,
...
@@ -507,7 +522,9 @@ def test_naacl_model(iters_per_unsup=3, iters_per_sup=3,
import
time
import
time
t
=
time
.
time
()
t
=
time
.
time
()
mode
=
theano
.
Mode
(
linker
=
'c|py'
,
optimizer
=
optimizer
)
if
optimizer
else
default_mode
if
optimizer
:
mode
=
theano
.
Mode
(
linker
=
'c|py'
,
optimizer
=
optimizer
)
else
:
mode
=
default_mode
if
realistic
:
if
realistic
:
m
=
create_realistic
(
compile_mode
=
mode
)
m
=
create_realistic
(
compile_mode
=
mode
)
else
:
else
:
...
...
theano/tensor/tests/test_opt.py
浏览文件 @
8604fcc2
...
@@ -1100,7 +1100,9 @@ class test_fusion(unittest.TestCase):
...
@@ -1100,7 +1100,9 @@ class test_fusion(unittest.TestCase):
print
'key, old val, new val, diff'
print
'key, old val, new val, diff'
for
key
in
set
(
d
.
keys
()
+
nd
.
keys
()):
for
key
in
set
(
d
.
keys
()
+
nd
.
keys
()):
if
d
.
has_key
(
key
)
and
nd
.
has_key
(
key
)
and
nd
[
key
]
!=
d
[
key
]:
if
d
.
has_key
(
key
)
and
nd
.
has_key
(
key
)
and
nd
[
key
]
!=
d
[
key
]:
print
key
,
d
.
get
(
key
),
nd
.
get
(
key
),
nd
[
key
]
-
d
[
key
]
if
d
.
has_key
(
key
)
and
nd
.
has_key
(
key
)
else
None
print
key
,
d
.
get
(
key
),
nd
.
get
(
key
),
if
d
.
has_key
(
key
)
and
nd
.
has_key
(
key
):
print
nd
[
key
]
-
d
[
key
]
else
:
print
None
gc
.
collect
();
gc
.
collect
();
gc
.
collect
()
gc
.
collect
();
gc
.
collect
();
gc
.
collect
()
d
=
nd
d
=
nd
...
@@ -1115,8 +1117,10 @@ class test_fusion(unittest.TestCase):
...
@@ -1115,8 +1117,10 @@ class test_fusion(unittest.TestCase):
cmp
=
not
isinstance
(
x
,
list
)
cmp
=
not
isinstance
(
x
,
list
)
if
not
cmp
and
x
:
if
not
cmp
and
x
:
cmp
=
x
[
0
]
.
__class__
.
__name__
!=
'array_converter'
cmp
=
x
[
0
]
.
__class__
.
__name__
!=
'array_converter'
cmp
=
x
[
0
]
!=
'Option'
if
cmp
else
cmp
if
cmp
:
cmp
=
x
[
0
]
!=
270
if
cmp
else
cmp
cmp
=
x
[
0
]
!=
'Option'
if
cmp
:
cmp
=
x
[
0
]
!=
270
cmp
=
False
cmp
=
False
if
cmp
and
x
in
dl
:
if
cmp
and
x
in
dl
:
nb
+=
1
nb
+=
1
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论