Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
P
pytensor
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
testgroup
pytensor
Commits
576f6eaf
提交
576f6eaf
authored
5月 21, 2014
作者:
Hengjean
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Merged inplace and non inplace append and extend
上级
fc64ccaa
隐藏空白字符变更
内嵌
并排
正在显示
2 个修改的文件
包含
26 行增加
和
12 行删除
+26
-12
basic.py
theano/typed_list/basic.py
+23
-9
test_basic.py
theano/typed_list/tests/test_basic.py
+3
-3
没有找到文件。
theano/typed_list/basic.py
浏览文件 @
576f6eaf
...
...
@@ -91,6 +91,12 @@ class Append(Op):
"""
#append an element at the end of another list
"""
def
__init__
(
self
,
inplace
=
False
):
self
.
inplace
=
inplace
if
self
.
inplace
:
self
.
destroy_map
=
{
0
:
[
0
]}
def
__eq__
(
self
,
other
):
return
type
(
self
)
==
type
(
other
)
...
...
@@ -103,17 +109,26 @@ class Append(Op):
return
Apply
(
self
,
[
x
,
toAppend
],
[
x
.
type
()])
def
perform
(
self
,
node
,
(
x
,
toAppend
),
(
out
,
)):
out
[
0
]
=
list
(
x
)
if
self
.
inplace
:
out
[
0
]
=
list
(
x
)
else
:
out
[
0
]
=
x
out
[
0
]
.
append
(
toAppend
)
def
__str__
(
self
):
return
self
.
__class__
.
__name__
class
Extend
Inplace
(
Op
):
class
Extend
(
Op
):
"""
append all element of a list at the end of another list
"""
def
__init__
(
self
,
inplace
=
False
):
self
.
inplace
=
inplace
if
self
.
inplace
:
self
.
destroy_map
=
{
0
:
[
0
]}
def
__eq__
(
self
,
other
):
return
type
(
self
)
==
type
(
other
)
...
...
@@ -126,19 +141,18 @@ class ExtendInplace(Op):
return
Apply
(
self
,
[
x
,
toAppend
],
[
x
.
type
()])
def
perform
(
self
,
node
,
(
x
,
toAppend
),
(
out
,
)):
out
[
0
]
=
x
if
self
.
inplace
:
out
[
0
]
=
list
(
x
)
else
:
out
[
0
]
=
x
out
[
0
]
.
extend
(
toAppend
)
def
__str__
(
self
):
return
self
.
__class__
.
__name__
destroy_map
=
{
0
:
[
0
]}
class
Insert
(
Op
):
class
Extend
(
Op
):
"""
append all element of a list at the end of another list
"""
def
__eq__
(
self
,
other
):
return
type
(
self
)
==
type
(
other
)
...
...
@@ -150,7 +164,7 @@ class Extend(Op):
assert
x
.
type
==
toAppend
.
type
return
Apply
(
self
,
[
x
,
toAppend
],
[
x
.
type
()])
def
perform
(
self
,
node
,
(
x
,
toAppend
),
(
out
,
)):
def
perform
(
self
,
node
,
(
x
,
index
,
toAppend
),
(
out
,
)):
out
[
0
]
=
list
(
x
)
out
[
0
]
.
extend
(
toAppend
)
...
...
theano/typed_list/tests/test_basic.py
浏览文件 @
576f6eaf
...
...
@@ -7,7 +7,7 @@ import theano.typed_list
from
theano
import
tensor
as
T
from
theano.tensor.type_other
import
SliceType
from
theano.typed_list.type
import
TypedListType
from
theano.typed_list.basic
import
(
GetItem
,
AppendInplace
,
ExtendInplace
,
from
theano.typed_list.basic
import
(
GetItem
,
Append
,
Extend
)
from
theano.tests
import
unittest_tools
as
utt
...
...
@@ -114,7 +114,7 @@ class test_append(unittest.TestCase):
theano
.
config
.
floatX
,
(
False
,
False
)))()
myMatrix
=
T
.
matrix
()
z
=
Append
Inplace
(
)(
mySymbolicMatricesList
,
myMatrix
)
z
=
Append
(
True
)(
mySymbolicMatricesList
,
myMatrix
)
f
=
theano
.
function
([
mySymbolicMatricesList
,
myMatrix
],
z
,
accept_inplace
=
True
)
...
...
@@ -164,7 +164,7 @@ class test_extend(unittest.TestCase):
mySymbolicMatricesList2
=
TypedListType
(
T
.
TensorType
(
theano
.
config
.
floatX
,
(
False
,
False
)))()
z
=
Extend
Inplace
(
)(
mySymbolicMatricesList1
,
mySymbolicMatricesList2
)
z
=
Extend
(
True
)(
mySymbolicMatricesList1
,
mySymbolicMatricesList2
)
f
=
theano
.
function
([
mySymbolicMatricesList1
,
mySymbolicMatricesList2
],
z
,
accept_inplace
=
True
)
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论