提交 ec381983 authored 作者: Pascal Lamblin's avatar Pascal Lamblin

Use the new expression for output shape.

+pep8 fixes
上级 af2bdbc7
...@@ -790,6 +790,7 @@ Use the new convolution interface to have GPU convolution working: ...@@ -790,6 +790,7 @@ Use the new convolution interface to have GPU convolution working:
theano.tensor.nnet.conv2d() theano.tensor.nnet.conv2d()
""" """
# This deals with any abstract convs that have a transfer somewhere # This deals with any abstract convs that have a transfer somewhere
@register_opt('fast_compile') @register_opt('fast_compile')
@op_lifter([AbstractConv2d, @op_lifter([AbstractConv2d,
......
...@@ -16,6 +16,7 @@ from theano.tensor.nnet.blocksparse import ( ...@@ -16,6 +16,7 @@ from theano.tensor.nnet.blocksparse import (
from theano.tensor.nnet.abstract_conv import (AbstractConv2d, from theano.tensor.nnet.abstract_conv import (AbstractConv2d,
AbstractConv2d_gradWeights, AbstractConv2d_gradWeights,
AbstractConv2d_gradInputs) AbstractConv2d_gradInputs)
from theano.tensor.nnet.abstract_conv import get_conv_output_shape
from theano.tensor.opt import register_specialize_device from theano.tensor.opt import register_specialize_device
from theano.tensor import TensorType from theano.tensor import TensorType
...@@ -199,12 +200,10 @@ def local_conv2d_gradweight_cpu(node): ...@@ -199,12 +200,10 @@ def local_conv2d_gradweight_cpu(node):
# Determine gradient on kernels # Determine gradient on kernels
assert len(op_imshp) == 4 and len(op_kshp) == 4 assert len(op_imshp) == 4 and len(op_kshp) == 4
outshp = ConvOp.getOutputShape(op_imshp[2:], outshp = get_conv_output_shape(op_imshp, op_kshp,
op_kshp[2:], node.op.subsample, node.op.border_mode, node.op.subsample)[2:]
node.op.border_mode) fulloutshp = get_conv_output_shape(op_imshp, op_kshp,
fulloutshp = ConvOp.getOutputShape(op_imshp[2:], node.op.border_mode, (1, 1))[2:]
op_kshp[2:], (1, 1),
node.op.border_mode)
newimg = img.dimshuffle((1, 0, 2, 3)) newimg = img.dimshuffle((1, 0, 2, 3))
newtopgrad = topgrad.dimshuffle((1, 0, 2, 3)) newtopgrad = topgrad.dimshuffle((1, 0, 2, 3))
...@@ -307,12 +306,11 @@ def local_conv2d_gradinputs_cpu(node): ...@@ -307,12 +306,11 @@ def local_conv2d_gradinputs_cpu(node):
filters = kern.dimshuffle((1, 0, 2, 3)) filters = kern.dimshuffle((1, 0, 2, 3))
filters = filters[:, :, ::-1, ::-1] filters = filters[:, :, ::-1, ::-1]
outshp = ConvOp.getOutputShape(op_imshp[2:], outshp = get_conv_output_shape(op_imshp, op_kshp,
op_kshp[2:], node.op.subsample, node.op.border_mode, node.op.subsample)[2:]
node.op.border_mode) fulloutshp = get_conv_output_shape(op_imshp, op_kshp,
fulloutshp = ConvOp.getOutputShape(op_imshp[2:], node.op.border_mode, (1, 1))[2:]
op_kshp[2:], (1, 1),
node.op.border_mode)
nkern = op_imshp[1] nkern = op_imshp[1]
imshp = (op_kshp[0], outshp[0], outshp[1]) imshp = (op_kshp[0], outshp[0], outshp[1])
imshp_logical = (op_kshp[0], fulloutshp[0], fulloutshp[1]) imshp_logical = (op_kshp[0], fulloutshp[0], fulloutshp[1])
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论