Wolfram Language & System 11.0 (2016)|Legacy Documentation

This is documentation for an earlier version of the Wolfram Language.View current documentation (Version 11.2)

ConvolutionLayer

ConvolutionLayer[n,s]
represents a trainable 2D convolutional net layer having n output channels, and uses s×s kernels to compute the convolution.

ConvolutionLayer[n,{h,w}]
uses kernels of size h×w.

ConvolutionLayer[n,{h,w},opts]
includes options for initial kernels and other parameters.

Details and OptionsDetails and Options

  • The following optional parameters can be included:
  • "Biases"Automaticinitial vector of kernel biases
    "Dilation"1dilation factor
    "PaddingSize"0amount of zero padding to apply to the input
    "Stride"1convolution step size to use
    "Weights"Automaticinitial matrix of kernel weights
  • 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.
  • 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 rank-3 numerical tensor
    "Output"a rank-3 numerical tensor
  • When it cannot be inferred from other layers in a larger net, the option "Input"->{d1,d2,d3} can be used to fix the input dimensions of ConvolutionLayer.
  • Given an input tensor of dimensions d1×d2×d3, the output tensor will be of dimensions 1×2×3, where the channel dimension 1=n, and the sizes d2 and d3 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.

ExamplesExamplesopen allclose all

Basic Examples  (3)Basic Examples  (3)

Create a 3x3 convolutional layer with 10 output channels:

In[1]:=
Click for copyable input
Out[1]=

Create an uninitialized layer with the input dimensions specified:

In[1]:=
Click for copyable input
Out[1]=

Initialize the layer with random weights:

In[2]:=
Click for copyable input

The layer automatically threads over lists of rank-3 tensors:

In[3]:=
Click for copyable input
Out[3]=

Create a randomly initialized convolution layer that takes in an image and returns an image using a NetEncoder and NetDecoder:

In[1]:=
Click for copyable input
Out[1]=

Apply the convolution layer to an image:

In[2]:=
Click for copyable input
Out[2]=
Introduced in 2016
(11.0)