Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
P
pytensor
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
testgroup
pytensor
Commits
e686253f
提交
e686253f
authored
8月 23, 2012
作者:
Frederic
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fix gh-883. Fix a crash introduced in the trunk for reshape([-1])
上级
3474a426
隐藏空白字符变更
内嵌
并排
正在显示
2 个修改的文件
包含
25 行增加
和
3 行删除
+25
-3
basic.py
theano/tensor/basic.py
+4
-2
test_basic.py
theano/tensor/tests/test_basic.py
+21
-1
没有找到文件。
theano/tensor/basic.py
浏览文件 @
e686253f
...
...
@@ -5391,11 +5391,13 @@ class Reshape(Op):
requ
=
list
(
requ
.
data
)
requ_part
=
[
ele
for
ele
in
requ
if
ele
!=
-
1
]
crit
=
len
(
requ
)
-
len
(
requ_part
)
if
crit
==
1
:
missing
=
numpy
.
prod
(
ishapes
[
0
])
/
numpy
.
prod
(
requ_part
)
if
crit
==
1
and
len
(
requ_part
)
>
0
:
missing
=
mul
(
*
ishapes
[
0
])
/
mul
(
*
requ_part
)
for
i
,
ele
in
enumerate
(
requ
):
if
ele
==
-
1
:
requ
[
i
]
=
missing
elif
crit
==
1
:
# we reshape to -1
requ
=
[
mul
(
*
ishapes
[
0
])]
elif
crit
>
1
:
raise
ValueError
(
'shape argument to Reshape.perform'
' must have at most one entry equal to -1'
)
...
...
theano/tensor/tests/test_basic.py
浏览文件 @
e686253f
...
...
@@ -6686,8 +6686,17 @@ class TestInferShape(utt.InferShapeTester):
# (non-constant) input shape
admat
=
dmatrix
()
aivec
=
ivector
()
ndim
=
2
ndim
=
1
admat_val
=
rand
(
3
,
4
)
self
.
_compile_and_check
([
admat
],
[
Reshape
(
ndim
)(
admat
,
[
12
])],
[
admat_val
],
Reshape
)
self
.
_compile_and_check
([
admat
],
[
Reshape
(
ndim
)(
admat
,
[
-
1
])],
[
admat_val
],
Reshape
)
ndim
=
2
self
.
_compile_and_check
([
admat
],
[
Reshape
(
ndim
)(
admat
,
[
4
,
3
])],
[
admat_val
],
Reshape
)
...
...
@@ -6696,6 +6705,17 @@ class TestInferShape(utt.InferShapeTester):
[
Reshape
(
ndim
)(
admat
,
[
4
,
-
1
])],
[
admat_val
],
Reshape
)
self
.
_compile_and_check
([
admat
],
[
Reshape
(
ndim
)(
admat
,
[
3
,
-
1
])],
[
admat_val
],
Reshape
)
self
.
_compile_and_check
([
admat
],
[
Reshape
(
ndim
)(
admat
,
[
-
1
,
3
])],
[
admat_val
],
Reshape
)
self
.
_compile_and_check
([
admat
],
[
Reshape
(
ndim
)(
admat
,
[
-
1
,
4
])],
[
admat_val
],
Reshape
)
# enable when infer_shape is generalized:
# self._compile_and_check([admat, aivec],
# [Reshape(ndim)(admat, aivec)],
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论