Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
P
pytensor
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
testgroup
pytensor
Commits
fb403768
提交
fb403768
authored
7月 31, 2014
作者:
Frederic
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Do as the doc say, don't crash when there is None in the shape info elements.
上级
97d3b7a9
显示空白字符变更
内嵌
并排
正在显示
2 个修改的文件
包含
22 行增加
和
7 行删除
+22
-7
conv.py
theano/tensor/nnet/conv.py
+16
-7
test_conv.py
theano/tensor/nnet/tests/test_conv.py
+6
-0
没有找到文件。
theano/tensor/nnet/conv.py
浏览文件 @
fb403768
...
@@ -241,6 +241,16 @@ class ConvOp(OpenMPOp):
...
@@ -241,6 +241,16 @@ class ConvOp(OpenMPOp):
#valid time, full time
#valid time, full time
speed_unroll_patch_shape
=
[
1.2967290878295898
,
5.5283889770507812
]
speed_unroll_patch_shape
=
[
1.2967290878295898
,
5.5283889770507812
]
@staticmethod
def
has_all_shape
(
imshp
,
kshp
,
nkern
,
bsize
):
all_shape
=
(
imshp
is
not
None
and
kshp
is
not
None
and
nkern
is
not
None
and
bsize
is
not
None
)
if
(
all_shape
and
(
any
([
True
for
sh
in
imshp
if
sh
is
None
])
or
any
([
True
for
sh
in
kshp
if
sh
is
None
]))):
all_shape
=
False
return
all_shape
@staticmethod
@staticmethod
def
getOutputShape
(
inshp
,
kshp
,
stride
=
(
1
,
1
),
mode
=
'valid'
):
def
getOutputShape
(
inshp
,
kshp
,
stride
=
(
1
,
1
),
mode
=
'valid'
):
"""
"""
...
@@ -371,8 +381,7 @@ class ConvOp(OpenMPOp):
...
@@ -371,8 +381,7 @@ class ConvOp(OpenMPOp):
raise
TypeError
(
'ConvOp.__init__ param dy must be an int'
,
dy
)
raise
TypeError
(
'ConvOp.__init__ param dy must be an int'
,
dy
)
dy
=
int
(
dy
)
dy
=
int
(
dy
)
all_shape
=
imshp
is
not
None
and
kshp
is
not
None
and
\
all_shape
=
self
.
has_all_shape
(
imshp
,
kshp
,
nkern
,
bsize
)
nkern
is
not
None
and
bsize
is
not
None
if
(
unroll_batch
or
unroll_kern
)
and
not
all_shape
:
if
(
unroll_batch
or
unroll_kern
)
and
not
all_shape
:
raise
Exception
(
"In ConvOp, when using unroll_batch and"
raise
Exception
(
"In ConvOp, when using unroll_batch and"
...
@@ -484,7 +493,7 @@ class ConvOp(OpenMPOp):
...
@@ -484,7 +493,7 @@ class ConvOp(OpenMPOp):
if
not
self
.
out_mode
in
[
"valid"
,
"full"
]:
if
not
self
.
out_mode
in
[
"valid"
,
"full"
]:
raise
Exception
(
"Mode
%
s not implemented"
%
self
.
out_mode
)
raise
Exception
(
"Mode
%
s not implemented"
%
self
.
out_mode
)
if
all_shap
e
and
not
(
self
.
outshp
>
0
)
.
all
():
if
self
.
outshp
is
not
Non
e
and
not
(
self
.
outshp
>
0
)
.
all
():
raise
Exception
(
"Bad size for the output shape. Verify that [post-"
raise
Exception
(
"Bad size for the output shape. Verify that [post-"
"supersampling] input shape (
%
s) and kern"
"supersampling] input shape (
%
s) and kern"
" shape(
%
s) are ok. (Hint: kerns must fit inside"
" shape(
%
s) are ok. (Hint: kerns must fit inside"
...
@@ -807,8 +816,8 @@ class ConvOp(OpenMPOp):
...
@@ -807,8 +816,8 @@ class ConvOp(OpenMPOp):
"ERROR: We disable ConvOp.grad now when dx or "
"ERROR: We disable ConvOp.grad now when dx or "
"dy are different from 1 and 2, as there is a bug in it."
)
"dy are different from 1 and 2, as there is a bug in it."
)
all_shape
=
(
self
.
imshp
is
not
None
and
self
.
kshp
is
not
None
and
all_shape
=
self
.
has_all_shape
(
self
.
imshp
,
self
.
kshp
,
self
.
nkern
is
not
None
and
self
.
bsize
is
not
Non
e
)
self
.
nkern
,
self
.
bsiz
e
)
if
not
all_shape
and
(
self
.
dx
!=
1
or
self
.
dy
!=
1
):
if
not
all_shape
and
(
self
.
dx
!=
1
or
self
.
dy
!=
1
):
raise
Exception
(
"ConvOp.grad when dx!=1 or dy!=1 we must have all "
raise
Exception
(
"ConvOp.grad when dx!=1 or dy!=1 we must have all "
...
@@ -1031,8 +1040,8 @@ using namespace std;
...
@@ -1031,8 +1040,8 @@ using namespace std;
d
=
locals
()
d
=
locals
()
d
.
update
(
sub
)
d
.
update
(
sub
)
all_shape
=
(
self
.
imshp
is
not
None
and
self
.
kshp
is
not
None
and
all_shape
=
self
.
has_all_shape
(
self
.
imshp
,
self
.
kshp
,
self
.
nkern
is
not
None
and
self
.
bsize
is
not
Non
e
)
self
.
nkern
,
self
.
bsiz
e
)
d
[
"self_out_mode"
]
=
self
.
out_mode
d
[
"self_out_mode"
]
=
self
.
out_mode
d
[
"self_dx"
]
=
self
.
dx
d
[
"self_dx"
]
=
self
.
dx
...
...
theano/tensor/nnet/tests/test_conv.py
浏览文件 @
fb403768
...
@@ -359,6 +359,12 @@ class TestConv2D(utt.InferShapeTester):
...
@@ -359,6 +359,12 @@ class TestConv2D(utt.InferShapeTester):
self
.
validate
((
None
,
2
,
None
,
None
),
(
None
,
2
,
5
,
5
),
self
.
validate
((
None
,
2
,
None
,
None
),
(
None
,
2
,
5
,
5
),
N_image_shape
=
(
3
,
2
,
8
,
8
),
N_image_shape
=
(
3
,
2
,
8
,
8
),
N_filter_shape
=
(
4
,
2
,
5
,
5
))
N_filter_shape
=
(
4
,
2
,
5
,
5
))
self
.
validate
((
3
,
2
,
8
,
8
),
(
4
,
2
,
None
,
5
),
N_image_shape
=
(
3
,
2
,
8
,
8
),
N_filter_shape
=
(
4
,
2
,
5
,
5
))
self
.
validate
((
3
,
2
,
8
,
8
),
(
4
,
2
,
5
,
None
),
N_image_shape
=
(
3
,
2
,
8
,
8
),
N_filter_shape
=
(
4
,
2
,
5
,
5
))
def
test_wrong_info
(
self
):
def
test_wrong_info
(
self
):
"""
"""
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论