提交 11b3e525 authored 作者: Chiheb Trabelsi's avatar Chiheb Trabelsi

GpuConvGrad3D has been modified in order to respect the flake8 style.

GpuConvGrad3D.py has been fixed GpuConvGrad3D.py do not contain long lines.
上级 7c171df5
...@@ -39,7 +39,7 @@ class GpuConvGrad3D(GpuOp): ...@@ -39,7 +39,7 @@ class GpuConvGrad3D(GpuOp):
d_ = T.as_tensor_variable(d) d_ = T.as_tensor_variable(d)
WShape_ = T.as_tensor_variable(WShape) WShape_ = T.as_tensor_variable(WShape)
dCdH_ = as_cuda_ndarray_variable(dCdH) dCdH_ = as_cuda_ndarray_variable(dCdH)
broad = (False,)*5 broad = (False,) * 5
return theano.Apply(self, inputs=[V_, d_, WShape_, dCdH_], return theano.Apply(self, inputs=[V_, d_, WShape_, dCdH_],
outputs=[CudaNdarrayType(dtype=V_.dtype, outputs=[CudaNdarrayType(dtype=V_.dtype,
broadcastable=broad)()]) broadcastable=broad)()])
...@@ -51,15 +51,10 @@ class GpuConvGrad3D(GpuOp): ...@@ -51,15 +51,10 @@ class GpuConvGrad3D(GpuOp):
# partial C / partial W[j,z,k,l,m] = sum_i sum_p sum_q sum_r (partial C /partial H[i,j,p,q,r] ) * V[i,z,dr*p+k,dc*q+l,dt*r+m] # partial C / partial W[j,z,k,l,m] = sum_i sum_p sum_q sum_r (partial C /partial H[i,j,p,q,r] ) * V[i,z,dr*p+k,dc*q+l,dt*r+m]
batchSize = dCdH.shape[0] batchSize = dCdH.shape[0]
outputFilters = dCdH.shape[1]
outputHeight = dCdH.shape[2] outputHeight = dCdH.shape[2]
outputWidth = dCdH.shape[3] outputWidth = dCdH.shape[3]
outputDur = dCdH.shape[4] outputDur = dCdH.shape[4]
assert V.shape[0] == batchSize assert V.shape[0] == batchSize
inputFilters = V.shape[1]
inputHeight = V.shape[2]
inputWidth = V.shape[3]
inputDur = V.shape[4]
dr, dc, dt = d dr, dc, dt = d
dCdW = numpy.zeros(WShape, dtype=V.dtype) dCdW = numpy.zeros(WShape, dtype=V.dtype)
...@@ -76,7 +71,11 @@ class GpuConvGrad3D(GpuOp): ...@@ -76,7 +71,11 @@ class GpuConvGrad3D(GpuOp):
for p in xrange(0, outputHeight): for p in xrange(0, outputHeight):
for q in xrange(0, outputWidth): for q in xrange(0, outputWidth):
for r in xrange(0, outputDur): for r in xrange(0, outputDur):
dCdW[j, z, k, l, m] += dCdH[i, j, p, q, r] * V[i, z, dr*p+k, dc*q+l, dt*r+m] dCdW[j, z, k, l, m] += dCdH[
i, j, p, q, r] * \
V[i, z, dr * p + k,
dc * q + l,
dt * r + m]
output_storage[0][0] = dCdW output_storage[0][0] = dCdW
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论