Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
P
pytensor
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
testgroup
pytensor
Commits
b14a0e30
提交
b14a0e30
authored
3月 03, 2015
作者:
Li
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
better wording
上级
bd5dc5a8
隐藏空白字符变更
内嵌
并排
正在显示
2 个修改的文件
包含
34 行增加
和
20 行删除
+34
-20
downsample.py
theano/tensor/signal/downsample.py
+16
-8
test_downsample.py
theano/tensor/signal/tests/test_downsample.py
+18
-12
没有找到文件。
theano/tensor/signal/downsample.py
浏览文件 @
b14a0e30
...
@@ -39,6 +39,10 @@ def max_pool_2d(input, ds, ignore_border=False, st=None, padding=(0, 0)):
...
@@ -39,6 +39,10 @@ def max_pool_2d(input, ds, ignore_border=False, st=None, padding=(0, 0)):
over rows/cols to get the the next pool region.
over rows/cols to get the the next pool region.
if st is None, it is considered equal to ds
if st is None, it is considered equal to ds
(no overlap on pooling regions)
(no overlap on pooling regions)
:param padding: (pad_h, pad_w), pad zeros to extend beyond four borders
of the images, pad_h is the size of the top and bottom margins,
and pad_w is the size of the left and right margins.
:type padding: tuple of two ints
"""
"""
if
input
.
ndim
<
2
:
if
input
.
ndim
<
2
:
...
@@ -101,8 +105,9 @@ class DownsampleFactorMax(Op):
...
@@ -101,8 +105,9 @@ class DownsampleFactorMax(Op):
extra row/col of partial downsampling (False) or ignore it (True).
extra row/col of partial downsampling (False) or ignore it (True).
:type ignore_border: bool
:type ignore_border: bool
:param padding: (pad_h, pad_w), pad zeros on four borders
:param padding: (pad_h, pad_w), pad zeros to extend beyond four borders
of the images, pad_h for padding rows, and pad_w for columns.
of the images, pad_h is the size of the top and bottom margins,
and pad_w is the size of the left and right margins.
:type padding: tuple of two ints
:type padding: tuple of two ints
:rtype: list
:rtype: list
...
@@ -172,8 +177,9 @@ class DownsampleFactorMax(Op):
...
@@ -172,8 +177,9 @@ class DownsampleFactorMax(Op):
(no overlap on pooling regions)
(no overlap on pooling regions)
: type st: list or tuple of two ints
: type st: list or tuple of two ints
:param padding: (pad_h, pad_w), pad zeros on four borders
:param padding: (pad_h, pad_w), pad zeros to extend beyond four borders
of the images, pad_h for padding rows, and pad_w for columns.
of the images, pad_h is the size of the top and bottom margins,
and pad_w is the size of the left and right margins.
:type padding: tuple of two ints
:type padding: tuple of two ints
"""
"""
...
@@ -226,10 +232,11 @@ class DownsampleFactorMax(Op):
...
@@ -226,10 +232,11 @@ class DownsampleFactorMax(Op):
pc
=
zz
.
shape
[
-
1
]
pc
=
zz
.
shape
[
-
1
]
ds0
,
ds1
=
self
.
ds
ds0
,
ds1
=
self
.
ds
st0
,
st1
=
self
.
st
st0
,
st1
=
self
.
st
img_rows
=
x
.
shape
[
-
2
]
+
2
*
self
.
padding
[
0
]
img_cols
=
x
.
shape
[
-
1
]
+
2
*
self
.
padding
[
1
]
pad_h
=
self
.
padding
[
0
]
pad_h
=
self
.
padding
[
0
]
pad_w
=
self
.
padding
[
1
]
pad_w
=
self
.
padding
[
1
]
img_rows
=
x
.
shape
[
-
2
]
+
2
*
pad_h
img_cols
=
x
.
shape
[
-
1
]
+
2
*
pad_w
# pad the image
# pad the image
fill
=
x
.
min
()
-
1.
fill
=
x
.
min
()
-
1.
...
@@ -377,10 +384,11 @@ class DownsampleFactorMaxGrad(Op):
...
@@ -377,10 +384,11 @@ class DownsampleFactorMaxGrad(Op):
pc
=
maxout
.
shape
[
-
1
]
pc
=
maxout
.
shape
[
-
1
]
ds0
,
ds1
=
self
.
ds
ds0
,
ds1
=
self
.
ds
st0
,
st1
=
self
.
st
st0
,
st1
=
self
.
st
img_rows
=
x
.
shape
[
-
2
]
+
2
*
self
.
padding
[
0
]
img_cols
=
x
.
shape
[
-
1
]
+
2
*
self
.
padding
[
1
]
pad_h
=
self
.
padding
[
0
]
pad_h
=
self
.
padding
[
0
]
pad_w
=
self
.
padding
[
1
]
pad_w
=
self
.
padding
[
1
]
img_rows
=
x
.
shape
[
-
2
]
+
2
*
pad_h
img_cols
=
x
.
shape
[
-
1
]
+
2
*
pad_w
# pad the image
# pad the image
fill
=
x
.
min
()
-
1
fill
=
x
.
min
()
-
1
y
=
numpy
.
zeros
(
y
=
numpy
.
zeros
(
...
...
theano/tensor/signal/tests/test_downsample.py
浏览文件 @
b14a0e30
...
@@ -267,18 +267,24 @@ class TestDownsampleFactorMax(utt.InferShapeTester):
...
@@ -267,18 +267,24 @@ class TestDownsampleFactorMax(utt.InferShapeTester):
def
test_DownsampleFactorMaxPaddingStride_grad
(
self
):
def
test_DownsampleFactorMaxPaddingStride_grad
(
self
):
rng
=
numpy
.
random
.
RandomState
(
utt
.
fetch_seed
())
rng
=
numpy
.
random
.
RandomState
(
utt
.
fetch_seed
())
imval
=
rng
.
rand
(
1
,
1
,
10
,
10
)
*
10.0
imgsizes
=
((
10
,
10
),
(
10
,
5
))
maxpoolsize
=
(
5
,
3
)
maxpoolsizes
=
((
5
,
3
),(
3
,
5
))
stridesize
=
(
3
,
2
)
stridesizes
=
((
3
,
2
),
(
2
,
3
))
paddingsize
=
(
2
,
2
)
paddingsizes
=
((
2
,
2
),(
2
,
1
))
for
i
in
range
(
len
(
imgsizes
)):
def
mp
(
input
):
imgsize
=
imgsizes
[
i
]
return
DownsampleFactorMax
(
imval
=
rng
.
rand
(
1
,
1
,
imgsize
[
0
],
imgsize
[
1
])
*
10.0
maxpoolsize
,
ignore_border
=
True
,
maxpoolsize
=
maxpoolsizes
[
i
]
st
=
stridesize
,
stridesize
=
stridesizes
[
i
]
padding
=
paddingsize
,
paddingsize
=
paddingsizes
[
i
]
)(
input
)
utt
.
verify_grad
(
mp
,
[
imval
],
rng
=
rng
)
def
mp
(
input
):
return
DownsampleFactorMax
(
maxpoolsize
,
ignore_border
=
True
,
st
=
stridesize
,
padding
=
paddingsize
,
)(
input
)
utt
.
verify_grad
(
mp
,
[
imval
],
rng
=
rng
)
def
test_DownsampleFactorMax_grad
(
self
):
def
test_DownsampleFactorMax_grad
(
self
):
rng
=
numpy
.
random
.
RandomState
(
utt
.
fetch_seed
())
rng
=
numpy
.
random
.
RandomState
(
utt
.
fetch_seed
())
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论