Main Content

transposedConv2dLayer

Transposed 2-D convolution layer

Description

A transposed 2-D convolution layer upsamples feature maps.

This layer is sometimes incorrectly known as a "deconvolution" or "deconv" layer. This layer is the transpose of convolution and does not perform deconvolution.

layer= transposedConv2dLayer(filterSize,numFilters)returns a transposed 2-D convolution layer and sets thefilterSizeandnumFiltersproperties.

example

layer= transposedConv2dLayer(filterSize,numFilters,Name,Value)returns a transposed 2-D convolutional layer and specifies additional options using one or more name-value pair arguments.

Examples

collapse all

Create a transposed convolutional layer with 96 filters, each with a height and width of 11. Use a stride of 4 in the horizontal and vertical directions.

layer = transposedConv2dLayer(11,96,'Stride',4);

Input Arguments

collapse all

Height and width of the filters, specified as a vector of two positive integers[h w], wherehis the height andwis the width.FilterSizedefines the size of the local regions to which the neurons connect in the input.

If you setFilterSizeusing an input argument, then you can specifyFilterSizeas scalar to use the same value for both dimensions.

Example:[5 5]specifies filters of height 5 and width 5.

Number of filters, specified as a positive integer. This number corresponds to the number of neurons in the layer that connect to the same region in the input. This parameter determines the number of channels (feature maps) in the output of the convolutional layer.

Example:96

Name-Value Arguments

Specify optional comma-separated pairs ofName,Valuearguments.Nameis the argument name andValueis the corresponding value.Namemust appear inside quotes. You can specify several name and value pair arguments in any order asName1,Value1,...,NameN,ValueN.

Example:'Cropping',1
Transposed Convolution

collapse all

Up-sampling factor of the input, specified as one of the following:

  • A vector of two positive integers[a b], whereais the vertical stride andbis the horizontal stride.

  • A positive integer the corresponds to both the vertical and horizontal stride.

Example:'Stride',[2 1]

Output size reduction, specified as one of the following:

  • 'same'– Set the cropping so that the output size equalsinputSize .* Stride, whereinputSizeis the height and width of the layer input. If you set the'Cropping'option to'same', then the software automatically sets theCroppingModeproperty of the layer to'same'.

    The software trims an equal amount from the top and bottom, and the left and right, if possible. If the vertical crop amount has an odd value, then the software trims an extra row from the bottom. If the horizontal crop amount has an odd value, then the software trims an extra column from the right.

  • A positive integer – Crop the specified amount of data from all the edges.

  • A vector of nonnegative integers[a b]- Cropafrom the top and bottom and cropbfrom the left and right.

  • A vector[t b l r]- Cropt,b,l,rfrom the top, bottom, left, and right of the input, respectively.

If you set the'Cropping'option to a numeric value, then the software automatically sets theCroppingModeproperty of the layer to'manual'.

Example:[1 2]

Number of channels for each filter, specified as 'NumChannels' and'auto'or a positive integer.

This parameter must be equal to the number of channels of the input to this convolutional layer. For example, if the input is a color image, then the number of channels for the input must be 3. If the number of filters for the convolutional layer prior to the current layer is 16, then the number of channels for this layer must be 16.

Parameters and Initialization

collapse all

Function to initialize the weights, specified as one of the following:

  • 'glorot'– Initialize the weights with the Glorot initializer[1](also known as Xavier initializer). The Glorot initializer independently samples from a uniform distribution with zero mean and variance2/(numIn + numOut), wherenumIn = filterSize(1)*filterSize(2)*NumChannels,numOut = filterSize(1)*filterSize(2)*numFilters, andNumChannels输入通道的数量。

  • 'he'– Initialize the weights with the He initializer[2]. The He initializer samples from a normal distribution with zero mean and variance2/numIn, wherenumIn = filterSize(1)*filterSize(2)*NumChannelsandNumChannels输入通道的数量。

  • 'narrow-normal'– Initialize the weights by independently sampling from a normal distribution with zero mean and standard deviation 0.01.

  • 'zeros'– Initialize the weights with zeros.

  • 'ones'– Initialize the weights with ones.

  • Function handle – Initialize the weights with a custom function. If you specify a function handle, then the function must be of the formweights = func(sz), wheresz权重的大小。例如,看到的Specify Custom Weight Initialization Function.

The layer only initializes the weights when theWeightsproperty is empty.

Data Types:char|string|function_handle

