Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
P
pytensor
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
testgroup
pytensor
Commits
93b4fb57
提交
93b4fb57
authored
2月 24, 2016
作者:
Nicolas Ballas
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
small fix to make the tests pass + flake8
上级
ecc4e7b9
显示空白字符变更
内嵌
并排
正在显示
3 个修改的文件
包含
17 行增加
和
22 行删除
+17
-22
test_abstractconv.py
theano/sandbox/cuda/tests/test_abstractconv.py
+3
-2
abstract_conv.py
theano/tensor/nnet/abstract_conv.py
+5
-10
test_abstract_conv.py
theano/tensor/nnet/tests/test_abstract_conv.py
+9
-10
没有找到文件。
theano/sandbox/cuda/tests/test_abstractconv.py
浏览文件 @
93b4fb57
...
@@ -46,13 +46,14 @@ class TestDnnConv2d(test_abstract_conv.BaseTestConv2d):
...
@@ -46,13 +46,14 @@ class TestDnnConv2d(test_abstract_conv.BaseTestConv2d):
provide_shape
=
provide_shape
,
border_mode
=
b
,
provide_shape
=
provide_shape
,
border_mode
=
b
,
filter_flip
=
flip
,
target_op
=
GpuDnnConvGradI
)
filter_flip
=
flip
,
target_op
=
GpuDnnConvGradI
)
class
TestCorrMMConv2d
(
test_abstract_conv
.
TestConv2d
):
class
TestCorrMMConv2d
(
test_abstract_conv
.
BaseTestConv2d
):
def
setUp
(
self
):
def
setUp
(
self
):
super
(
TestCorrMMConv2d
,
self
)
.
setUp
()
super
(
TestCorrMMConv2d
,
self
)
.
setUp
()
self
.
shared
=
gpu_shared
self
.
shared
=
gpu_shared
self
.
mode
=
mode_with_gpu
.
excluding
(
'cudnn'
)
self
.
mode
=
mode_with_gpu
.
excluding
(
'cudnn'
)
def
t
est_gpucorrmm_conv
(
self
,
i
,
f
,
s
,
b
,
flip
,
provide_shape
):
def
t
case
(
self
,
i
,
f
,
s
,
b
,
flip
,
provide_shape
):
mode
=
self
.
mode
mode
=
self
.
mode
o
=
self
.
get_output_shape
(
i
,
f
,
s
,
b
)
o
=
self
.
get_output_shape
(
i
,
f
,
s
,
b
)
self
.
run_fwd
(
inputs_shape
=
i
,
filters_shape
=
f
,
subsample
=
s
,
self
.
run_fwd
(
inputs_shape
=
i
,
filters_shape
=
f
,
subsample
=
s
,
...
...
theano/tensor/nnet/abstract_conv.py
浏览文件 @
93b4fb57
...
@@ -458,7 +458,6 @@ class BaseAbstractConv2d(Op):
...
@@ -458,7 +458,6 @@ class BaseAbstractConv2d(Op):
'invalid mode {}, which must be either '
'invalid mode {}, which must be either '
'"valid" or "full"'
.
format
(
mode
))
'"valid" or "full"'
.
format
(
mode
))
out_shape
=
get_conv_output_shape
(
img
.
shape
,
kern
.
shape
,
mode
,
[
1
,
1
])
out_shape
=
get_conv_output_shape
(
img
.
shape
,
kern
.
shape
,
mode
,
[
1
,
1
])
out
=
numpy
.
zeros
(
out_shape
,
dtype
=
img
.
dtype
)
out
=
numpy
.
zeros
(
out_shape
,
dtype
=
img
.
dtype
)
val
=
_valfrommode
(
mode
)
val
=
_valfrommode
(
mode
)
...
@@ -522,16 +521,15 @@ class AbstractConv2d(BaseAbstractConv2d):
...
@@ -522,16 +521,15 @@ class AbstractConv2d(BaseAbstractConv2d):
new_img
=
numpy
.
zeros
((
img
.
shape
[
0
],
img
.
shape
[
1
],
new_img
=
numpy
.
zeros
((
img
.
shape
[
0
],
img
.
shape
[
1
],
img
.
shape
[
2
]
+
2
*
pad_h
,
img
.
shape
[
2
]
+
2
*
pad_h
,
img
.
shape
[
3
]
+
2
*
pad_w
),
dtype
=
img
.
dtype
)
img
.
shape
[
3
]
+
2
*
pad_w
),
dtype
=
img
.
dtype
)
new_img
[:,
:,
pad_h
:
img
.
shape
[
2
]
+
pad_h
,
pad_w
:
img
.
shape
[
3
]
+
pad_w
]
=
img
new_img
[:,
:,
pad_h
:
img
.
shape
[
2
]
+
pad_h
,
pad_w
:
img
.
shape
[
3
]
+
pad_w
]
=
img
img
=
new_img
img
=
new_img
if
not
self
.
filter_flip
:
if
not
self
.
filter_flip
:
kern
=
kern
[:,
:,
::
-
1
,
::
-
1
]
kern
=
kern
[:,
:,
::
-
1
,
::
-
1
]
conv_out
=
self
.
corr2d
(
img
,
kern
,
mode
)
conv_out
=
self
.
corr2d
(
img
,
kern
,
mode
)
conv_out
=
conv_out
[:,
:,
::
self
.
subsample
[
0
],
::
self
.
subsample
[
1
]]
conv_out
=
conv_out
[:,
:,
::
self
.
subsample
[
0
],
::
self
.
subsample
[
1
]]
o
[
0
]
=
node
.
outputs
[
0
]
.
type
.
filter
(
conv_out
)
o
[
0
]
=
node
.
outputs
[
0
]
.
type
.
filter
(
conv_out
)
def
R_op
(
self
,
inputs
,
eval_points
):
def
R_op
(
self
,
inputs
,
eval_points
):
rval
=
None
rval
=
None
if
eval_points
[
0
]
is
not
None
:
if
eval_points
[
0
]
is
not
None
:
...
@@ -641,12 +639,11 @@ class AbstractConv2d_gradWeights(BaseAbstractConv2d):
...
@@ -641,12 +639,11 @@ class AbstractConv2d_gradWeights(BaseAbstractConv2d):
pad_h
,
pad_w
=
map
(
int
,
mode
)
pad_h
,
pad_w
=
map
(
int
,
mode
)
mode
=
"valid"
mode
=
"valid"
new_img
=
numpy
.
zeros
((
img
.
shape
[
0
],
img
.
shape
[
1
],
new_img
=
numpy
.
zeros
((
img
.
shape
[
0
],
img
.
shape
[
1
],
img
.
shape
[
2
]
+
2
*
pad_h
,
img
.
shape
[
2
]
+
2
*
pad_h
,
img
.
shape
[
3
]
+
2
*
pad_w
),
dtype
=
img
.
dtype
)
img
.
shape
[
3
]
+
2
*
pad_w
),
dtype
=
img
.
dtype
)
new_img
[:,
:,
pad_h
:
img
.
shape
[
2
]
+
pad_h
,
pad_w
:
img
.
shape
[
3
]
+
pad_w
]
=
img
new_img
[:,
:,
pad_h
:
img
.
shape
[
2
]
+
pad_h
,
pad_w
:
img
.
shape
[
3
]
+
pad_w
]
=
img
img
=
new_img
img
=
new_img
if
self
.
subsample
[
0
]
>
1
or
self
.
subsample
[
1
]
>
1
:
if
self
.
subsample
[
0
]
>
1
or
self
.
subsample
[
1
]
>
1
:
new_shape
=
(
topgrad
.
shape
[
0
],
topgrad
.
shape
[
1
],
new_shape
=
(
topgrad
.
shape
[
0
],
topgrad
.
shape
[
1
],
img
.
shape
[
2
]
-
shape
[
0
]
+
1
,
img
.
shape
[
2
]
-
shape
[
0
]
+
1
,
...
@@ -664,8 +661,6 @@ class AbstractConv2d_gradWeights(BaseAbstractConv2d):
...
@@ -664,8 +661,6 @@ class AbstractConv2d_gradWeights(BaseAbstractConv2d):
kern
=
kern
.
transpose
(
1
,
0
,
2
,
3
)
kern
=
kern
.
transpose
(
1
,
0
,
2
,
3
)
o
[
0
]
=
node
.
outputs
[
0
]
.
type
.
filter
(
kern
)
o
[
0
]
=
node
.
outputs
[
0
]
.
type
.
filter
(
kern
)
def
grad
(
self
,
inp
,
grads
):
def
grad
(
self
,
inp
,
grads
):
bottom
,
top
=
inp
[:
2
]
bottom
,
top
=
inp
[:
2
]
weights
,
=
grads
weights
,
=
grads
...
@@ -782,7 +777,7 @@ class AbstractConv2d_gradInputs(BaseAbstractConv2d):
...
@@ -782,7 +777,7 @@ class AbstractConv2d_gradInputs(BaseAbstractConv2d):
if
self
.
filter_flip
:
if
self
.
filter_flip
:
img
=
img
[:,
:,
::
-
1
,
::
-
1
]
img
=
img
[:,
:,
::
-
1
,
::
-
1
]
if
pad_h
>
0
or
pad_w
>
0
:
if
pad_h
>
0
or
pad_w
>
0
:
img
=
img
[:,
:,
pad_h
:
img
.
shape
[
2
]
-
pad_h
,
pad_w
:
img
.
shape
[
3
]
-
pad_w
]
img
=
img
[:,
:,
pad_h
:
img
.
shape
[
2
]
-
pad_h
,
pad_w
:
img
.
shape
[
3
]
-
pad_w
]
o
[
0
]
=
node
.
outputs
[
0
]
.
type
.
filter
(
img
)
o
[
0
]
=
node
.
outputs
[
0
]
.
type
.
filter
(
img
)
def
grad
(
self
,
inp
,
grads
):
def
grad
(
self
,
inp
,
grads
):
...
...
theano/tensor/nnet/tests/test_abstract_conv.py
浏览文件 @
93b4fb57
...
@@ -363,32 +363,31 @@ class TestCpuConv2d(BaseTestConv2d):
...
@@ -363,32 +363,31 @@ class TestCpuConv2d(BaseTestConv2d):
border_mode
=
b
,
border_mode
=
b
,
filter_flip
=
flip
)
filter_flip
=
flip
)
class
TestDebugMode
(
BaseTestConv2d
):
class
TestDebugModeConv2d
(
BaseTestConv2d
):
def
setUp
(
self
):
def
setUp
(
self
):
super
(
TestD
nn
Conv2d
,
self
)
.
setUp
()
super
(
TestD
ebugMode
Conv2d
,
self
)
.
setUp
()
self
.
provide_shape
=
[
False
]
self
.
provide_shape
=
[
False
]
self
.
shared
=
gpu_shared
def
tcase
(
self
,
i
,
f
,
s
,
b
,
flip
,
provide_shape
):
def
tcase
(
self
,
i
,
f
,
s
,
b
,
flip
,
provide_shape
):
mode
=
"DebugMode"
mode
=
"DebugMode"
o
=
self
.
get_output_shape
(
i
,
f
,
s
,
b
)
o
=
self
.
get_output_shape
(
i
,
f
,
s
,
b
)
self
.
run_fwd
(
inputs_shape
=
i
,
filters_shape
=
f
,
subsample
=
s
,
self
.
run_fwd
(
inputs_shape
=
i
,
filters_shape
=
f
,
subsample
=
s
,
verify_grad
=
True
,
mode
=
mode
,
mode_ref
=
mode_without_gpu
,
verify_grad
=
True
,
mode
=
mode
,
device
=
'cpu'
,
provide_shape
=
provide_shape
,
border_mode
=
b
,
provide_shape
=
provide_shape
,
border_mode
=
b
,
filter_flip
=
flip
,
target_op
=
None
)
filter_flip
=
flip
,
target_op
=
None
)
self
.
run_gradweight
(
inputs_shape
=
i
,
filters_shape
=
f
,
self
.
run_gradweight
(
inputs_shape
=
i
,
filters_shape
=
f
,
output_shape
=
o
,
subsample
=
s
,
output_shape
=
o
,
subsample
=
s
,
verify_grad
=
True
,
mode
=
mode
,
mode_ref
=
mode_without_gpu
,
verify_grad
=
True
,
mode
=
mode
,
device
=
'cpu'
,
provide_shape
=
provide_shape
,
border_mode
=
b
,
provide_shape
=
provide_shape
,
border_mode
=
b
,
filter_flip
=
flip
,
target_op
=
None
)
filter_flip
=
flip
,
target_op
=
None
)
self
.
run_gradinput
(
inputs_shape
=
i
,
filters_shape
=
f
,
self
.
run_gradinput
(
inputs_shape
=
i
,
filters_shape
=
f
,
output_shape
=
o
,
subsample
=
s
,
output_shape
=
o
,
subsample
=
s
,
verify_grad
=
True
,
mode
=
mode
,
mode_ref
=
mode_without_gpu
,
verify_grad
=
True
,
mode
=
mode
,
device
=
'cpu'
,
provide_shape
=
provide_shape
,
border_mode
=
b
,
provide_shape
=
provide_shape
,
border_mode
=
b
,
filter_flip
=
flip
,
target_op
=
None
)
filter_flip
=
flip
,
target_op
=
None
)
class
TestConvTypes
(
unittest
.
TestCase
):
class
TestConvTypes
(
unittest
.
TestCase
):
def
setUp
(
self
):
def
setUp
(
self
):
self
.
input
=
tensor
.
ftensor4
()
self
.
input
=
tensor
.
ftensor4
()
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论