Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
P
pytensor
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
testgroup
pytensor
Commits
33551a31
提交
33551a31
authored
3月 02, 2015
作者:
Li
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
grad still not working
上级
218c02f9
隐藏空白字符变更
内嵌
并排
正在显示
1 个修改的文件
包含
11 行增加
和
5 行删除
+11
-5
downsample.py
theano/tensor/signal/downsample.py
+11
-5
没有找到文件。
theano/tensor/signal/downsample.py
浏览文件 @
33551a31
...
@@ -100,6 +100,9 @@ class DownsampleFactorMax(Op):
...
@@ -100,6 +100,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 zeros on four borders of the images
:type padding: tuple of two ints
:rtype: list
:rtype: list
:returns: the shape of the output from this op, for input of given
:returns: the shape of the output from this op, for input of given
shape. This will have the same length as imgshape, but with last
shape. This will have the same length as imgshape, but with last
...
@@ -167,6 +170,9 @@ class DownsampleFactorMax(Op):
...
@@ -167,6 +170,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 zeros on four borders of the images
:type padding: tuple of two ints
"""
"""
self
.
ds
=
tuple
(
ds
)
self
.
ds
=
tuple
(
ds
)
if
not
all
([
isinstance
(
d
,
int
)
for
d
in
ds
]):
if
not
all
([
isinstance
(
d
,
int
)
for
d
in
ds
]):
...
@@ -221,8 +227,8 @@ class DownsampleFactorMax(Op):
...
@@ -221,8 +227,8 @@ class DownsampleFactorMax(Op):
pad_w
=
self
.
padding
[
1
]
pad_w
=
self
.
padding
[
1
]
# pad the image
# pad the image
fill
=
x
.
min
()
-
1
fill
=
x
.
min
()
-
1
.
y
=
numpy
.
zeros
((
x
.
shape
[
0
],
x
.
shape
[
1
],
img_rows
,
img_cols
))
+
fill
y
=
numpy
.
zeros
((
x
.
shape
[
0
],
x
.
shape
[
1
],
img_rows
,
img_cols
)
,
dtype
=
x
.
dtype
)
+
fill
y
[:,
:,
pad_h
:(
img_rows
-
pad_h
),
pad_w
:(
img_cols
-
pad_w
)]
=
x
y
[:,
:,
pad_h
:(
img_rows
-
pad_h
),
pad_w
:(
img_cols
-
pad_w
)]
=
x
# max pooling
# max pooling
for
n
in
xrange
(
x
.
shape
[
0
]):
for
n
in
xrange
(
x
.
shape
[
0
]):
...
@@ -332,7 +338,7 @@ class DownsampleFactorMax(Op):
...
@@ -332,7 +338,7 @@ class DownsampleFactorMax(Op):
class
DownsampleFactorMaxGrad
(
Op
):
class
DownsampleFactorMaxGrad
(
Op
):
__props__
=
(
'ds'
,
'ignore_border'
,
'st'
)
__props__
=
(
'ds'
,
'ignore_border'
,
'st'
,
'padding'
)
def
__init__
(
self
,
ds
,
ignore_border
,
st
=
None
,
padding
=
(
0
,
0
)):
def
__init__
(
self
,
ds
,
ignore_border
,
st
=
None
,
padding
=
(
0
,
0
)):
self
.
ds
=
tuple
(
ds
)
self
.
ds
=
tuple
(
ds
)
...
@@ -343,7 +349,7 @@ class DownsampleFactorMaxGrad(Op):
...
@@ -343,7 +349,7 @@ class DownsampleFactorMaxGrad(Op):
self
.
padding
=
tuple
(
padding
)
self
.
padding
=
tuple
(
padding
)
def
__str__
(
self
):
def
__str__
(
self
):
return
'
%
s{
%
s,
%
s,
%
s,
%
s}'
%
(
self
.
__class__
.
__name__
,
return
'
%
s{
%
s,
%
s,
%
s,
%
s}'
%
(
self
.
__class__
.
__name__
,
self
.
ds
,
self
.
st
,
self
.
ignore_border
,
self
.
padding
)
self
.
ds
,
self
.
st
,
self
.
ignore_border
,
self
.
padding
)
def
make_node
(
self
,
x
,
maxout
,
gz
):
def
make_node
(
self
,
x
,
maxout
,
gz
):
...
@@ -373,7 +379,7 @@ class DownsampleFactorMaxGrad(Op):
...
@@ -373,7 +379,7 @@ class DownsampleFactorMaxGrad(Op):
# pad the image
# pad the image
fill
=
x
.
min
()
-
1
fill
=
x
.
min
()
-
1
y
=
numpy
.
zeros
((
x
.
shape
[
0
],
x
.
shape
[
1
],
img_rows
,
img_cols
))
+
fill
y
=
numpy
.
zeros
((
x
.
shape
[
0
],
x
.
shape
[
1
],
img_rows
,
img_cols
)
,
dtype
=
x
.
dtype
)
+
fill
y
[:,
:,
pad_h
:(
img_rows
-
pad_h
),
pad_w
:(
img_cols
-
pad_w
)]
=
x
y
[:,
:,
pad_h
:(
img_rows
-
pad_h
),
pad_w
:(
img_cols
-
pad_w
)]
=
x
gx
=
numpy
.
zeros_like
(
y
)
gx
=
numpy
.
zeros_like
(
y
)
for
n
in
xrange
(
x
.
shape
[
0
]):
for
n
in
xrange
(
x
.
shape
[
0
]):
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论