Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
P
pytensor
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
testgroup
pytensor
Commits
72fc02e2
提交
72fc02e2
authored
7月 02, 2015
作者:
Iban Harlouchet
提交者:
Frederic
7月 23, 2015
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
flake8 for theano/tensor/nnet/ConvTransp3D.py
上级
692f9012
隐藏空白字符变更
内嵌
并排
正在显示
2 个修改的文件
包含
19 行增加
和
15 行删除
+19
-15
ConvTransp3D.py
theano/tensor/nnet/ConvTransp3D.py
+19
-14
test_flake8.py
theano/tests/test_flake8.py
+0
-1
没有找到文件。
theano/tensor/nnet/ConvTransp3D.py
浏览文件 @
72fc02e2
from
__future__
import
print_function
from
__future__
import
print_function
import
numpy
as
N
import
numpy
as
N
from
six.moves
import
xrange
from
six.moves
import
xrange
import
theano
from
theano.tensor
import
basic
as
T
from
theano.tensor
import
basic
as
T
from
theano.misc
import
strutil
from
theano.misc
import
strutil
import
theano
from
theano.gradient
import
grad_undefined
from
theano.gradient
import
grad_undefined
from
theano.gradient
import
DisconnectedType
from
theano.gradient
import
DisconnectedType
from
theano.tensor.nnet.Conv3D
import
conv3D
from
theano.tensor.nnet.ConvGrad3D
import
convGrad3D
class
ConvTransp3D
(
theano
.
Op
):
class
ConvTransp3D
(
theano
.
Op
):
...
@@ -31,12 +35,15 @@ class ConvTransp3D(theano.Op):
...
@@ -31,12 +35,15 @@ class ConvTransp3D(theano.Op):
else
:
else
:
RShape_
=
T
.
as_tensor_variable
([
-
1
,
-
1
,
-
1
])
RShape_
=
T
.
as_tensor_variable
([
-
1
,
-
1
,
-
1
])
return
theano
.
Apply
(
self
,
inputs
=
[
W_
,
b_
,
d_
,
H_
,
RShape_
],
outputs
=
[
T
.
TensorType
(
H_
.
dtype
,
(
False
,
False
,
False
,
False
,
False
))()
]
)
return
theano
.
Apply
(
self
,
inputs
=
[
W_
,
b_
,
d_
,
H_
,
RShape_
],
outputs
=
[
T
.
TensorType
(
H_
.
dtype
,
(
False
,
False
,
False
,
False
,
False
))()])
def
infer_shape
(
self
,
node
,
input_shapes
):
def
infer_shape
(
self
,
node
,
input_shapes
):
W
,
b
,
d
,
H
,
RShape
=
node
.
inputs
W
,
b
,
d
,
H
,
RShape
=
node
.
inputs
W_shape
,
b_shape
,
d_shape
,
H_shape
,
RShape_shape
=
input_shapes
W_shape
,
b_shape
,
d_shape
,
H_shape
,
RShape_shape
=
input_shapes
return
[(
H_shape
[
0
],
RShape
[
0
],
RShape
[
1
],
RShape
[
2
],
W_shape
[
4
])]
return
[(
H_shape
[
0
],
RShape
[
0
],
RShape
[
1
],
RShape
[
2
],
W_shape
[
4
])]
def
connection_pattern
(
self
,
node
):
def
connection_pattern
(
self
,
node
):
return
[[
True
],
[
True
],
[
True
],
[
True
],
[
False
]]
return
[[
True
],
[
True
],
[
True
],
[
True
],
[
False
]]
...
@@ -73,11 +80,13 @@ class ConvTransp3D(theano.Op):
...
@@ -73,11 +80,13 @@ class ConvTransp3D(theano.Op):
else
:
else
:
b_name
=
'anon_b'
b_name
=
'anon_b'
dCdW
.
name
=
'ConvTransp3D_dCdW.H='
+
H_name
+
',dCdR='
+
dCdR_name
+
',W='
+
W_name
dCdW
.
name
=
(
'ConvTransp3D_dCdW.H='
+
H_name
+
',dCdR='
+
dCdR_name
+
dCdb
.
name
=
'ConvTransp3D_dCdb.H='
+
H_name
+
',dCdR='
+
dCdR_name
+
',W='
+
W_name
+
',b='
+
b_name
',W='
+
W_name
)
dCdb
.
name
=
(
'ConvTransp3D_dCdb.H='
+
H_name
+
',dCdR='
+
dCdR_name
+
',W='
+
W_name
+
',b='
+
b_name
)
dCdH
.
name
=
'ConvTransp3D_dCdH.H='
+
H_name
+
',dCdR='
+
dCdR_name
dCdH
.
name
=
'ConvTransp3D_dCdH.H='
+
H_name
+
',dCdR='
+
dCdR_name
return
[
dCdW
,
dCdb
,
dCdd
,
dCdH
,
dCdRShape
]
return
[
dCdW
,
dCdb
,
dCdd
,
dCdH
,
dCdRShape
]
def
perform
(
self
,
node
,
inputs
,
output_storage
):
def
perform
(
self
,
node
,
inputs
,
output_storage
):
W
,
b
,
d
,
H
,
RShape
=
inputs
W
,
b
,
d
,
H
,
RShape
=
inputs
...
@@ -335,7 +344,7 @@ def computeR(W, b, d, H, Rshape=None):
...
@@ -335,7 +344,7 @@ def computeR(W, b, d, H, Rshape=None):
assert
len
(
b
.
shape
)
==
1
assert
len
(
b
.
shape
)
==
1
assert
len
(
d
)
==
3
assert
len
(
d
)
==
3
outputChannels
,
filterHeight
,
filterWidth
,
filterDur
,
\
outputChannels
,
filterHeight
,
filterWidth
,
filterDur
,
\
inputChannels
=
W
.
shape
inputChannels
=
W
.
shape
batchSize
,
outputHeight
,
outputWidth
,
outputDur
,
\
batchSize
,
outputHeight
,
outputWidth
,
outputDur
,
\
outputChannelsAgain
=
H
.
shape
outputChannelsAgain
=
H
.
shape
...
@@ -367,7 +376,7 @@ def computeR(W, b, d, H, Rshape=None):
...
@@ -367,7 +376,7 @@ def computeR(W, b, d, H, Rshape=None):
# print "video size: "+str((videoHeight, videoWidth, videoDur))
# print "video size: "+str((videoHeight, videoWidth, videoDur))
R
=
N
.
zeros
((
batchSize
,
videoHeight
,
R
=
N
.
zeros
((
batchSize
,
videoHeight
,
videoWidth
,
videoDur
,
inputChannels
),
dtype
=
H
.
dtype
)
videoWidth
,
videoDur
,
inputChannels
),
dtype
=
H
.
dtype
)
# R[i,j,r,c,t] = b_j + sum_{rc,rk | d \circ rc + rk = r} sum_{cc,ck | ...} sum_{tc,tk | ...} sum_k W[k, j, rk, ck, tk] * H[i,k,rc,cc,tc]
# R[i,j,r,c,t] = b_j + sum_{rc,rk | d \circ rc + rk = r} sum_{cc,ck | ...} sum_{tc,tk | ...} sum_k W[k, j, rk, ck, tk] * H[i,k,rc,cc,tc]
for
i
in
xrange
(
0
,
batchSize
):
for
i
in
xrange
(
0
,
batchSize
):
...
@@ -404,8 +413,8 @@ def computeR(W, b, d, H, Rshape=None):
...
@@ -404,8 +413,8 @@ def computeR(W, b, d, H, Rshape=None):
if
tk
<
0
:
if
tk
<
0
:
break
break
R
[
R
[
i
,
r
,
c
,
t
,
j
]
+=
N
.
dot
(
i
,
r
,
c
,
t
,
j
]
+=
N
.
dot
(
W
[:,
rk
,
ck
,
tk
,
j
],
H
[
i
,
rc
,
cc
,
tc
,
:]
)
W
[:,
rk
,
ck
,
tk
,
j
],
H
[
i
,
rc
,
cc
,
tc
,
:]
)
tc
+=
1
tc
+=
1
""
# close loop over tc
""
# close loop over tc
...
@@ -421,7 +430,3 @@ def computeR(W, b, d, H, Rshape=None):
...
@@ -421,7 +430,3 @@ def computeR(W, b, d, H, Rshape=None):
""
# close loop over i
""
# close loop over i
return
R
return
R
from
theano.tensor.nnet.Conv3D
import
conv3D
from
theano.tensor.nnet.ConvGrad3D
import
convGrad3D
theano/tests/test_flake8.py
浏览文件 @
72fc02e2
...
@@ -89,7 +89,6 @@ whitelist_flake8 = [
...
@@ -89,7 +89,6 @@ whitelist_flake8 = [
"tensor/signal/tests/test_conv.py"
,
"tensor/signal/tests/test_conv.py"
,
"tensor/signal/tests/test_downsample.py"
,
"tensor/signal/tests/test_downsample.py"
,
"tensor/nnet/__init__.py"
,
"tensor/nnet/__init__.py"
,
"tensor/nnet/ConvTransp3D.py"
,
"tensor/nnet/sigm.py"
,
"tensor/nnet/sigm.py"
,
"tensor/nnet/ConvGrad3D.py"
,
"tensor/nnet/ConvGrad3D.py"
,
"tensor/nnet/conv3d2d.py"
,
"tensor/nnet/conv3d2d.py"
,
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论