提交 62966940 authored 作者: Arnaud Bergeron's avatar Arnaud Bergeron

Fix the docstrings in abstract_conv.py

上级 abe2d24c
...@@ -132,68 +132,80 @@ def conv2d_grad_wrt_inputs(output_grad, ...@@ -132,68 +132,80 @@ def conv2d_grad_wrt_inputs(output_grad,
used by the convolution, such that the output_grad is upsampled used by the convolution, such that the output_grad is upsampled
to the input shape. to the input shape.
:type output_grad: symbolic 4D tensor. Parameters
:param output_grad: mini-batch of feature map stacks, of shape ----------
(batch size, input channels, input rows, input columns). output_grad : symbolic 4D tensor
This is the tensor that will be upsampled or the output mini-batch of feature map stacks, of shape (batch size, input
gradient of the convolution whose gradient will be taken channels, input rows, input columns). This is the tensor that
with respect to the input of the convolution. will be upsampled or the output gradient of the convolution
See the optional parameter ``output_grad_shape``. whose gradient will be taken with respect to the input of the
convolution. See the optional parameter
:type filters: symbolic 4D tensor. ``output_grad_shape``.
:param filters: set of filters used in CNN layer of shape filters : symbolic 4D tensor
(output channels, input channels, filter rows, filter columns). set of filters used in CNN layer of shape (output channels,
See the optional parameter ``filter_shape``. input channels, filter rows, filter columns). See the
optional parameter ``filter_shape``.
:type output_grad_shape: None, tuple/list of len 4 of int or output_grad_shape : list of 4 symbolic or real ints
Constant variable. The shape of the output_grad parameter. Optional, possibly
:param output_grad_shape: The shape of the output_grad parameter. used to choose an optimal implementation. You can give
Optional, possibly used to choose an optimal implementation. ``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.
input_shape : list of 2 symbolic or real ints
The shape (row and column size) of the input (upsampled)
parameter. Not Optional, since given the output_grad_shape
and the subsample values, multiple input_shape may be
plausible.
filter_shape : list of 4 symbolic or real ints
The shape of the filters parameter. Optional, possibly used
to choose an optimal implementation. You can give ``None``
for any element of the list to specify that this element is
not known at compile time.
border_mode : str, int or tuple of two int
Either of the following:
:type input_shape: tuple/list of len 2 of int or Constant variable. ``'valid'``
:param input_shape: The shape (row and column size) of the apply filter wherever it completely overlaps with the
input (upsampled) parameter. input. Generates output of shape: input shape - filter
Not Optional, since given the output_grad_shape and the subsample values, shape + 1
multiple input_shape may be plausible.
:type filter_shape: None, tuple/list of len 4 of int or Constant variable ``'full'``
:param filter_shape: The shape of the filters parameter. apply filter wherever it partly overlaps with the input.
Optional, possibly used to choose an optimal implementation. Generates output of shape: input shape + filter shape - 1
You can give ``None`` for any element of the list to specify that this
element is not known at compile time.
:type border_mode: str, int or tuple of two int ``'half'``
:param border_mode: Either of the following: pad input with a symmetric border of ``filter rows // 2``
* ``'valid'``: apply filter wherever it completely overlaps with the rows and ``filter columns // 2`` columns, then perform a
input. Generates output of shape: input shape - filter shape + 1 valid convolution. For filters with an odd number of rows
* ``'full'``: apply filter wherever it partly overlaps with the input. and columns, this leads to the output shape being equal to
Generates output of shape: input shape + filter shape - 1 the input shape.
* ``'half'``: pad input with a symmetric border of ``filter rows // 2``
rows and ``filter columns // 2`` columns, then perform a valid
convolution. For filters with an odd number of rows and columns, this
leads to the output shape being equal to the input shape.
* ``int``: pad input with a symmetric border of zeros of the given
width, then perform a valid convolution.
* ``(int1, int2)``: pad input with a symmetric border of ``int1`` rows
and ``int2`` columns, then perform a valid convolution.
:type subsample: tuple of len 2, the subsampling used in the forward pass
of the convolutional operation.
:param subsample: factor by which to subsample the output.
Also called strides elsewhere.
:type filter_flip: bool ``int``
:param filter_flip: If ``True``, will flip the filter rows and columns pad input with a symmetric border of zeros of the given
before sliding them over the input. This operation is normally referred width, then perform a valid convolution.
to as a convolution, and this is the default. If ``False``, the filters
are not flipped and the operation is referred to as a ``(int1, int2)``
cross-correlation. pad input with a symmetric border of ``int1`` rows and
``int2`` columns, then perform a valid convolution.
subsample : tuple of len 2
The subsampling used in the forward pass. Also called strides
elsewhere.
filter_flip : bool
If ``True``, will flip the filter rows and columns before
sliding them over the input. This operation is normally
referred to as a convolution, and this is the default. If
``False``, the filters are not flipped and the operation is
referred to as a cross-correlation.
Returns
-------
symbolic 4D tensor
set of feature maps generated by convolutional layer. Tensor
is of shape (batch size, output channels, output rows, output
columns)
:rtype: symbolic 4D tensor. Notes
:return: set of feature maps generated by convolutional layer. Tensor is -----
of shape (batch size, output channels, output rows, output columns)
:note: If CuDNN is available, it will be used on the :note: If CuDNN is available, it will be used on the
GPU. Otherwise, it is the *CorrMM* convolution that will be used GPU. Otherwise, it is the *CorrMM* convolution that will be used
...@@ -224,71 +236,81 @@ def conv2d_grad_wrt_weights(input, ...@@ -224,71 +236,81 @@ def conv2d_grad_wrt_weights(input,
"""This function will build the symbolic graph for getting the """This function will build the symbolic graph for getting the
gradient of the output of a convolution (output_grad) w.r.t its wights. gradient of the output of a convolution (output_grad) w.r.t its wights.
:type input: symbolic 4D tensor. Parameters
:param input: mini-batch of feature map stacks, of shape ----------
(batch size, input channels, input rows, input columns). input : symbolic 4D tensor
This is the input of the convolution in the forward pass. mini-batch of feature map stacks, of shape (batch size, input
channels, input rows, input columns). This is the input of
the convolution in the forward pass.
output_grad : symbolic 4D tensor
mini-batch of feature map stacks, of shape (batch size, input
channels, input rows, input columns). This is the gradient of
the output of convolution.
filters : symbolic 4D tensor.
set of filters used in CNN layer of shape (output channels,
input channels, filter rows, filter columns). See the
optional parameter ``filter_shape``.
output_grad_shape : list of 4 ints or Constant variables
The shape of the input parameter. Optional, possibly used to
choose an optimal implementation. You can give ``None`` for
any element of the list to specify that this element is not
known at compile time.
input_shape : list of 2 ints or Constant variables
The shape of the input parameter. This parameter indicates
the row and column size of the input in the forward pass.
Optional, possibly used to choose an optimal implementation.
You can give ``None`` for any element of the list to specify
that this element is not known at compile time.
filter_shape : list of 4 ints or Constant variables
The shape of the filters parameter. Not Optional, since given
the output_grad_shape and the input_shape, multiple
filter_shape may be plausible.
border_mode : str, int or tuple of two ints
Either of the following:
:type output_grad: symbolic 4D tensor. ``'valid'``
:param output_grad: mini-batch of feature map stacks, of shape apply filter wherever it completely overlaps with the
(batch size, input channels, input rows, input columns). input. Generates output of shape: input shape - filter
This is the gradient of the output of convolution. shape + 1
:type filters: symbolic 4D tensor. ``'full'``
:param filters: set of filters used in CNN layer of shape apply filter wherever it partly overlaps with the input.
(output channels, input channels, filter rows, filter columns). Generates output of shape: input shape + filter shape - 1
See the optional parameter ``filter_shape``.
:type output_grad_shape: None, tuple/list of len 4 of int ``'half'``
or Constant variable. pad input with a symmetric border of ``filter rows // 2``
:param output_grad_shape: The shape of the input parameter. rows and ``filter columns // 2`` columns, then perform a
Optional, possibly used to choose an optimal implementation. valid convolution. For filters with an odd number of rows
You can give ``None`` for any element of the list to specify that this and columns, this leads to the output shape being equal to
element is not known at compile time. the input shape.
:type input_shape: tuple/list of len 2 of int or Constant variable. ``int``
:param input_shape: The shape of the input parameter. pad input with a symmetric border of zeros of the given
This parameter indicates the row and column size of the input width, then perform a valid convolution.
in the forward pass.
Optional, possibly used to choose an optimal implementation.
You can give ``None`` for any element of the list to specify that this
element is not known at compile time.
:type filter_shape: None, tuple/list of len 4 of int or Constant variable. ``(int1, int2)``
:param filter_shape: The shape of the filters parameter. pad input with a symmetric border of ``int1`` rows and
Not Optional, since given the output_grad_shape and the input_shape, ``int2`` columns, then perform a valid convolution.
multiple filter_shape may be plausible.
:type border_mode: str, int or tuple of two int
:param border_mode: Either of the following:
* ``'valid'``: apply filter wherever it completely overlaps with the
input. Generates output of shape: input shape - filter shape + 1
* ``'full'``: apply filter wherever it partly overlaps with the input.
Generates output of shape: input shape + filter shape - 1
* ``'half'``: pad input with a symmetric border of ``filter rows // 2``
rows and ``filter columns // 2`` columns, then perform a valid
convolution. For filters with an odd number of rows and columns, this
leads to the output shape being equal to the input shape.
* ``int``: pad input with a symmetric border of zeros of the given
width, then perform a valid convolution.
* ``(int1, int2)``: pad input with a symmetric border of ``int1`` rows
and ``int2`` columns, then perform a valid convolution.
:type subsample: tuple of len 2, the subsampling used in the forward pass
of the convolutional operation.
:param subsample: factor by which to subsample the output.
Also called strides elsewhere.
:type filter_flip: bool subsample : tuple of len 2
:param filter_flip: If ``True``, will flip the filter rows and columns The subsampling used in the forward pass of the convolutional
before sliding them over the input. This operation is normally referred operation. Also called strides elsewhere.
to as a convolution, and this is the default. If ``False``, the filters filter_flip : bool
are not flipped and the operation is referred to as a If ``True``, will flip the filter rows and columns before
cross-correlation. sliding them over the input. This operation is normally
referred to as a convolution, and this is the default. If
``False``, the filters are not flipped and the operation is
referred to as a cross-correlation.
Returns
-------
symbolic 4D tensor
set of feature maps generated by convolutional layer. Tensor
is of shape (batch size, output channels, output rows, output
columns)
:rtype: symbolic 4D tensor. Notes
:return: set of feature maps generated by convolutional layer. Tensor is -----
of shape (batch size, output channels, output rows, output columns)
:note: If CuDNN is available, it will be used on the :note: If CuDNN is available, it will be used on the
GPU. Otherwise, it is the *CorrMM* convolution that will be used GPU. Otherwise, it is the *CorrMM* convolution that will be used
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论