MCPcopy Create free account
hub / github.com/PaddlePaddle/Paddle / conv2d

Function conv2d

python/paddle/nn/functional/conv.py:716–954  ·  view source on GitHub ↗

r""" The convolution2D layer calculates the output based on the input, filter and strides, paddings, dilations, groups parameters. Input and Output are in NCHW or NHWC format, where N is batch size, C is the number of channels, H is the height of the feature, and W is the width of t

(
    x: Tensor,
    weight: Tensor,
    bias: Tensor | None = None,
    stride: Size2 = 1,
    padding: _PaddingSizeMode | Size2 | Size4 | Sequence[Size2] = 0,
    dilation: Size2 = 1,
    groups: int = 1,
    data_format: DataLayout2D = "NCHW",
    name: str | None = None,
)

Source from the content-addressed store, hash-verified

714
715@param_one_alias(["x", "input"])
716def conv2d(
717 x: Tensor,
718 weight: Tensor,
719 bias: Tensor | None = None,
720 stride: Size2 = 1,
721 padding: _PaddingSizeMode | Size2 | Size4 | Sequence[Size2] = 0,
722 dilation: Size2 = 1,
723 groups: int = 1,
724 data_format: DataLayout2D = "NCHW",
725 name: str | None = None,
726) -> Tensor:
727 r"""
728
729 The convolution2D layer calculates the output based on the input, filter
730 and strides, paddings, dilations, groups parameters. Input and
731 Output are in NCHW or NHWC format, where N is batch size, C is the number of
732 channels, H is the height of the feature, and W is the width of the feature.
733 Filter is in MCHW format, where M is the number of output image channels,
734 C is the number of input image channels, H is the height of the filter,
735 and W is the width of the filter. If the groups is greater than 1,
736 C will equal the number of input image channels divided by the groups.
737 Please refer to UFLDL's `convolution
738 <http://ufldl.stanford.edu/tutorial/supervised/FeatureExtractionUsingConvolution/>`_
739 for more details.
740 If bias attribution and activation type are provided, bias is added to the
741 output of the convolution, and the corresponding activation function is
742 applied to the final result.
743
744 For each input :math:`X`, the equation is:
745
746 .. math::
747
748 Out = \sigma (W \ast X + b)
749
750 Where:
751
752 * :math:`X`: Input value, a tensor with NCHW or NHWC format.
753 * :math:`W`: Filter value, a tensor with MCHW format.
754 * :math:`\\ast`: Convolution operation.
755 * :math:`b`: Bias value, a 2-D tensor with shape [M, 1].
756 * :math:`\\sigma`: Activation function.
757 * :math:`Out`: Output value, the shape of :math:`Out` and :math:`X` may be different.
758
759 Example:
760
761 - Input:
762
763 Input shape: :math:`(N, C_{in}, H_{in}, W_{in})`
764
765 Filter shape: :math:`(C_{out}, C_{in}, H_f, W_f)`
766
767 - Output:
768
769 Output shape: :math:`(N, C_{out}, H_{out}, W_{out})`
770
771 Where
772
773 .. math::

Callers

nothing calls this directly

Calls 15

get_flagsFunction · 0.90
_global_flagsFunction · 0.90
ValueErrorClass · 0.85
is_compiled_with_cudaFunction · 0.85
convert_to_listFunction · 0.85
is_compiled_with_rocmFunction · 0.85
rangeFunction · 0.85
no_gradFunction · 0.85
_conv_ndFunction · 0.85
get_flagsMethod · 0.80
conv2dMethod · 0.80

Tested by

no test coverage detected