Function to initialize the bias, specified as one of the following:

  • 'zeros'– Initialize the bias with zeros.

  • 'ones'– Initialize the bias with ones.

  • 'narrow-normal'– Initialize the bias by independently sampling from a normal distribution with zero mean and standard deviation 0.01.

  • Function handle – Initialize the bias with a custom function. If you specify a function handle, then the function must be of the formbias = func(sz), whereszis the size of the bias.

The layer only initializes the bias when theBiasproperty is empty.

Data Types:char|string|function_handle

Layer weights for the convolutional layer, specified as a numeric array.

The layer weights are learnable parameters. You can specify the initial value for the weights directly using theWeightsproperty of the layer. When you train a network, if theWeightsproperty of the layer is nonempty, thentrainNetworkuses theWeightsproperty as the initial value. If theWeightsproperty is empty, thentrainNetworkuses the initializer specified by theWeightsInitializerproperty of the layer.

At training time,Weightsis afilterSize(1)-by-filterSize(2)-by-numFilters-by-NumChannelsarray.

Data Types:single|double

Layer biases for the convolutional layer, specified as a numeric array.

The layer biases are learnable parameters. When you train a network, ifBiasis nonempty, thentrainNetworkuses theBiasproperty as the initial value. IfBiasis empty, thentrainNetworkuses the initializer specified byBiasInitializer.

At training time,Biasis a 1-by-1-by-numFiltersarray.

Data Types:single|double

Learning Rate and Regularization

collapse all

Learning rate factor for the weights, specified as a nonnegative scalar.

The software multiplies this factor by the global learning rate to determine the learning rate for the weights in this layer. For example, ifWeightLearnRateFactoris2, then the learning rate for the weights in this layer is twice the current global learning rate. The software determines the global learning rate based on the settings you specify using thetrainingOptionsfunction.

Data Types:single|double|int8|int16|int32|int64|uint8|uint16|uint32|uint64

Learning rate factor for the biases, specified as a nonnegative scalar.

The software multiplies this factor by the global learning rate to determine the learning rate for the biases in this layer. For example, ifBiasLearnRateFactoris2, then the learning rate for the biases in the layer is twice the current global learning rate. The software determines the global learning rate based on the settings you specify using thetrainingOptionsfunction.

Data Types:single|double|int8|int16|int32|int64|uint8|uint16|uint32|uint64

L2regularization factor for the weights, specified as a nonnegative scalar.

The software multiplies this factor by the globalL2regularization factor to determine theL2regularization for the weights in this layer. For example, ifWeightL2Factoris2, then theL2regularization for the weights in this layer is twice the globalL2regularization factor. You can specify the globalL2regularization factor using thetrainingOptionsfunction.

Data Types:single|double|int8|int16|int32|int64|uint8|uint16|uint32|uint64

L2regularization factor for the biases, specified as a nonnegative scalar.

The software multiplies this factor by the globalL2regularization factor to determine theL2regularization for the biases in this layer. For example, ifBiasL2Factoris2, then theL2regularization for the biases in this layer is twice the globalL2regularization factor. You can specify the globalL2regularization factor using thetrainingOptionsfunction.

Data Types:single|double|int8|int16|int32|int64|uint8|uint16|uint32|uint64

Layer

collapse all

Layer name, specified as a character vector or a string scalar. ForLayerarray input, thetrainNetwork,assembleNetwork,layerGraph, anddlnetworkfunctions automatically assign names to layers withNameset to''.

Data Types:char|string

Output Arguments

collapse all

Transposed 2-D convolution layer, returned as aTransposedConvolution2DLayerobject.

Compatibility Considerations

expand all

Behavior changed in R2019a

References

[1] Glorot, Xavier, and Yoshua Bengio. "Understanding the Difficulty of Training Deep Feedforward Neural Networks." InProceedings of the Thirteenth International Conference on Artificial Intelligence and Statistics, 249–356. Sardinia, Italy: AISTATS, 2010.

[2] He, Kaiming, Xiangyu Zhang, Shaoqing Ren, and Jian Sun. "Delving Deep into Rectifiers: Surpassing Human-Level Performance on ImageNet Classification." InProceedings of the 2015 IEEE International Conference on Computer Vision, 1026–1034. Washington, DC: IEEE Computer Vision Society, 2015.

Extended Capabilities

GPU Code Generation
Generate CUDA® code for NVIDIA® GPUs using GPU Coder™.

Introduced in R2017b