Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
P
pytensor
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
testgroup
pytensor
Commits
6e470998
提交
6e470998
authored
10月 17, 2014
作者:
Frederic
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Small update to new MakeList op.
上级
d8fbe1e9
显示空白字符变更
内嵌
并排
正在显示
2 个修改的文件
包含
12 行增加
和
8 行删除
+12
-8
basic.py
theano/typed_list/basic.py
+9
-5
test_basic.py
theano/typed_list/tests/test_basic.py
+3
-3
没有找到文件。
theano/typed_list/basic.py
浏览文件 @
6e470998
...
@@ -569,7 +569,7 @@ Returns the size of a list.
...
@@ -569,7 +569,7 @@ Returns the size of a list.
"""
"""
class
Make
_
List
(
Op
):
class
MakeList
(
Op
):
def
__eq__
(
self
,
other
):
def
__eq__
(
self
,
other
):
return
type
(
self
)
==
type
(
other
)
return
type
(
self
)
==
type
(
other
)
...
@@ -584,7 +584,9 @@ class Make_List(Op):
...
@@ -584,7 +584,9 @@ class Make_List(Op):
if
not
isinstance
(
elem
,
theano
.
gof
.
Variable
):
if
not
isinstance
(
elem
,
theano
.
gof
.
Variable
):
elem
=
as_tensor_variable
(
elem
)
elem
=
as_tensor_variable
(
elem
)
a2
.
append
(
elem
)
a2
.
append
(
elem
)
assert
all
(
a2
[
0
]
.
type
==
elem
.
type
for
elem
in
a2
)
if
not
all
(
a2
[
0
]
.
type
==
elem
.
type
for
elem
in
a2
):
raise
TypeError
(
"MakeList need all input variable to be of the same type."
)
tl
=
theano
.
typed_list
.
TypedListType
(
a2
[
0
]
.
type
)()
tl
=
theano
.
typed_list
.
TypedListType
(
a2
[
0
]
.
type
)()
return
Apply
(
self
,
a2
,
[
tl
])
return
Apply
(
self
,
a2
,
[
tl
])
...
@@ -592,9 +594,11 @@ class Make_List(Op):
...
@@ -592,9 +594,11 @@ class Make_List(Op):
def
perform
(
self
,
node
,
inputs
,
(
out
,
)):
def
perform
(
self
,
node
,
inputs
,
(
out
,
)):
out
[
0
]
=
list
(
inputs
)
out
[
0
]
=
list
(
inputs
)
make_list
=
Make
_
List
()
make_list
=
MakeList
()
"""
"""
Returns a list made from tuple's elements
.
Build a Python list from those Theano variable
.
:param a: tuple.
:param a: tuple/list of Theano variable
:note: All Theano variable must have the same type.
"""
"""
theano/typed_list/tests/test_basic.py
浏览文件 @
6e470998
...
@@ -10,7 +10,7 @@ from theano.tensor.type_other import SliceType
...
@@ -10,7 +10,7 @@ from theano.tensor.type_other import SliceType
from
theano.typed_list.type
import
TypedListType
from
theano.typed_list.type
import
TypedListType
from
theano.typed_list.basic
import
(
GetItem
,
Insert
,
from
theano.typed_list.basic
import
(
GetItem
,
Insert
,
Append
,
Extend
,
Remove
,
Reverse
,
Append
,
Extend
,
Remove
,
Reverse
,
Index
,
Count
,
Length
,
make_list
,
Make
_
List
)
Index
,
Count
,
Length
,
make_list
,
MakeList
)
from
theano
import
sparse
from
theano
import
sparse
from
theano.tests
import
unittest_tools
as
utt
from
theano.tests
import
unittest_tools
as
utt
# TODO, handle the case where scipy isn't installed.
# TODO, handle the case where scipy isn't installed.
...
@@ -555,13 +555,13 @@ class test_length(unittest.TestCase):
...
@@ -555,13 +555,13 @@ class test_length(unittest.TestCase):
self
.
assertTrue
(
f
([
x
,
x
])
==
2
)
self
.
assertTrue
(
f
([
x
,
x
])
==
2
)
class
T_Make
_
List
(
unittest
.
TestCase
):
class
T_MakeList
(
unittest
.
TestCase
):
def
test_wrong_shape
(
self
):
def
test_wrong_shape
(
self
):
a
=
T
.
vector
()
a
=
T
.
vector
()
b
=
T
.
matrix
()
b
=
T
.
matrix
()
self
.
assertRaises
(
Assertion
Error
,
make_list
,
(
a
,
b
))
self
.
assertRaises
(
Type
Error
,
make_list
,
(
a
,
b
))
def
correct_answer
(
self
):
def
correct_answer
(
self
):
a
=
T
.
matrix
()
a
=
T
.
matrix
()
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论