Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
P
pytensor
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
testgroup
pytensor
Commits
490ef97a
提交
490ef97a
authored
6月 19, 2012
作者:
lamblin
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #710 from nouiz/small
Small
上级
822a6648
b1ff1b33
全部展开
隐藏空白字符变更
内嵌
并排
正在显示
5 个修改的文件
包含
57 行增加
和
56 行删除
+57
-56
test_scan.py
theano/scan_module/tests/test_scan.py
+0
-1
conv.py
theano/tensor/nnet/conv.py
+1
-1
test_conv.py
theano/tensor/nnet/tests/test_conv.py
+0
-0
test_updates.py
theano/tests/test_updates.py
+47
-54
updates.py
theano/updates.py
+9
-0
没有找到文件。
theano/scan_module/tests/test_scan.py
浏览文件 @
490ef97a
...
@@ -693,7 +693,6 @@ class T_Scan(unittest.TestCase):
...
@@ -693,7 +693,6 @@ class T_Scan(unittest.TestCase):
outputs_info
=
[
None
])
outputs_info
=
[
None
])
inp
=
numpy
.
arange
(
5
)
.
astype
(
'float64'
)
inp
=
numpy
.
arange
(
5
)
.
astype
(
'float64'
)
rval
=
theano
.
function
([
x
],
y
,
updates
=
updates
)(
inp
)
rval
=
theano
.
function
([
x
],
y
,
updates
=
updates
)(
inp
)
import
ipdb
;
ipdb
.
set_trace
()
assert
numpy
.
all
(
rval
==
inp
[:
-
1
])
assert
numpy
.
all
(
rval
==
inp
[:
-
1
])
# simple rnn, one input, one state, weights for each; input/state are
# simple rnn, one input, one state, weights for each; input/state are
...
...
theano/tensor/nnet/conv.py
浏览文件 @
490ef97a
...
@@ -708,7 +708,7 @@ class ConvOp(Op):
...
@@ -708,7 +708,7 @@ class ConvOp(Op):
raise
NotImplementedError
(
'todo'
)
raise
NotImplementedError
(
'todo'
)
if
self
.
dx
not
in
(
1
,
2
)
or
self
.
dy
not
in
(
1
,
2
):
if
self
.
dx
not
in
(
1
,
2
)
or
self
.
dy
not
in
(
1
,
2
):
raise
Exception
(
"ERROR: We disable ConvOp.grad now when dx or "
\
raise
NotImplementedError
(
"ERROR: We disable ConvOp.grad now when dx or "
\
"dy are different from 1 and 2, as there is a bug in it."
)
"dy are different from 1 and 2, as there is a bug in it."
)
all_shape
=
self
.
imshp
is
not
None
and
self
.
kshp
is
not
None
and
\
all_shape
=
self
.
imshp
is
not
None
and
self
.
kshp
is
not
None
and
\
...
...
theano/tensor/nnet/tests/test_conv.py
浏览文件 @
490ef97a
差异被折叠。
点击展开。
theano/tests/test_updates.py
浏览文件 @
490ef97a
import
unittest
import
theano
import
theano
from
theano.updates
import
Updates
from
theano.updates
import
Updates
import
theano.tensor
as
T
import
theano.tensor
as
T
def
test_updates_setitem
():
class
test_ifelse
(
unittest
.
TestCase
):
ok
=
True
up
=
Updates
()
def
test_updates_init
(
self
):
sv
=
theano
.
shared
(
'asdf'
)
self
.
assertRaises
(
TypeError
,
Updates
,
dict
(
d
=
3
)
)
# keys have to be SharedVariables
sv
=
theano
.
shared
(
'asdf'
)
try
:
Updates
({
sv
:
3
})
up
[
5
]
=
7
ok
=
False
except
TypeError
:
ok
=
True
assert
ok
# keys have to be SharedVariables
def
test_updates_setitem
(
self
):
try
:
up
[
T
.
vector
()]
=
7
ok
=
False
except
TypeError
:
ok
=
True
ok
=
True
assert
ok
# keys have to be SharedVariables
up
[
theano
.
shared
(
88
)]
=
7
def
test_updates_add
():
up
=
Updates
()
sv
=
theano
.
shared
(
'asdf'
)
up1
=
Updates
()
# keys have to be SharedVariables
up2
=
Updates
()
self
.
assertRaises
(
TypeError
,
up
.
__setitem__
,
5
,
7
)
self
.
assertRaises
(
TypeError
,
up
.
__setitem__
,
T
.
vector
(),
7
)
a
=
theano
.
shared
(
'a'
)
up
[
theano
.
shared
(
88
)]
=
7
b
=
theano
.
shared
(
'b'
)
def
test_updates_add
(
self
):
assert
not
up1
+
up2
up1
=
Updates
()
up2
=
Updates
()
up1
[
a
]
=
5
a
=
theano
.
shared
(
'a'
)
b
=
theano
.
shared
(
'b'
)
# test that addition works
assert
not
up1
+
up2
assert
up1
assert
up1
+
up2
assert
not
up2
assert
len
(
up1
+
up2
)
==
1
up1
[
a
]
=
5
assert
(
up1
+
up2
)[
a
]
==
5
up2
[
b
]
=
7
# test that addition works
assert
up1
assert
up1
assert
up1
+
up2
assert
up1
+
up2
asser
t
up2
assert
no
t
up2
assert
len
(
up1
+
up2
)
==
2
assert
len
(
up1
+
up2
)
==
1
assert
(
up1
+
up2
)[
a
]
==
5
assert
(
up1
+
up2
)[
a
]
==
5
assert
(
up1
+
up2
)[
b
]
==
7
assert
a
in
(
up1
+
up2
)
up2
[
b
]
=
7
assert
b
in
(
up1
+
up2
)
assert
up1
assert
up1
+
up2
assert
up2
# this works even though there is a collision
assert
len
(
up1
+
up2
)
==
2
# because values all match
assert
(
up1
+
up2
)[
a
]
==
5
assert
len
(
up1
+
up1
+
up1
)
==
1
assert
(
up1
+
up2
)[
b
]
==
7
up2
[
a
]
=
8
# a gets different value in up1 and up2
assert
a
in
(
up1
+
up2
)
try
:
assert
b
in
(
up1
+
up2
)
up1
+
up2
assert
0
except
KeyError
:
pass
# reassigning to a key works fine right?
# this works even though there is a collision
up2
[
a
]
=
10
# because values all match
assert
len
(
up1
+
up1
+
up1
)
==
1
up2
[
a
]
=
8
# a gets different value in up1 and up2
try
:
up1
+
up2
assert
0
except
KeyError
:
pass
# reassigning to a key works fine right?
up2
[
a
]
=
10
theano/updates.py
浏览文件 @
490ef97a
...
@@ -19,6 +19,15 @@ class Updates(dict):
...
@@ -19,6 +19,15 @@ class Updates(dict):
This mapping supports the use of the "+" operator for the union of updates.
This mapping supports the use of the "+" operator for the union of updates.
"""
"""
def
__init__
(
self
,
*
key
,
**
kwargs
):
ret
=
super
(
Updates
,
self
)
.
__init__
(
*
key
,
**
kwargs
)
for
key
in
self
:
if
not
isinstance
(
key
,
SharedVariable
):
raise
TypeError
(
'Updates keys must inherit from SharedVariable'
,
key
)
return
ret
def
__setitem__
(
self
,
key
,
value
):
def
__setitem__
(
self
,
key
,
value
):
if
isinstance
(
key
,
SharedVariable
):
if
isinstance
(
key
,
SharedVariable
):
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论