提交 5ae986b1 authored 作者: Vikram's avatar Vikram

Documentation suggestions implemented

上级 444f7d56
...@@ -3039,6 +3039,7 @@ def local_abstractconv_cudnn_graph(op, context_name, inputs, outputs): ...@@ -3039,6 +3039,7 @@ def local_abstractconv_cudnn_graph(op, context_name, inputs, outputs):
return None return None
if isinstance(op.border_mode, tuple) and any(isinstance(p, tuple) for p in op.border_mode): if isinstance(op.border_mode, tuple) and any(isinstance(p, tuple) for p in op.border_mode):
# Asymmetric padding not yet supported
return None return None
inp1 = inputs[0] inp1 = inputs[0]
...@@ -3138,6 +3139,7 @@ def local_abstractconv_cudnn(node): ...@@ -3138,6 +3139,7 @@ def local_abstractconv_cudnn(node):
if node.op.unshared: if node.op.unshared:
return None return None
if isinstance(node.op.border_mode, tuple) and any(isinstance(p, tuple) for p in node.op.border_mode): if isinstance(node.op.border_mode, tuple) and any(isinstance(p, tuple) for p in node.op.border_mode):
# Asymmetric padding not yet supported
return None return None
if isinstance(node.op, AbstractConv2d): if isinstance(node.op, AbstractConv2d):
return local_abstractconv_cudnn_graph(node.op, ctx, node.inputs, node.outputs) return local_abstractconv_cudnn_graph(node.op, ctx, node.inputs, node.outputs)
...@@ -3156,6 +3158,7 @@ def local_abstractconv_cudnn_alt(node): ...@@ -3156,6 +3158,7 @@ def local_abstractconv_cudnn_alt(node):
if node.op.unshared: if node.op.unshared:
return None return None
if isinstance(node.op.border_mode, tuple) and any(isinstance(p, tuple) for p in node.op.border_mode): if isinstance(node.op.border_mode, tuple) and any(isinstance(p, tuple) for p in node.op.border_mode):
# Asymmetric padding not yet supported
return None return None
inp1 = node.inputs[0] inp1 = node.inputs[0]
inp2 = node.inputs[1] inp2 = node.inputs[1]
...@@ -3366,6 +3369,7 @@ def local_abstractconv_gw_cudnn(node): ...@@ -3366,6 +3369,7 @@ def local_abstractconv_gw_cudnn(node):
if node.op.unshared: if node.op.unshared:
return None return None
if isinstance(node.op.border_mode, tuple) and any(isinstance(p, tuple) for p in node.op.border_mode): if isinstance(node.op.border_mode, tuple) and any(isinstance(p, tuple) for p in node.op.border_mode):
# Asymmetric padding not yet supported
return None return None
if isinstance(node.op, AbstractConv2d_gradWeights): if isinstance(node.op, AbstractConv2d_gradWeights):
return local_abstractconv_cudnn_graph(node.op, ctx, node.inputs, node.outputs) return local_abstractconv_cudnn_graph(node.op, ctx, node.inputs, node.outputs)
...@@ -3381,6 +3385,7 @@ def local_abstractconv_gi_cudnn(node): ...@@ -3381,6 +3385,7 @@ def local_abstractconv_gi_cudnn(node):
if node.op.unshared: if node.op.unshared:
return None return None
if isinstance(node.op.border_mode, tuple) and any(isinstance(p, tuple) for p in node.op.border_mode): if isinstance(node.op.border_mode, tuple) and any(isinstance(p, tuple) for p in node.op.border_mode):
# Asymmetric padding not yet supported
return None return None
if isinstance(node.op, AbstractConv2d_gradInputs): if isinstance(node.op, AbstractConv2d_gradInputs):
return local_abstractconv_cudnn_graph(node.op, ctx, node.inputs, node.outputs) return local_abstractconv_cudnn_graph(node.op, ctx, node.inputs, node.outputs)
......
...@@ -72,18 +72,17 @@ def conv2d(input, filters, input_shape=None, filter_shape=None, ...@@ -72,18 +72,17 @@ def conv2d(input, filters, input_shape=None, filter_shape=None,
You can give ``None`` for any element of the list to specify that this You can give ``None`` for any element of the list to specify that this
element is not known at compile time. element is not known at compile time.
border_mode: str, int or tuple of ``convdim`` elements where each element border_mode: str, int or a tuple of two ints or pairs of ints
is an integer or a tuple of length 2.
Either of the following: Either of the following:
``'valid'``: apply filter wherever it completely overlaps with the ``'valid'``: apply filter wherever it completely overlaps with the
input. Generates output of shape: input shape - filter shape + 1 input. Generates output of shape: input shape - filter shape + 1
``'full'``: apply filter wherever it partly overlaps with the input. ``'full'``: apply filter wherever it partly overlaps with the input.
Generates output of shape: input shape + filter shape - 1 Generates output of shape: input shape + filter shape - 1
``'half'``: pad input with a symmetric border of ``filter size // 2`` ``'half'``: pad input with a symmetric border of ``filter rows // 2``
in each convolution dimension, then perform a valid convolution. rows and ``filter columns // 2`` columns, then perform a valid
For filters with an odd filter size, this leads to the output convolution. For filters with an odd number of rows and columns, this
shape being equal to the input shape. leads to the output shape being equal to the input shape.
``int``: pad input with a symmetric border of zeros of the given ``int``: pad input with a symmetric border of zeros of the given
width, then perform a valid convolution. width, then perform a valid convolution.
``(int1, int2)``: (for 2D) pad input with a symmetric border of ``int1``, ``(int1, int2)``: (for 2D) pad input with a symmetric border of ``int1``,
...@@ -91,11 +90,6 @@ def conv2d(input, filters, input_shape=None, filter_shape=None, ...@@ -91,11 +90,6 @@ def conv2d(input, filters, input_shape=None, filter_shape=None,
``(int1, (int2, int3))`` or ``((int1, int2), int3)``: (for 2D) ``(int1, (int2, int3))`` or ``((int1, int2), int3)``: (for 2D)
pad input with one symmetric border of `int1`` or ``int3``, and pad input with one symmetric border of `int1`` or ``int3``, and
one asymmetric border of ``(int2, int3)`` or ``(int1, int2)``. one asymmetric border of ``(int2, int3)`` or ``(int1, int2)``.
``((int1, int2), (int3, int4))``: (for 2D) pad input with an asymmetric
border of ``(int1, int2)`` along one dimension and ``(int3, int4)``
along the second dimension.
``(int1, int2, int3)``: (for 3D) pad input with a symmetric border of
``int1``, ``int2`` and ``int3``, then perform a valid convolution.
subsample: tuple of len 2 subsample: tuple of len 2
Factor by which to subsample the output. Factor by which to subsample the output.
...@@ -208,7 +202,7 @@ def conv2d_transpose(input, filters, output_shape, filter_shape=None, ...@@ -208,7 +202,7 @@ def conv2d_transpose(input, filters, output_shape, filter_shape=None,
You can give ``None`` for any element of the list to specify that this You can give ``None`` for any element of the list to specify that this
element is not known at compile time. element is not known at compile time.
border_mode: str, int or tuple of two elements border_mode: str, int or tuple of two int
Refers to the ``border_mode`` argument of the corresponding forward Refers to the ``border_mode`` argument of the corresponding forward
(non-transposed) convolution. See the argument description in (non-transposed) convolution. See the argument description in
``conv2d``. What was ``padding`` for the forward convolution means ``conv2d``. What was ``padding`` for the forward convolution means
......
...@@ -89,7 +89,7 @@ class BaseCorrMM(gof.OpenMPOp): ...@@ -89,7 +89,7 @@ class BaseCorrMM(gof.OpenMPOp):
raise ValueError( raise ValueError(
'invalid border_mode {}, which must be either ' 'invalid border_mode {}, which must be either '
'"valid", "full", "half", an integer or a tuple ' '"valid", "full", "half", an integer or a tuple '
'of length 2'.format(border_mode)) 'of two integers or a pair of integers'.format(border_mode))
self.border_mode = border_mode self.border_mode = border_mode
if len(subsample) != 2: if len(subsample) != 2:
raise ValueError("subsample must have two elements") raise ValueError("subsample must have two elements")
......
...@@ -24,7 +24,7 @@ from theano.tensor.nnet.abstract_conv import bilinear_kernel_1D ...@@ -24,7 +24,7 @@ from theano.tensor.nnet.abstract_conv import bilinear_kernel_1D
from theano.tensor.nnet.abstract_conv import bilinear_kernel_2D from theano.tensor.nnet.abstract_conv import bilinear_kernel_2D
from theano.tensor.nnet.abstract_conv import bilinear_upsampling from theano.tensor.nnet.abstract_conv import bilinear_upsampling
from theano.tensor.nnet.abstract_conv import separable_conv2d, separable_conv3d from theano.tensor.nnet.abstract_conv import separable_conv2d, separable_conv3d
from theano.tensor.nnet.abstract_conv import causal_conv from theano.tensor.nnet.abstract_conv import causal_conv1d
from theano.tensor.nnet.corr import (CorrMM, CorrMM_gradWeights, from theano.tensor.nnet.corr import (CorrMM, CorrMM_gradWeights,
CorrMM_gradInputs) CorrMM_gradInputs)
from theano.tensor.nnet.corr3d import (Corr3dMM, Corr3dMM_gradWeights, from theano.tensor.nnet.corr3d import (Corr3dMM, Corr3dMM_gradWeights,
...@@ -2037,7 +2037,7 @@ class TestCausalConv(unittest.TestCase): ...@@ -2037,7 +2037,7 @@ class TestCausalConv(unittest.TestCase):
img_sym = theano.tensor.tensor3('img') img_sym = theano.tensor.tensor3('img')
kern_sym = theano.tensor.tensor3('kern') kern_sym = theano.tensor.tensor3('kern')
sym_out = causal_conv(img_sym, kern_sym, self.kern.shape, filter_dilation=self.dilation) sym_out = causal_conv1d(img_sym, kern_sym, self.kern.shape, filter_dilation=self.dilation)
causal_func = theano.function([img_sym, kern_sym], sym_out, mode=self.mode) causal_func = theano.function([img_sym, kern_sym], sym_out, mode=self.mode)
...@@ -2046,6 +2046,6 @@ class TestCausalConv(unittest.TestCase): ...@@ -2046,6 +2046,6 @@ class TestCausalConv(unittest.TestCase):
utt.assert_allclose(output, self.precomp_top) utt.assert_allclose(output, self.precomp_top)
def causal_conv_fn(inputs_val, filters_val): def causal_conv_fn(inputs_val, filters_val):
return causal_conv(inputs_val, filters_val, self.kern.shape, filter_dilation=1) return causal_conv1d(inputs_val, filters_val, self.kern.shape, filter_dilation=1)
utt.verify_grad(causal_conv_fn, [self.img, self.kern], mode=self.mode, eps=1) utt.verify_grad(causal_conv_fn, [self.img, self.kern], mode=self.mode, eps=1)
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论