Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
P
pytensor
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
testgroup
pytensor
Commits
68ab8d91
提交
68ab8d91
authored
9月 12, 2013
作者:
Arnaud Bergeron
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
New algortihm for the perform that avoids one of the reshapes.
上级
0f1c32b5
显示空白字符变更
内嵌
并排
正在显示
1 个修改的文件
包含
4 行增加
和
20 行删除
+4
-20
elemwise.py
theano/tensor/elemwise.py
+4
-20
没有找到文件。
theano/tensor/elemwise.py
浏览文件 @
68ab8d91
...
@@ -143,10 +143,6 @@ class DimShuffle(Op):
...
@@ -143,10 +143,6 @@ class DimShuffle(Op):
# list of dimensions of the input to drop
# list of dimensions of the input to drop
self
.
drop
=
[]
self
.
drop
=
[]
# this maps i before dropping dimensions to j after dropping dimensions
# so self.shuffle can be set properly later on
i2j
=
{}
j
=
0
for
i
,
b
in
enumerate
(
input_broadcastable
):
for
i
,
b
in
enumerate
(
input_broadcastable
):
if
i
not
in
new_order
:
if
i
not
in
new_order
:
# we want to drop this dimension because it's not a value in
# we want to drop this dimension because it's not a value in
...
@@ -158,14 +154,9 @@ class DimShuffle(Op):
...
@@ -158,14 +154,9 @@ class DimShuffle(Op):
raise
ValueError
(
raise
ValueError
(
"You cannot drop a non-broadcastable dimension."
,
"You cannot drop a non-broadcastable dimension."
,
(
input_broadcastable
,
new_order
))
(
input_broadcastable
,
new_order
))
else
:
i2j
[
i
]
=
j
j
+=
1
# transposition of non-broadcastable dimensions
# this is the list of the original dimensions that we keep
# This is how the dimensions will be permuted, without accounting for
self
.
shuffle
=
[
x
for
x
in
new_order
if
x
!=
'x'
]
# the extra 'x' broadcastable dimensions to insert.
self
.
shuffle
=
[
i2j
[
x
]
for
x
in
new_order
if
x
!=
'x'
]
# list of dimensions of the output that are broadcastable and were not
# list of dimensions of the output that are broadcastable and were not
# in the original input
# in the original input
...
@@ -237,16 +228,12 @@ class DimShuffle(Op):
...
@@ -237,16 +228,12 @@ class DimShuffle(Op):
res
=
input
res
=
input
if
type
(
res
)
!=
numpy
.
ndarray
and
type
(
res
)
!=
numpy
.
memmap
:
if
type
(
res
)
!=
numpy
.
ndarray
and
type
(
res
)
!=
numpy
.
memmap
:
raise
TypeError
(
res
)
raise
TypeError
(
res
)
shape
=
list
(
res
.
shape
)
for
drop
in
reversed
(
self
.
drop
):
shape
.
pop
(
drop
)
res
=
res
.
reshape
(
shape
)
# transpose
# transpose
res
=
res
.
transpose
(
self
.
shuffle
)
res
=
res
.
transpose
(
self
.
shuffle
+
self
.
drop
)
# augment
# augment
shape
=
list
(
res
.
shape
)
shape
=
list
(
res
.
shape
[:
len
(
self
.
shuffle
)]
)
for
augm
in
self
.
augment
:
for
augm
in
self
.
augment
:
shape
.
insert
(
augm
,
1
)
shape
.
insert
(
augm
,
1
)
res
=
res
.
reshape
(
shape
)
res
=
res
.
reshape
(
shape
)
...
@@ -259,9 +246,6 @@ class DimShuffle(Op):
...
@@ -259,9 +246,6 @@ class DimShuffle(Op):
def
infer_shape
(
self
,
node
,
shapes
):
def
infer_shape
(
self
,
node
,
shapes
):
ishp
,
=
shapes
ishp
,
=
shapes
ishp
=
list
(
ishp
)
for
drop
in
reversed
(
self
.
drop
):
del
ishp
[
drop
]
# transpose
# transpose
rval
=
[
ishp
[
i
]
for
i
in
self
.
shuffle
]
rval
=
[
ishp
[
i
]
for
i
in
self
.
shuffle
]
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论