ConvolutionLayer
ConvolutionLayer[n,s]
represents a trainable convolutional net layer having n output channels and using kernels of size s to compute the convolution.
ConvolutionLayer[n,{s}]
represents a layer performing one-dimensional convolutions with kernels of size s.
ConvolutionLayer[n,{h,w}]
represents a layer performing two-dimensional convolution with kernels of size h×w.
ConvolutionLayer[n,kernel,opts]
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. The channel dimension is taken to be the first dimension of the input and output tensors.
- 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" Automatic initial vector of kernel biases "Dilation" 1 dilation factor "Dimensionality" Automatic number of spatial dimensions of the convolution "PaddingSize" 0 amount of zero padding to apply to the input "Stride" 1 convolution step size to use "Weights" Automatic initial tensor of kernel weights - The settings for "PaddingSize", "Dilation" and "Stride" can be of the following forms:
-
n use the value n for all dimensions {…,ni,…} use the value ni for the i
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.
- 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 matrix or rank-3 tensor "Output" a matrix or rank-3 tensor - 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.
Examples
open allclose allBasic Examples (2)
Create a one-dimensional ConvolutionLayer with 2 output channels and a kernel size of 4:
Create an initialized one-dimensional ConvolutionLayer:
Scope (3)
Options (15)
Properties & Relations (2)
Possible Issues (3)
See Also
DeconvolutionLayer PoolingLayer BatchNormalizationLayer LocalResponseNormalizationLayer NetChain NetGraph NetInitialize NetTrain NetExtract Ramp SpatialTransformationLayer