提交 689a4bf4 authored 作者: Arnaud Bergeron's avatar Arnaud Bergeron

Flake8 fixes for new file.

上级 1128c1b3
...@@ -2,7 +2,7 @@ import os ...@@ -2,7 +2,7 @@ import os
import numpy import numpy
import theano import theano
from theano import Apply, gof, tensor, config, Variable from theano import Apply, tensor, config, Variable
from theano.scalar import as_scalar, constant from theano.scalar import as_scalar, constant
from theano.gradient import DisconnectedType, grad_not_implemented from theano.gradient import DisconnectedType, grad_not_implemented
from theano.gof import Optimizer, local_optimizer, COp from theano.gof import Optimizer, local_optimizer, COp
...@@ -485,8 +485,8 @@ class GpuDnnConv(DnnBase, COp): ...@@ -485,8 +485,8 @@ class GpuDnnConv(DnnBase, COp):
return ( return (
b, nb, b, nb,
(h + 2*padh - kh)//sh + 1, (h + 2 * padh - kh) // sh + 1,
(w + 2*padw - kw)//sw + 1 (w + 2 * padw - kw) // sw + 1
) )
def infer_shape(self, node, shape): def infer_shape(self, node, shape):
...@@ -670,7 +670,7 @@ def dnn_conv(img, kerns, border_mode='valid', subsample=(1, 1), ...@@ -670,7 +670,7 @@ def dnn_conv(img, kerns, border_mode='valid', subsample=(1, 1),
""" """
fgraph = getattr(img, 'fgraph', None) or getattr(kerns, 'fgraph', None) fgraph = getattr(img, 'fgraph', None) or getattr(kerns, 'fgraph', None)
if (border_mode == 'valid' and subsample == (1, 1) and if (border_mode == 'valid' and subsample == (1, 1) and
direction_hint == 'bprop weights'): direction_hint == 'bprop weights'):
# Special case: We are asked to use GpuDnnConvGradW. We need to set # Special case: We are asked to use GpuDnnConvGradW. We need to set
# up a suitable 'fake' convolution to compute the gradient for. # up a suitable 'fake' convolution to compute the gradient for.
img = gpu_contiguous(img.dimshuffle(1, 0, 2, 3)) img = gpu_contiguous(img.dimshuffle(1, 0, 2, 3))
...@@ -682,7 +682,7 @@ def dnn_conv(img, kerns, border_mode='valid', subsample=(1, 1), ...@@ -682,7 +682,7 @@ def dnn_conv(img, kerns, border_mode='valid', subsample=(1, 1),
shape2 = shape_i(img, 2, fgraph) - shape_i(kerns, 2, fgraph) + 1 shape2 = shape_i(img, 2, fgraph) - shape_i(kerns, 2, fgraph) + 1
shape3 = shape_i(img, 3, fgraph) - shape_i(kerns, 3, fgraph) + 1 shape3 = shape_i(img, 3, fgraph) - shape_i(kerns, 3, fgraph) + 1
out = gpu_alloc_empty(shape_i(kerns, 1, fgraph), out = gpu_alloc_empty(shape_i(kerns, 1, fgraph),
shape_i(img, 1, fgraph), shape2, shape3) shape_i(img, 1, fgraph), shape2, shape3)
desc = GpuDnnConvDesc(border_mode='valid', subsample=(1, 1), desc = GpuDnnConvDesc(border_mode='valid', subsample=(1, 1),
conv_mode='cross')(img.shape, out.shape) conv_mode='cross')(img.shape, out.shape)
conv = GpuDnnConvGradW()(img, kerns, out, desc) conv = GpuDnnConvGradW()(img, kerns, out, desc)
...@@ -699,7 +699,7 @@ def dnn_conv(img, kerns, border_mode='valid', subsample=(1, 1), ...@@ -699,7 +699,7 @@ def dnn_conv(img, kerns, border_mode='valid', subsample=(1, 1),
shape2 = shape_i(img, 2, fgraph) + shape_i(kerns, 2, fgraph) - 1 shape2 = shape_i(img, 2, fgraph) + shape_i(kerns, 2, fgraph) - 1
shape3 = shape_i(img, 3, fgraph) + shape_i(kerns, 3, fgraph) - 1 shape3 = shape_i(img, 3, fgraph) + shape_i(kerns, 3, fgraph) - 1
out = gpu_alloc_empty(shape_i(img, 0, fgraph), out = gpu_alloc_empty(shape_i(img, 0, fgraph),
shape_i(kerns, 1, fgraph), shape2, shape3) shape_i(kerns, 1, fgraph), shape2, shape3)
desc = GpuDnnConvDesc(border_mode='valid', subsample=(1, 1), desc = GpuDnnConvDesc(border_mode='valid', subsample=(1, 1),
conv_mode=conv_mode)(out.shape, kerns.shape) conv_mode=conv_mode)(out.shape, kerns.shape)
return GpuDnnConvGradI()(kerns, img, out, desc) return GpuDnnConvGradI()(kerns, img, out, desc)
...@@ -858,8 +858,8 @@ class GpuDnnPool(DnnBase): ...@@ -858,8 +858,8 @@ class GpuDnnPool(DnnBase):
return [( return [(
shape[0][0], shape[0][0],
shape[0][1], shape[0][1],
(shape[0][2] + 2*padh - kh)//sh + 1, (shape[0][2] + 2 * padh - kh) // sh + 1,
(shape[0][3] + 2*padw - kw)//sw + 1 (shape[0][3] + 2 * padw - kw) // sw + 1
)] )]
def c_support_code_struct(self, node, name): def c_support_code_struct(self, node, name):
...@@ -976,8 +976,8 @@ if (err%(name)s != CUDNN_STATUS_SUCCESS) { ...@@ -976,8 +976,8 @@ if (err%(name)s != CUDNN_STATUS_SUCCESS) {
""" % dict(out=out, desc=desc, fail=sub['fail'], """ % dict(out=out, desc=desc, fail=sub['fail'],
name=name, set_in=set_in, name=name, set_in=set_in,
set_out=set_out, input=inputs[0], set_out=set_out, input=inputs[0],
input_desc="input"+name, input_desc="input" + name,
output_desc="output"+name) output_desc="output" + name)
def grad(self, inp, grads): def grad(self, inp, grads):
img, desc = inp img, desc = inp
...@@ -1184,10 +1184,10 @@ if (err%(name)s != CUDNN_STATUS_SUCCESS) { ...@@ -1184,10 +1184,10 @@ if (err%(name)s != CUDNN_STATUS_SUCCESS) {
fail=sub['fail'], fail=sub['fail'],
name=name, set_in=set_in, name=name, set_in=set_in,
set_out=set_out, input=inp, input_grad=inp_grad, output=out, set_out=set_out, input=inp, input_grad=inp_grad, output=out,
input_desc="input"+name, input_desc="input" + name,
input_grad_desc="input_grad"+name, input_grad_desc="input_grad" + name,
output_desc="output"+name, output_desc="output" + name,
output_grad_desc="output_grad"+name) output_grad_desc="output_grad" + name)
def c_code_cache_version(self): def c_code_cache_version(self):
return (5, version()) return (5, version())
...@@ -1725,9 +1725,9 @@ if True: ...@@ -1725,9 +1725,9 @@ if True:
def local_softmax_dnn_grad(node): def local_softmax_dnn_grad(node):
if (isinstance(node.op, SoftmaxGrad) and if (isinstance(node.op, SoftmaxGrad) and
((node.inputs[0].owner and ((node.inputs[0].owner and
isinstance(node.inputs[0].owner.op, HostFromGpu)) isinstance(node.inputs[0].owner.op, HostFromGpu)) or
or (node.inputs[1].owner and (node.inputs[1].owner and
isinstance(node.inputs[1].owner.op, HostFromGpu)))): isinstance(node.inputs[1].owner.op, HostFromGpu)))):
if not dnn_available(): if not dnn_available():
return return
ins = [] ins = []
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论