Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
P
pytensor
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
testgroup
pytensor
Commits
b79e5f2a
提交
b79e5f2a
authored
4月 11, 2017
作者:
amrithasuresh
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
1. Delete import numpy
2. Updated numpy as np
上级
0784ab7b
隐藏空白字符变更
内嵌
并排
正在显示
1 个修改的文件
包含
16 行增加
和
17 行删除
+16
-17
abstract_conv.py
theano/tensor/nnet/abstract_conv.py
+16
-17
没有找到文件。
theano/tensor/nnet/abstract_conv.py
浏览文件 @
b79e5f2a
...
@@ -17,7 +17,6 @@ from theano.gof import Apply, Op
...
@@ -17,7 +17,6 @@ from theano.gof import Apply, Op
from
six.moves
import
xrange
from
six.moves
import
xrange
import
warnings
import
warnings
import
numpy
import
numpy
as
np
import
numpy
as
np
try
:
try
:
...
@@ -69,7 +68,7 @@ def get_conv_output_shape(image_shape, kernel_shape,
...
@@ -69,7 +68,7 @@ def get_conv_output_shape(image_shape, kernel_shape,
nkern
,
kshp
=
kernel_shape
[
0
],
kernel_shape
[
2
:]
nkern
,
kshp
=
kernel_shape
[
0
],
kernel_shape
[
2
:]
if
filter_dilation
is
None
:
if
filter_dilation
is
None
:
filter_dilation
=
n
umpy
.
ones
(
len
(
subsample
),
dtype
=
'int'
)
filter_dilation
=
n
p
.
ones
(
len
(
subsample
),
dtype
=
'int'
)
if
isinstance
(
border_mode
,
tuple
):
if
isinstance
(
border_mode
,
tuple
):
out_shp
=
tuple
(
get_conv_shape_1axis
(
out_shp
=
tuple
(
get_conv_shape_1axis
(
...
@@ -181,7 +180,7 @@ def get_conv_gradweights_shape(image_shape, top_shape,
...
@@ -181,7 +180,7 @@ def get_conv_gradweights_shape(image_shape, top_shape,
nchan
,
topshp
=
top_shape
[
1
],
top_shape
[
2
:]
nchan
,
topshp
=
top_shape
[
1
],
top_shape
[
2
:]
if
filter_dilation
is
None
:
if
filter_dilation
is
None
:
filter_dilation
=
n
umpy
.
ones
(
len
(
subsample
),
dtype
=
'int'
)
filter_dilation
=
n
p
.
ones
(
len
(
subsample
),
dtype
=
'int'
)
if
isinstance
(
border_mode
,
tuple
):
if
isinstance
(
border_mode
,
tuple
):
out_shp
=
tuple
(
get_conv_gradweights_shape_1axis
(
out_shp
=
tuple
(
get_conv_gradweights_shape_1axis
(
...
@@ -286,7 +285,7 @@ def get_conv_gradinputs_shape(kernel_shape, top_shape,
...
@@ -286,7 +285,7 @@ def get_conv_gradinputs_shape(kernel_shape, top_shape,
nkern
,
kshp
=
kernel_shape
[
1
],
kernel_shape
[
2
:]
nkern
,
kshp
=
kernel_shape
[
1
],
kernel_shape
[
2
:]
if
filter_dilation
is
None
:
if
filter_dilation
is
None
:
filter_dilation
=
n
umpy
.
ones
(
len
(
subsample
),
dtype
=
'int'
)
filter_dilation
=
n
p
.
ones
(
len
(
subsample
),
dtype
=
'int'
)
if
isinstance
(
border_mode
,
tuple
):
if
isinstance
(
border_mode
,
tuple
):
out_shp
=
tuple
(
get_conv_gradinputs_shape_1axis
(
out_shp
=
tuple
(
get_conv_gradinputs_shape_1axis
(
...
@@ -1508,11 +1507,11 @@ class BaseAbstractConv(Op):
...
@@ -1508,11 +1507,11 @@ class BaseAbstractConv(Op):
out_shape
=
get_conv_output_shape
(
img
.
shape
,
kern
.
shape
,
out_shape
=
get_conv_output_shape
(
img
.
shape
,
kern
.
shape
,
mode
,
[
1
]
*
self
.
convdim
,
dilation
)
mode
,
[
1
]
*
self
.
convdim
,
dilation
)
out
=
n
umpy
.
zeros
(
out_shape
,
dtype
=
img
.
dtype
)
out
=
n
p
.
zeros
(
out_shape
,
dtype
=
img
.
dtype
)
dil_kern_shp
=
kern
.
shape
[:
-
self
.
convdim
]
+
tuple
(
dil_kern_shp
=
kern
.
shape
[:
-
self
.
convdim
]
+
tuple
(
(
kern
.
shape
[
-
self
.
convdim
+
i
]
-
1
)
*
dilation
[
i
]
+
1
(
kern
.
shape
[
-
self
.
convdim
+
i
]
-
1
)
*
dilation
[
i
]
+
1
for
i
in
range
(
self
.
convdim
))
for
i
in
range
(
self
.
convdim
))
dilated_kern
=
n
umpy
.
zeros
(
dil_kern_shp
,
dtype
=
kern
.
dtype
)
dilated_kern
=
n
p
.
zeros
(
dil_kern_shp
,
dtype
=
kern
.
dtype
)
dilated_kern
[(
slice
(
None
),
slice
(
None
))
+
dilated_kern
[(
slice
(
None
),
slice
(
None
))
+
tuple
(
slice
(
None
,
None
,
dilation
[
i
])
for
i
in
range
(
self
.
convdim
))
tuple
(
slice
(
None
,
None
,
dilation
[
i
])
for
i
in
range
(
self
.
convdim
))
]
=
kern
]
=
kern
...
@@ -1522,7 +1521,7 @@ class BaseAbstractConv(Op):
...
@@ -1522,7 +1521,7 @@ class BaseAbstractConv(Op):
bval
=
_bvalfromboundary
(
'fill'
)
bval
=
_bvalfromboundary
(
'fill'
)
with
warnings
.
catch_warnings
():
with
warnings
.
catch_warnings
():
warnings
.
simplefilter
(
'ignore'
,
n
umpy
.
ComplexWarning
)
warnings
.
simplefilter
(
'ignore'
,
n
p
.
ComplexWarning
)
for
b
in
xrange
(
img
.
shape
[
0
]):
for
b
in
xrange
(
img
.
shape
[
0
]):
for
n
in
xrange
(
kern
.
shape
[
0
]):
for
n
in
xrange
(
kern
.
shape
[
0
]):
for
im0
in
xrange
(
img
.
shape
[
1
]):
for
im0
in
xrange
(
img
.
shape
[
1
]):
...
@@ -1592,8 +1591,8 @@ class AbstractConv(BaseAbstractConv):
...
@@ -1592,8 +1591,8 @@ class AbstractConv(BaseAbstractConv):
def
perform
(
self
,
node
,
inp
,
out_
):
def
perform
(
self
,
node
,
inp
,
out_
):
img
,
kern
=
inp
img
,
kern
=
inp
img
=
n
umpy
.
asarray
(
img
)
img
=
n
p
.
asarray
(
img
)
kern
=
n
umpy
.
asarray
(
kern
)
kern
=
n
p
.
asarray
(
kern
)
dil_kernshp
=
tuple
((
kern
.
shape
[
2
+
i
]
-
1
)
*
self
.
filter_dilation
[
i
]
+
1
dil_kernshp
=
tuple
((
kern
.
shape
[
2
+
i
]
-
1
)
*
self
.
filter_dilation
[
i
]
+
1
for
i
in
range
(
self
.
convdim
))
for
i
in
range
(
self
.
convdim
))
o
,
=
out_
o
,
=
out_
...
@@ -1613,7 +1612,7 @@ class AbstractConv(BaseAbstractConv):
...
@@ -1613,7 +1612,7 @@ class AbstractConv(BaseAbstractConv):
if
isinstance
(
mode
,
tuple
):
if
isinstance
(
mode
,
tuple
):
pad
=
tuple
(
int
(
mode
[
i
])
for
i
in
range
(
self
.
convdim
))
pad
=
tuple
(
int
(
mode
[
i
])
for
i
in
range
(
self
.
convdim
))
mode
=
"valid"
mode
=
"valid"
new_img
=
n
umpy
.
zeros
((
img
.
shape
[
0
],
img
.
shape
[
1
])
+
new_img
=
n
p
.
zeros
((
img
.
shape
[
0
],
img
.
shape
[
1
])
+
tuple
(
img
.
shape
[
i
+
2
]
+
2
*
pad
[
i
]
tuple
(
img
.
shape
[
i
+
2
]
+
2
*
pad
[
i
]
for
i
in
range
(
self
.
convdim
)),
for
i
in
range
(
self
.
convdim
)),
dtype
=
img
.
dtype
)
dtype
=
img
.
dtype
)
...
@@ -1809,8 +1808,8 @@ class AbstractConv_gradWeights(BaseAbstractConv):
...
@@ -1809,8 +1808,8 @@ class AbstractConv_gradWeights(BaseAbstractConv):
def
perform
(
self
,
node
,
inp
,
out_
):
def
perform
(
self
,
node
,
inp
,
out_
):
img
,
topgrad
,
shape
=
inp
img
,
topgrad
,
shape
=
inp
img
=
n
umpy
.
asarray
(
img
)
img
=
n
p
.
asarray
(
img
)
topgrad
=
n
umpy
.
asarray
(
topgrad
)
topgrad
=
n
p
.
asarray
(
topgrad
)
o
,
=
out_
o
,
=
out_
...
@@ -1833,7 +1832,7 @@ class AbstractConv_gradWeights(BaseAbstractConv):
...
@@ -1833,7 +1832,7 @@ class AbstractConv_gradWeights(BaseAbstractConv):
pad
=
tuple
(
int
(
mode
[
i
])
for
i
in
range
(
self
.
convdim
))
pad
=
tuple
(
int
(
mode
[
i
])
for
i
in
range
(
self
.
convdim
))
mode
=
"valid"
mode
=
"valid"
new_img
=
n
umpy
.
zeros
((
img
.
shape
[
0
],
img
.
shape
[
1
])
+
new_img
=
n
p
.
zeros
((
img
.
shape
[
0
],
img
.
shape
[
1
])
+
tuple
(
img
.
shape
[
i
+
2
]
+
2
*
pad
[
i
]
tuple
(
img
.
shape
[
i
+
2
]
+
2
*
pad
[
i
]
for
i
in
range
(
self
.
convdim
)),
for
i
in
range
(
self
.
convdim
)),
dtype
=
img
.
dtype
)
dtype
=
img
.
dtype
)
...
@@ -1846,7 +1845,7 @@ class AbstractConv_gradWeights(BaseAbstractConv):
...
@@ -1846,7 +1845,7 @@ class AbstractConv_gradWeights(BaseAbstractConv):
new_shape
=
((
topgrad
.
shape
[
0
],
topgrad
.
shape
[
1
])
+
new_shape
=
((
topgrad
.
shape
[
0
],
topgrad
.
shape
[
1
])
+
tuple
(
img
.
shape
[
i
+
2
]
-
dil_shape
[
i
]
+
1
tuple
(
img
.
shape
[
i
+
2
]
-
dil_shape
[
i
]
+
1
for
i
in
range
(
self
.
convdim
)))
for
i
in
range
(
self
.
convdim
)))
new_topgrad
=
n
umpy
.
zeros
((
new_shape
),
dtype
=
topgrad
.
dtype
)
new_topgrad
=
n
p
.
zeros
((
new_shape
),
dtype
=
topgrad
.
dtype
)
new_topgrad
[(
slice
(
None
),
slice
(
None
))
+
new_topgrad
[(
slice
(
None
),
slice
(
None
))
+
tuple
(
slice
(
None
,
None
,
self
.
subsample
[
i
])
tuple
(
slice
(
None
,
None
,
self
.
subsample
[
i
])
for
i
in
range
(
self
.
convdim
))]
=
topgrad
for
i
in
range
(
self
.
convdim
))]
=
topgrad
...
@@ -2049,8 +2048,8 @@ class AbstractConv_gradInputs(BaseAbstractConv):
...
@@ -2049,8 +2048,8 @@ class AbstractConv_gradInputs(BaseAbstractConv):
def
perform
(
self
,
node
,
inp
,
out_
):
def
perform
(
self
,
node
,
inp
,
out_
):
kern
,
topgrad
,
shape
=
inp
kern
,
topgrad
,
shape
=
inp
kern
=
n
umpy
.
asarray
(
kern
)
kern
=
n
p
.
asarray
(
kern
)
topgrad
=
n
umpy
.
asarray
(
topgrad
)
topgrad
=
n
p
.
asarray
(
topgrad
)
o
,
=
out_
o
,
=
out_
mode
=
self
.
border_mode
mode
=
self
.
border_mode
...
@@ -2089,7 +2088,7 @@ class AbstractConv_gradInputs(BaseAbstractConv):
...
@@ -2089,7 +2088,7 @@ class AbstractConv_gradInputs(BaseAbstractConv):
new_shape
=
((
topgrad
.
shape
[
0
],
topgrad
.
shape
[
1
])
+
new_shape
=
((
topgrad
.
shape
[
0
],
topgrad
.
shape
[
1
])
+
tuple
(
shape
[
i
]
+
2
*
pad
[
i
]
-
dil_kernshp
[
i
]
+
1
tuple
(
shape
[
i
]
+
2
*
pad
[
i
]
-
dil_kernshp
[
i
]
+
1
for
i
in
range
(
self
.
convdim
)))
for
i
in
range
(
self
.
convdim
)))
new_topgrad
=
n
umpy
.
zeros
((
new_shape
),
dtype
=
topgrad
.
dtype
)
new_topgrad
=
n
p
.
zeros
((
new_shape
),
dtype
=
topgrad
.
dtype
)
new_topgrad
[(
slice
(
None
),
slice
(
None
))
+
new_topgrad
[(
slice
(
None
),
slice
(
None
))
+
tuple
(
slice
(
None
,
None
,
self
.
subsample
[
i
])
tuple
(
slice
(
None
,
None
,
self
.
subsample
[
i
])
for
i
in
range
(
self
.
convdim
))]
=
topgrad
for
i
in
range
(
self
.
convdim
))]
=
topgrad
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论