Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
P
pytensor
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
testgroup
pytensor
Commits
f3fd620a
提交
f3fd620a
authored
11月 09, 2010
作者:
Frederic Bastien
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
make convolution op accept Constant variable as shape.
上级
d2630156
隐藏空白字符变更
内嵌
并排
正在显示
2 个修改的文件
包含
32 行增加
和
2 行删除
+32
-2
conv.py
theano/tensor/nnet/conv.py
+17
-0
test_conv.py
theano/tensor/nnet/tests/test_conv.py
+15
-2
没有找到文件。
theano/tensor/nnet/conv.py
浏览文件 @
f3fd620a
...
@@ -69,6 +69,23 @@ def conv2d(input, filters, image_shape=None, filter_shape=None,
...
@@ -69,6 +69,23 @@ def conv2d(input, filters, image_shape=None, filter_shape=None,
:return: set of feature maps generated by convolutional layer. Tensor is of shape
:return: set of feature maps generated by convolutional layer. Tensor is of shape
(batch size, nb filters, output row, output col)
(batch size, nb filters, output row, output col)
"""
"""
#accept Constant value for image_shape and filter_shape.
if
image_shape
is
not
None
:
image_shape
=
list
(
image_shape
)
for
i
in
range
(
len
(
image_shape
)):
if
image_shape
[
i
]
is
not
None
:
image_shape
[
i
]
=
tensor
.
get_constant_value
(
tensor
.
as_tensor_variable
(
image_shape
[
i
]))
assert
str
(
image_shape
[
i
]
.
dtype
)
.
startswith
(
'int'
)
image_shape
[
i
]
=
int
(
image_shape
[
i
])
if
filter_shape
is
not
None
:
filter_shape
=
list
(
filter_shape
)
for
i
in
range
(
len
(
filter_shape
)):
if
filter_shape
[
i
]
is
not
None
:
filter_shape
[
i
]
=
tensor
.
get_constant_value
(
tensor
.
as_tensor_variable
(
filter_shape
[
i
]))
assert
str
(
filter_shape
[
i
]
.
dtype
)
.
startswith
(
'int'
)
filter_shape
[
i
]
=
int
(
filter_shape
[
i
])
if
image_shape
and
filter_shape
:
if
image_shape
and
filter_shape
:
try
:
try
:
assert
image_shape
[
1
]
==
filter_shape
[
1
]
assert
image_shape
[
1
]
==
filter_shape
[
1
]
...
...
theano/tensor/nnet/tests/test_conv.py
浏览文件 @
f3fd620a
...
@@ -25,9 +25,9 @@ class TestConv2D(unittest.TestCase):
...
@@ -25,9 +25,9 @@ class TestConv2D(unittest.TestCase):
verify_grad
=
True
,
should_raise
=
False
):
verify_grad
=
True
,
should_raise
=
False
):
if
N_image_shape
is
None
:
if
N_image_shape
is
None
:
N_image_shape
=
image_shape
N_image_shape
=
[
T
.
get_constant_value
(
T
.
as_tensor_variable
(
x
))
for
x
in
image_shape
]
if
N_filter_shape
is
None
:
if
N_filter_shape
is
None
:
N_filter_shape
=
filter_shape
N_filter_shape
=
[
T
.
get_constant_value
(
T
.
as_tensor_variable
(
x
))
for
x
in
filter_shape
]
if
not
input
:
if
not
input
:
input
=
self
.
input
input
=
self
.
input
...
@@ -203,6 +203,19 @@ class TestConv2D(unittest.TestCase):
...
@@ -203,6 +203,19 @@ class TestConv2D(unittest.TestCase):
self
.
validate
((
3
,
2
,
7
,
5
),
(
5
,
2
,
2
,
3
),
'full'
,
subsample
=
(
2
,
2
))
self
.
validate
((
3
,
2
,
7
,
5
),
(
5
,
2
,
2
,
3
),
'full'
,
subsample
=
(
2
,
2
))
self
.
validate
((
3
,
2
,
7
,
5
),
(
5
,
2
,
2
,
3
),
'valid'
,
subsample
=
(
2
,
1
))
self
.
validate
((
3
,
2
,
7
,
5
),
(
5
,
2
,
2
,
3
),
'valid'
,
subsample
=
(
2
,
1
))
def
test_shape_Constant_tensor
(
self
):
"""
Tests convolution where the {image,filter}_shape is a Constant tensor.
"""
as_t
=
T
.
as_tensor_variable
self
.
validate
((
as_t
(
3
),
as_t
(
2
),
as_t
(
7
),
as_t
(
5
)),
(
5
,
2
,
2
,
3
),
'valid'
)
self
.
validate
(
as_t
([
3
,
2
,
7
,
5
]),
(
5
,
2
,
2
,
3
),
'valid'
)
self
.
validate
(
as_t
((
3
,
2
,
7
,
5
)),
(
5
,
2
,
2
,
3
),
'valid'
)
self
.
validate
((
3
,
2
,
7
,
5
),
(
as_t
(
5
),
as_t
(
2
),
as_t
(
2
),
as_t
(
3
)),
'valid'
)
self
.
validate
((
3
,
2
,
7
,
5
),
as_t
([
5
,
2
,
2
,
3
]),
'valid'
)
self
.
validate
((
3
,
2
,
7
,
5
),
as_t
((
5
,
2
,
2
,
3
)),
'valid'
)
self
.
validate
(
as_t
([
3
,
2
,
7
,
5
]),
as_t
([
5
,
2
,
2
,
3
]),
'full'
)
def
test_invalid_filter_shape
(
self
):
def
test_invalid_filter_shape
(
self
):
"""
"""
Tests scenario where filter_shape[1] != input_shape[1]
Tests scenario where filter_shape[1] != input_shape[1]
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论