Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
P
pytensor
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
testgroup
pytensor
Commits
de36c64a
提交
de36c64a
authored
10月 13, 2016
作者:
Frederic Bastien
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
clean following the fix
上级
941e3a27
隐藏空白字符变更
内嵌
并排
正在显示
3 个修改的文件
包含
16 行增加
和
44 行删除
+16
-44
dnn.py
theano/gpuarray/dnn.py
+3
-3
dnn.py
theano/sandbox/cuda/dnn.py
+3
-3
pool.py
theano/tensor/signal/pool.py
+10
-38
没有找到文件。
theano/gpuarray/dnn.py
浏览文件 @
de36c64a
...
@@ -2078,7 +2078,7 @@ def local_gpua_pool_dnn_alternative(op, ctx_name, inputs, outputs):
...
@@ -2078,7 +2078,7 @@ def local_gpua_pool_dnn_alternative(op, ctx_name, inputs, outputs):
if
not
op
.
ignore_border
:
if
not
op
.
ignore_border
:
return
return
img
,
ws
,
stride
,
pad
=
inputs
img
,
ws
,
stride
,
pad
=
inputs
nd
=
op
.
ndim
if
op
.
ndim
else
(
img
.
ndim
-
2
)
nd
=
op
.
ndim
if
nd
not
in
(
2
,
3
):
if
nd
not
in
(
2
,
3
):
return
return
img
=
gpu_contiguous
(
as_gpuarray_variable
(
img
,
ctx_name
))
img
=
gpu_contiguous
(
as_gpuarray_variable
(
img
,
ctx_name
))
...
@@ -2102,7 +2102,7 @@ def local_gpua_pool_dnn_grad_stride(op, ctx_name, inputs, outputs):
...
@@ -2102,7 +2102,7 @@ def local_gpua_pool_dnn_grad_stride(op, ctx_name, inputs, outputs):
if
not
op
.
ignore_border
:
if
not
op
.
ignore_border
:
return
return
inp
,
out
,
out_grad
,
ws
,
stride
,
pad
=
inputs
inp
,
out
,
out_grad
,
ws
,
stride
,
pad
=
inputs
nd
=
op
.
ndim
if
op
.
ndim
else
(
inp
.
ndim
-
2
)
nd
=
op
.
ndim
if
nd
not
in
(
2
,
3
):
if
nd
not
in
(
2
,
3
):
return
return
inp
=
gpu_contiguous
(
as_gpuarray_variable
(
inp
,
ctx_name
))
inp
=
gpu_contiguous
(
as_gpuarray_variable
(
inp
,
ctx_name
))
...
@@ -2141,7 +2141,7 @@ def local_gpua_avg_pool_dnn_grad_stride(op, ctx_name, inputs, outputs):
...
@@ -2141,7 +2141,7 @@ def local_gpua_avg_pool_dnn_grad_stride(op, ctx_name, inputs, outputs):
if
not
op
.
ignore_border
:
if
not
op
.
ignore_border
:
return
return
inp
,
out_grad
,
ws
,
stride
,
pad
=
inputs
inp
,
out_grad
,
ws
,
stride
,
pad
=
inputs
nd
=
op
.
ndim
if
op
.
ndim
else
(
inp
.
ndim
-
2
)
nd
=
op
.
ndim
if
nd
not
in
(
2
,
3
):
if
nd
not
in
(
2
,
3
):
return
return
inp
=
gpu_contiguous
(
as_gpuarray_variable
(
inp
,
ctx_name
))
inp
=
gpu_contiguous
(
as_gpuarray_variable
(
inp
,
ctx_name
))
...
...
theano/sandbox/cuda/dnn.py
浏览文件 @
de36c64a
...
@@ -3055,7 +3055,7 @@ if True:
...
@@ -3055,7 +3055,7 @@ if True:
if
not
node
.
op
.
ignore_border
:
if
not
node
.
op
.
ignore_border
:
return
return
img
,
ws
,
stride
,
pad
=
node
.
inputs
img
,
ws
,
stride
,
pad
=
node
.
inputs
nd
=
node
.
op
.
ndim
if
node
.
op
.
ndim
else
(
img
.
ndim
-
2
)
nd
=
node
.
op
.
ndim
mode
=
node
.
op
.
mode
mode
=
node
.
op
.
mode
if
nd
not
in
(
2
,
3
):
if
nd
not
in
(
2
,
3
):
return
return
...
@@ -3098,7 +3098,7 @@ if True:
...
@@ -3098,7 +3098,7 @@ if True:
if
not
node
.
op
.
ignore_border
:
if
not
node
.
op
.
ignore_border
:
return
return
inp
,
out
,
inp_grad
,
ws
,
stride
,
pad
=
node
.
inputs
inp
,
out
,
inp_grad
,
ws
,
stride
,
pad
=
node
.
inputs
nd
=
node
.
op
.
ndim
if
node
.
op
.
ndim
else
(
inp
.
ndim
-
2
)
nd
=
node
.
op
.
ndim
mode
=
node
.
op
.
mode
mode
=
node
.
op
.
mode
if
nd
not
in
(
2
,
3
):
if
nd
not
in
(
2
,
3
):
return
return
...
@@ -3134,7 +3134,7 @@ if True:
...
@@ -3134,7 +3134,7 @@ if True:
if
not
node
.
op
.
ignore_border
:
if
not
node
.
op
.
ignore_border
:
return
return
inp
,
inp_grad
,
ws
,
stride
,
pad
=
node
.
inputs
inp
,
inp_grad
,
ws
,
stride
,
pad
=
node
.
inputs
nd
=
node
.
op
.
ndim
if
node
.
op
.
ndim
else
(
inp
.
ndim
-
2
)
nd
=
node
.
op
.
ndim
mode
=
node
.
op
.
mode
mode
=
node
.
op
.
mode
if
nd
not
in
(
2
,
3
):
if
nd
not
in
(
2
,
3
):
return
return
...
...
theano/tensor/signal/pool.py
浏览文件 @
de36c64a
...
@@ -170,14 +170,14 @@ class Pool(OpenMPOp):
...
@@ -170,14 +170,14 @@ class Pool(OpenMPOp):
'average_exc_pad' include it)
'average_exc_pad' include it)
ndim : int
ndim : int
The number of pooling dimensions N.
The number of pooling dimensions N.
If this number is not specified, the default is set to
2.
The default is
2.
"""
"""
__props__
=
(
'ignore_border'
,
'mode'
,
'ndim'
)
__props__
=
(
'ignore_border'
,
'mode'
,
'ndim'
)
@staticmethod
@staticmethod
def
out_shape
(
imgshape
,
ds
,
ignore_border
=
False
,
st
=
None
,
padding
=
None
,
ndim
=
None
):
def
out_shape
(
imgshape
,
ds
,
ignore_border
=
False
,
st
=
None
,
padding
=
None
,
ndim
=
2
):
"""
"""
Return the shape of the output from this op, for input of given
Return the shape of the output from this op, for input of given
shape and flags.
shape and flags.
...
@@ -204,7 +204,7 @@ class Pool(OpenMPOp):
...
@@ -204,7 +204,7 @@ class Pool(OpenMPOp):
right margins. No padding is added if padding is None.
right margins. No padding is added if padding is None.
ndim : int
ndim : int
The number of pooling dimensions N.
The number of pooling dimensions N.
If this number is not specified, the default is set to
2.
The default is
2.
Returns
Returns
-------
-------
...
@@ -253,10 +253,8 @@ class Pool(OpenMPOp):
...
@@ -253,10 +253,8 @@ class Pool(OpenMPOp):
rval
=
list
(
imgshape
[:
-
ndim
])
+
out_shape
rval
=
list
(
imgshape
[:
-
ndim
])
+
out_shape
return
rval
return
rval
def
__init__
(
self
,
ignore_border
=
False
,
mode
=
'max'
,
ndim
=
None
,
openmp
=
None
):
def
__init__
(
self
,
ignore_border
=
False
,
mode
=
'max'
,
ndim
=
2
,
openmp
=
None
):
super
(
Pool
,
self
)
.
__init__
(
openmp
=
openmp
)
super
(
Pool
,
self
)
.
__init__
(
openmp
=
openmp
)
if
ndim
is
None
:
ndim
=
2
self
.
ndim
=
ndim
self
.
ndim
=
ndim
self
.
ignore_border
=
ignore_border
self
.
ignore_border
=
ignore_border
if
mode
not
in
[
'max'
,
'average_inc_pad'
,
'average_exc_pad'
,
'sum'
]:
if
mode
not
in
[
'max'
,
'average_inc_pad'
,
'average_exc_pad'
,
'sum'
]:
...
@@ -334,8 +332,6 @@ class Pool(OpenMPOp):
...
@@ -334,8 +332,6 @@ class Pool(OpenMPOp):
x
,
ws
,
stride
,
pad
=
inp
x
,
ws
,
stride
,
pad
=
inp
z
,
=
out
z
,
=
out
nd
=
self
.
ndim
nd
=
self
.
ndim
if
nd
is
None
:
nd
=
len
(
x
.
shape
)
-
2
assert
ws
.
shape
==
stride
.
shape
==
pad
.
shape
==
(
nd
,)
assert
ws
.
shape
==
stride
.
shape
==
pad
.
shape
==
(
nd
,)
if
len
(
x
.
shape
)
<
nd
:
if
len
(
x
.
shape
)
<
nd
:
raise
NotImplementedError
(
raise
NotImplementedError
(
...
@@ -419,8 +415,6 @@ class Pool(OpenMPOp):
...
@@ -419,8 +415,6 @@ class Pool(OpenMPOp):
x
,
ws
,
stride
,
pad
=
inp
x
,
ws
,
stride
,
pad
=
inp
z
,
=
out
z
,
=
out
nd
=
self
.
ndim
nd
=
self
.
ndim
if
nd
is
None
:
nd
=
node
.
inputs
[
0
]
.
ndim
-
2
total_ndim
=
node
.
inputs
[
0
]
.
ndim
total_ndim
=
node
.
inputs
[
0
]
.
ndim
non_pool_ndim
=
total_ndim
-
nd
non_pool_ndim
=
total_ndim
-
nd
fail
=
sub
[
'fail'
]
fail
=
sub
[
'fail'
]
...
@@ -721,7 +715,7 @@ class PoolGrad(OpenMPOp):
...
@@ -721,7 +715,7 @@ class PoolGrad(OpenMPOp):
__props__
=
(
'ignore_border'
,
'mode'
,
'ndim'
)
__props__
=
(
'ignore_border'
,
'mode'
,
'ndim'
)
@staticmethod
@staticmethod
def
out_shape
(
imgshape
,
ds
,
ignore_border
=
False
,
st
=
None
,
padding
=
None
,
ndim
=
None
):
def
out_shape
(
imgshape
,
ds
,
ignore_border
=
False
,
st
=
None
,
padding
=
None
,
ndim
=
2
):
"""Return the shape of the output from this op, for input of given
"""Return the shape of the output from this op, for input of given
shape and flags.
shape and flags.
...
@@ -747,9 +741,7 @@ class PoolGrad(OpenMPOp):
...
@@ -747,9 +741,7 @@ class PoolGrad(OpenMPOp):
right margins. No padding is added if padding is None.
right margins. No padding is added if padding is None.
ndim : int
ndim : int
The number of pooling dimensions N.
The number of pooling dimensions N.
If this number is not specified, the default is set to the
The default is 2.
(input.ndim - 2), assuming that the first two dimensions of the input
are non-pooling dimensions.
Returns
Returns
-------
-------
...
@@ -760,8 +752,6 @@ class PoolGrad(OpenMPOp):
...
@@ -760,8 +752,6 @@ class PoolGrad(OpenMPOp):
ignore_border flags.
ignore_border flags.
"""
"""
if
ndim
is
None
:
ndim
=
len
(
imgshape
)
-
2
if
len
(
imgshape
)
<
ndim
:
if
len
(
imgshape
)
<
ndim
:
raise
TypeError
(
'imgshape must have at least {} dimensions'
.
format
(
ndim
))
raise
TypeError
(
'imgshape must have at least {} dimensions'
.
format
(
ndim
))
...
@@ -796,7 +786,7 @@ class PoolGrad(OpenMPOp):
...
@@ -796,7 +786,7 @@ class PoolGrad(OpenMPOp):
rval
=
list
(
imgshape
[:
-
ndim
])
+
out_shape
rval
=
list
(
imgshape
[:
-
ndim
])
+
out_shape
return
rval
return
rval
def
__init__
(
self
,
ignore_border
,
mode
=
'max'
,
ndim
=
None
,
openmp
=
None
):
def
__init__
(
self
,
ignore_border
,
mode
=
'max'
,
ndim
=
2
,
openmp
=
None
):
self
.
ndim
=
ndim
self
.
ndim
=
ndim
self
.
ignore_border
=
ignore_border
self
.
ignore_border
=
ignore_border
if
mode
not
in
[
'max'
,
'sum'
,
'average_inc_pad'
,
'average_exc_pad'
]:
if
mode
not
in
[
'max'
,
'sum'
,
'average_inc_pad'
,
'average_exc_pad'
]:
...
@@ -841,7 +831,7 @@ class PoolGrad(OpenMPOp):
...
@@ -841,7 +831,7 @@ class PoolGrad(OpenMPOp):
class
MaxPoolGrad
(
PoolGrad
):
class
MaxPoolGrad
(
PoolGrad
):
def
__init__
(
self
,
ignore_border
,
ndim
=
None
,
openmp
=
None
):
def
__init__
(
self
,
ignore_border
,
ndim
=
2
,
openmp
=
None
):
PoolGrad
.
__init__
(
self
,
ignore_border
,
mode
=
'max'
,
ndim
=
ndim
,
openmp
=
openmp
)
PoolGrad
.
__init__
(
self
,
ignore_border
,
mode
=
'max'
,
ndim
=
ndim
,
openmp
=
openmp
)
def
make_node
(
self
,
x
,
maxout
,
gz
,
ws
,
stride
=
None
,
pad
=
None
):
def
make_node
(
self
,
x
,
maxout
,
gz
,
ws
,
stride
=
None
,
pad
=
None
):
...
@@ -851,8 +841,6 @@ class MaxPoolGrad(PoolGrad):
...
@@ -851,8 +841,6 @@ class MaxPoolGrad(PoolGrad):
maxout
=
tensor
.
as_tensor_variable
(
maxout
)
maxout
=
tensor
.
as_tensor_variable
(
maxout
)
gz
=
tensor
.
as_tensor_variable
(
gz
)
gz
=
tensor
.
as_tensor_variable
(
gz
)
nd
=
self
.
ndim
nd
=
self
.
ndim
if
nd
is
None
:
nd
=
x
.
ndim
-
2
if
stride
is
None
:
if
stride
is
None
:
stride
=
ws
stride
=
ws
if
pad
is
None
:
if
pad
is
None
:
...
@@ -880,8 +868,6 @@ class MaxPoolGrad(PoolGrad):
...
@@ -880,8 +868,6 @@ class MaxPoolGrad(PoolGrad):
x
,
maxout
,
gz
,
ws
,
stride
,
pad
=
inp
x
,
maxout
,
gz
,
ws
,
stride
,
pad
=
inp
gx_stg
,
=
out
gx_stg
,
=
out
nd
=
self
.
ndim
nd
=
self
.
ndim
if
nd
is
None
:
nd
=
len
(
x
.
shape
)
-
2
assert
ws
.
shape
==
stride
.
shape
==
pad
.
shape
==
(
nd
,)
assert
ws
.
shape
==
stride
.
shape
==
pad
.
shape
==
(
nd
,)
if
len
(
x
.
shape
)
<
nd
:
if
len
(
x
.
shape
)
<
nd
:
raise
NotImplementedError
(
raise
NotImplementedError
(
...
@@ -944,8 +930,6 @@ class MaxPoolGrad(PoolGrad):
...
@@ -944,8 +930,6 @@ class MaxPoolGrad(PoolGrad):
x
,
z
,
gz
,
ws
,
stride
,
pad
=
inp
x
,
z
,
gz
,
ws
,
stride
,
pad
=
inp
gx
,
=
out
gx
,
=
out
nd
=
self
.
ndim
nd
=
self
.
ndim
if
nd
is
None
:
nd
=
node
.
inputs
[
0
]
.
ndim
-
2
total_ndim
=
node
.
inputs
[
0
]
.
ndim
total_ndim
=
node
.
inputs
[
0
]
.
ndim
non_pool_ndim
=
total_ndim
-
nd
non_pool_ndim
=
total_ndim
-
nd
fail
=
sub
[
'fail'
]
fail
=
sub
[
'fail'
]
...
@@ -1162,7 +1146,7 @@ class MaxPoolGrad(PoolGrad):
...
@@ -1162,7 +1146,7 @@ class MaxPoolGrad(PoolGrad):
class
AveragePoolGrad
(
PoolGrad
):
class
AveragePoolGrad
(
PoolGrad
):
def
__init__
(
self
,
ignore_border
,
mode
=
'average_inc_pad'
,
ndim
=
None
):
def
__init__
(
self
,
ignore_border
,
mode
=
'average_inc_pad'
,
ndim
=
2
):
assert
mode
in
[
'sum'
,
'average_inc_pad'
,
'average_exc_pad'
]
assert
mode
in
[
'sum'
,
'average_inc_pad'
,
'average_exc_pad'
]
PoolGrad
.
__init__
(
self
,
ignore_border
,
mode
,
ndim
)
PoolGrad
.
__init__
(
self
,
ignore_border
,
mode
,
ndim
)
...
@@ -1176,8 +1160,6 @@ class AveragePoolGrad(PoolGrad):
...
@@ -1176,8 +1160,6 @@ class AveragePoolGrad(PoolGrad):
x
=
tensor
.
as_tensor_variable
(
x
)
x
=
tensor
.
as_tensor_variable
(
x
)
gz
=
tensor
.
as_tensor_variable
(
gz
)
gz
=
tensor
.
as_tensor_variable
(
gz
)
nd
=
self
.
ndim
nd
=
self
.
ndim
if
nd
is
None
:
nd
=
x
.
ndim
-
2
if
stride
is
None
:
if
stride
is
None
:
stride
=
ws
stride
=
ws
if
pad
is
None
:
if
pad
is
None
:
...
@@ -1203,8 +1185,6 @@ class AveragePoolGrad(PoolGrad):
...
@@ -1203,8 +1185,6 @@ class AveragePoolGrad(PoolGrad):
x
,
gz
,
ws
,
stride
,
pad
=
inp
x
,
gz
,
ws
,
stride
,
pad
=
inp
gx_stg
,
=
out
gx_stg
,
=
out
nd
=
self
.
ndim
nd
=
self
.
ndim
if
nd
is
None
:
nd
=
len
(
x
.
shape
)
-
2
assert
ws
.
shape
==
stride
.
shape
==
pad
.
shape
==
(
nd
,)
assert
ws
.
shape
==
stride
.
shape
==
pad
.
shape
==
(
nd
,)
if
len
(
x
.
shape
)
<
nd
:
if
len
(
x
.
shape
)
<
nd
:
raise
NotImplementedError
(
raise
NotImplementedError
(
...
@@ -1275,8 +1255,6 @@ class AveragePoolGrad(PoolGrad):
...
@@ -1275,8 +1255,6 @@ class AveragePoolGrad(PoolGrad):
x
,
gz
,
ws
,
stride
,
pad
=
inp
x
,
gz
,
ws
,
stride
,
pad
=
inp
gx
,
=
out
gx
,
=
out
nd
=
self
.
ndim
nd
=
self
.
ndim
if
nd
is
None
:
nd
=
node
.
inputs
[
0
]
.
ndim
-
2
total_ndim
=
node
.
inputs
[
0
]
.
ndim
total_ndim
=
node
.
inputs
[
0
]
.
ndim
non_pool_ndim
=
total_ndim
-
nd
non_pool_ndim
=
total_ndim
-
nd
fail
=
sub
[
'fail'
]
fail
=
sub
[
'fail'
]
...
@@ -1503,7 +1481,7 @@ class AveragePoolGrad(PoolGrad):
...
@@ -1503,7 +1481,7 @@ class AveragePoolGrad(PoolGrad):
class
DownsampleFactorMaxGradGrad
(
OpenMPOp
):
class
DownsampleFactorMaxGradGrad
(
OpenMPOp
):
__props__
=
(
'ignore_border'
,
'mode'
,
'ndim'
)
__props__
=
(
'ignore_border'
,
'mode'
,
'ndim'
)
def
__init__
(
self
,
ignore_border
,
mode
=
'max'
,
ndim
=
None
,
openmp
=
None
):
def
__init__
(
self
,
ignore_border
,
mode
=
'max'
,
ndim
=
2
,
openmp
=
None
):
self
.
ndim
=
ndim
self
.
ndim
=
ndim
self
.
ignore_border
=
ignore_border
self
.
ignore_border
=
ignore_border
self
.
mode
=
mode
self
.
mode
=
mode
...
@@ -1517,8 +1495,6 @@ class DownsampleFactorMaxGradGrad(OpenMPOp):
...
@@ -1517,8 +1495,6 @@ class DownsampleFactorMaxGradGrad(OpenMPOp):
maxout
=
tensor
.
as_tensor_variable
(
maxout
)
maxout
=
tensor
.
as_tensor_variable
(
maxout
)
gz
=
tensor
.
as_tensor_variable
(
gz
)
gz
=
tensor
.
as_tensor_variable
(
gz
)
nd
=
self
.
ndim
nd
=
self
.
ndim
if
nd
is
None
:
nd
=
x
.
ndim
-
2
if
stride
is
None
:
if
stride
is
None
:
stride
=
ws
stride
=
ws
if
pad
is
None
:
if
pad
is
None
:
...
@@ -1550,8 +1526,6 @@ class DownsampleFactorMaxGradGrad(OpenMPOp):
...
@@ -1550,8 +1526,6 @@ class DownsampleFactorMaxGradGrad(OpenMPOp):
x
,
maxout
,
ggx
,
ws
,
stride
,
pad
=
inp
x
,
maxout
,
ggx
,
ws
,
stride
,
pad
=
inp
z
,
=
out
z
,
=
out
nd
=
self
.
ndim
nd
=
self
.
ndim
if
nd
is
None
:
nd
=
len
(
x
.
shape
)
-
2
assert
ws
.
shape
==
stride
.
shape
==
pad
.
shape
==
(
nd
,)
assert
ws
.
shape
==
stride
.
shape
==
pad
.
shape
==
(
nd
,)
if
len
(
x
.
shape
)
<
nd
:
if
len
(
x
.
shape
)
<
nd
:
raise
NotImplementedError
(
raise
NotImplementedError
(
...
@@ -1624,8 +1598,6 @@ class DownsampleFactorMaxGradGrad(OpenMPOp):
...
@@ -1624,8 +1598,6 @@ class DownsampleFactorMaxGradGrad(OpenMPOp):
x
,
maxout
,
ggx
,
ws
,
stride
,
pad
=
inp
x
,
maxout
,
ggx
,
ws
,
stride
,
pad
=
inp
z
,
=
out
# the grad of grad
z
,
=
out
# the grad of grad
nd
=
self
.
ndim
nd
=
self
.
ndim
if
nd
is
None
:
nd
=
node
.
inputs
[
0
]
.
ndim
-
2
total_ndim
=
node
.
inputs
[
0
]
.
ndim
total_ndim
=
node
.
inputs
[
0
]
.
ndim
non_pool_ndim
=
total_ndim
-
nd
non_pool_ndim
=
total_ndim
-
nd
fail
=
sub
[
'fail'
]
fail
=
sub
[
'fail'
]
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论