represents a trainable convolutional net layer having n output channels and using kernels of size s to compute the convolution.


represents a layer performing one-dimensional convolutions with kernels of size s.


represents a layer performing two-dimensional convolution with kernels of size h×w.


represents a three-dimensional convolution with kernels of size h×w×d.


includes options for padding and other parameters.

Details and Options

  • ConvolutionLayer[n,] represents a layer that, applied to an input tensor with m input channels and one or more spatial dimensions, effectively performs n×m distinct convolutions across the spatial dimensions to produce an output tensor with n channels.
  • In ConvolutionLayer[n,s], the dimensionality of the convolution layer will be inferred when the layer is connected in a NetChain, NetGraph, etc.
  • The following optional parameters can be included:
  • "Biases"Automaticinitial vector of kernel biases
    "Dilation"1dilation factor
    "Dimensionality"Automaticnumber of spatial dimensions of the convolution
    "Interleaving"Falsethe position of the channel dimension
    "PaddingSize"0amount of zero padding to apply to the input
    "Stride"1convolution step size to use
    "Weights"Automaticinitial tensor of kernel weights
  • The settings for "PaddingSize", "Dilation" and "Stride" can be of the following forms:
  • nuse the value n for all dimensions
    {,ni,}use the value ni for the i^(th) dimension
  • With Automatic settings, weights and biases are added automatically when NetInitialize or NetTrain is used.
  • The setting "Biases"->None specifies that no biases should be used.
  • With the setting "Interleaving"->False, the channel dimension is taken to be the first dimension of the input and output tensors.
  • With the setting "Interleaving"->True, the channel dimension is taken to be the last dimension of the input and output tensors.
  • If weights and biases have been added, ConvolutionLayer[][input] explicitly computes the output from applying the layer.
  • ConvolutionLayer[][{input1,input2,}] explicitly computes outputs for each of the inputi.
  • NetExtract can be used to extract weights and biases from a ConvolutionLayer object.
  • ConvolutionLayer is typically used inside NetChain, NetGraph, etc.
  • ConvolutionLayer exposes the following ports for use in NetGraph etc.:
  • "Input"a tensor of rank 2, 3 or 4
    "Output"a tensor of rank 2, 3 or 4
  • ConvolutionLayer can operate on tensors that contain "Varying" dimensions.
  • When it cannot be inferred from other layers in a larger net, the option "Input"->{d1,,dn} can be used to fix the input dimensions of ConvolutionLayer.
  • Given an input tensor of dimensions d1××di×, the output tensor will be of dimensions ×××, where the channel dimension =n and the sizes di are transformed according to , where is the padding size, is the kernel size, is the stride size, and is the dilation factor for each dimension.


open allclose all

Basic Examples  (2)

Create a one-dimensional ConvolutionLayer with 2 output channels and a kernel size of 4:

Click for copyable input

Create an initialized one-dimensional ConvolutionLayer:

Click for copyable input

Apply the layer to an input matrix:

Click for copyable input

Scope  (3)

Options  (16)

Properties & Relations  (2)

Possible Issues  (3)

See Also

DeconvolutionLayer  PoolingLayer  BatchNormalizationLayer  LocalResponseNormalizationLayer  NetChain  NetGraph  NetInitialize  NetTrain  NetExtract  Ramp  SpatialTransformationLayer  NetEncoder  "Image"  "Image3D"  "Audio"


Introduced in 2016
| Updated in 2018