Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
P
pytensor
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
testgroup
pytensor
Commits
c971bfd9
提交
c971bfd9
authored
4月 11, 2011
作者:
Frederic Bastien
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Following code review optimized Rebroadcast infer_shape.
Insert constant 1 when the dimensions is broadcastable.
上级
dafbb7fa
显示空白字符变更
内嵌
并排
正在显示
2 个修改的文件
包含
34 行增加
和
3 行删除
+34
-3
basic.py
theano/tensor/basic.py
+10
-1
test_basic.py
theano/tensor/tests/test_basic.py
+24
-2
没有找到文件。
theano/tensor/basic.py
浏览文件 @
c971bfd9
...
...
@@ -3292,7 +3292,16 @@ class Rebroadcast(Op):
# restore the broadcasting pattern of the input
return
Rebroadcast
(
*
[(
axis
,
x
.
type
.
broadcastable
[
axis
])
for
axis
,
value
in
self
.
axis
.
iteritems
()])(
gz
),
def
infer_shape
(
self
,
node
,
ishapes
):
return
ishapes
assert
len
(
ishapes
)
==
1
l
=
[]
one
=
constant
(
1
)
for
ax
in
range
(
len
(
ishapes
[
0
])):
if
self
.
axis
.
get
(
ax
,
False
):
l
.
append
(
one
)
else
:
l
.
append
(
ishapes
[
0
][
ax
])
return
[
tuple
(
l
)]
def
addbroadcast
(
x
,
*
axes
):
"""
...
...
theano/tensor/tests/test_basic.py
浏览文件 @
c971bfd9
...
...
@@ -4173,9 +4173,19 @@ class test_broadcast(unittest.TestCase):
def
test_infer_shape
(
self
):
x
=
matrix
()
y
=
addbroadcast
(
x
,
0
)
y
=
addbroadcast
(
x
,
0
)
f
=
theano
.
function
([
x
],
y
.
shape
)
f
(
numpy
.
zeros
((
1
,
5
),
dtype
=
config
.
floatX
))
assert
(
f
(
numpy
.
zeros
((
1
,
5
),
dtype
=
config
.
floatX
))
==
[
1
,
5
])
.
all
()
topo
=
f
.
maker
.
env
.
toposort
()
if
theano
.
config
.
mode
!=
'FAST_COMPILE'
:
assert
len
(
topo
)
==
2
assert
isinstance
(
topo
[
0
]
.
op
,
opt
.
Shape_i
)
assert
isinstance
(
topo
[
1
]
.
op
,
opt
.
MakeVector
)
x
=
matrix
()
y
=
unbroadcast
(
x
,
0
)
f
=
theano
.
function
([
x
],
y
.
shape
)
assert
(
f
(
numpy
.
zeros
((
2
,
5
),
dtype
=
config
.
floatX
))
==
[
2
,
5
])
.
all
()
topo
=
f
.
maker
.
env
.
toposort
()
if
theano
.
config
.
mode
!=
'FAST_COMPILE'
:
assert
len
(
topo
)
==
3
...
...
@@ -4183,6 +4193,18 @@ class test_broadcast(unittest.TestCase):
assert
isinstance
(
topo
[
1
]
.
op
,
opt
.
Shape_i
)
assert
isinstance
(
topo
[
2
]
.
op
,
opt
.
MakeVector
)
x
=
row
()
y
=
unbroadcast
(
x
,
0
)
f
=
theano
.
function
([
x
],
y
.
shape
)
assert
(
f
(
numpy
.
zeros
((
1
,
5
),
dtype
=
config
.
floatX
))
==
[
1
,
5
])
.
all
()
topo
=
f
.
maker
.
env
.
toposort
()
if
theano
.
config
.
mode
!=
'FAST_COMPILE'
:
assert
len
(
topo
)
==
2
assert
isinstance
(
topo
[
0
]
.
op
,
opt
.
Shape_i
)
assert
isinstance
(
topo
[
1
]
.
op
,
opt
.
MakeVector
)
def
test_mod
():
"""
We add this test as not all language and C implementation give the same
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论