Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
P
pytensor
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
testgroup
pytensor
Commits
2fa005b3
提交
2fa005b3
authored
8月 28, 2015
作者:
Frederic Bastien
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Warn about pending ignore_border default value change.
上级
77f6b2be
隐藏空白字符变更
内嵌
并排
正在显示
2 个修改的文件
包含
12 行增加
和
3 行删除
+12
-3
downsample.py
theano/tensor/signal/downsample.py
+11
-2
test_downsample.py
theano/tensor/signal/tests/test_downsample.py
+1
-1
没有找到文件。
theano/tensor/signal/downsample.py
浏览文件 @
2fa005b3
...
@@ -9,6 +9,7 @@ from __future__ import print_function
...
@@ -9,6 +9,7 @@ from __future__ import print_function
# This file should move along with conv.py
# This file should move along with conv.py
from
six.moves
import
xrange
from
six.moves
import
xrange
import
six.moves.builtins
as
builtins
import
six.moves.builtins
as
builtins
import
warnings
import
numpy
import
numpy
...
@@ -44,7 +45,7 @@ def max_pool_2d_same_size(input, patch_size):
...
@@ -44,7 +45,7 @@ def max_pool_2d_same_size(input, patch_size):
return
outs
return
outs
def
max_pool_2d
(
input
,
ds
,
ignore_border
=
Fals
e
,
st
=
None
,
padding
=
(
0
,
0
),
def
max_pool_2d
(
input
,
ds
,
ignore_border
=
Non
e
,
st
=
None
,
padding
=
(
0
,
0
),
mode
=
'max'
):
mode
=
'max'
):
"""
"""
Takes as input a N-D tensor, where N >= 2. It downscales the input image by
Takes as input a N-D tensor, where N >= 2. It downscales the input image by
...
@@ -58,7 +59,7 @@ def max_pool_2d(input, ds, ignore_border=False, st=None, padding=(0, 0),
...
@@ -58,7 +59,7 @@ def max_pool_2d(input, ds, ignore_border=False, st=None, padding=(0, 0),
ds : tuple of length 2
ds : tuple of length 2
Factor by which to downscale (vertical ds, horizontal ds).
Factor by which to downscale (vertical ds, horizontal ds).
(2,2) will halve the image in each dimension.
(2,2) will halve the image in each dimension.
ignore_border : bool
ignore_border : bool
(default None, mean print warning and set False)
When True, (5,5) input with ds=(2,2) will generate a (2,2) output.
When True, (5,5) input with ds=(2,2) will generate a (2,2) output.
(3,3) otherwise.
(3,3) otherwise.
st : tuple of lenght 2
st : tuple of lenght 2
...
@@ -77,6 +78,14 @@ def max_pool_2d(input, ds, ignore_border=False, st=None, padding=(0, 0),
...
@@ -77,6 +78,14 @@ def max_pool_2d(input, ds, ignore_border=False, st=None, padding=(0, 0),
"""
"""
if
input
.
ndim
<
2
:
if
input
.
ndim
<
2
:
raise
NotImplementedError
(
'max_pool_2d requires a dimension >= 2'
)
raise
NotImplementedError
(
'max_pool_2d requires a dimension >= 2'
)
if
ignore_border
is
None
:
warnings
.
warn
(
"max_pool_2d() will have the parameter ignore_border"
" default value change to True (currently"
" False). To be safe with all Theano versions,"
" explicitly add the parameter ignore_border=True."
" (this is also faster then ignore_border=False)"
,
stacklevel
=
2
)
ignore_border
=
False
if
input
.
ndim
==
4
:
if
input
.
ndim
==
4
:
op
=
DownsampleFactorMax
(
ds
,
ignore_border
,
st
=
st
,
padding
=
padding
,
op
=
DownsampleFactorMax
(
ds
,
ignore_border
,
st
=
st
,
padding
=
padding
,
mode
=
mode
)
mode
=
mode
)
...
...
theano/tensor/signal/tests/test_downsample.py
浏览文件 @
2fa005b3
...
@@ -629,7 +629,7 @@ class TestDownsampleFactorMax(utt.InferShapeTester):
...
@@ -629,7 +629,7 @@ class TestDownsampleFactorMax(utt.InferShapeTester):
x_vec
=
tensor
.
vector
(
'x'
)
x_vec
=
tensor
.
vector
(
'x'
)
z
=
tensor
.
dot
(
x_vec
.
dimshuffle
(
0
,
'x'
),
z
=
tensor
.
dot
(
x_vec
.
dimshuffle
(
0
,
'x'
),
x_vec
.
dimshuffle
(
'x'
,
0
))
x_vec
.
dimshuffle
(
'x'
,
0
))
y
=
max_pool_2d
(
input
=
z
,
ds
=
(
2
,
2
))
y
=
max_pool_2d
(
input
=
z
,
ds
=
(
2
,
2
)
,
ignore_border
=
True
)
C
=
tensor
.
exp
(
tensor
.
sum
(
y
))
C
=
tensor
.
exp
(
tensor
.
sum
(
y
))
grad_hess
=
tensor
.
hessian
(
cost
=
C
,
wrt
=
x_vec
)
grad_hess
=
tensor
.
hessian
(
cost
=
C
,
wrt
=
x_vec
)
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论