Main Content

addPix2PixHDLocalEnhancer

Add local enhancer network to pix2pixHD generator network

Since R2021a

Description

netWithEnhancer = addPix2PixHDLocalEnhancer(net) adds a local enhancer network to a pix2pixHD generator network, net. For more information about the network architecture, see pix2pixHD Local Enhancer Network.

This function requires Deep Learning Toolbox™.

example

netWithEnhancer = addPix2PixHDLocalEnhancer(net,Name=Value) controls aspects of the local enhancer network creation using name-value arguments.

Examples

collapse all

Specify the network input size for 32-channel data of size 512-by-1024.

inputSize = [512 1024 32];

Create a pix2pixHD global generator network.

pix2pixHD = pix2pixHDGlobalGenerator(inputSize)
pix2pixHD = 
  dlnetwork with properties:

         Layers: [84×1 nnet.cnn.layer.Layer]
    Connections: [92×2 table]
     Learnables: [110×3 table]
          State: [0×3 table]
     InputNames: {'GlobalGenerator_inputLayer'}
    OutputNames: {'GlobalGenerator_fActivation'}
    Initialized: 1

  View summary with summary.

Add a local enhancer network to the pix2pixHD network.

pix2pixHDEnhanced = addPix2PixHDLocalEnhancer(pix2pixHD)
pix2pixHDEnhanced = 
  dlnetwork with properties:

         Layers: [113×1 nnet.cnn.layer.Layer]
    Connections: [124×2 table]
     Learnables: [146×3 table]
          State: [0×3 table]
     InputNames: {'LocalEnhancer_inputLayer'  'GlobalGenerator_inputLayer'}
    OutputNames: {'LocalEnhancer_fActivation'}
    Initialized: 1

  View summary with summary.

Display the network with the local enhancer.

analyzeNetwork(pix2pixHDEnhanced)

Input Arguments

collapse all

Pix2pixHD generator network, specified as a dlnetwork (Deep Learning Toolbox) object. You can create a pix2pixHD generator network using the pix2pixHDGlobalGenerator function.

Name-Value Arguments

collapse all

Specify optional pairs of arguments as Name1=Value1,...,NameN=ValueN, where Name is the argument name and Value is the corresponding value. Name-value arguments must appear after other arguments, but the order of the pairs does not matter.

Example: netWithEnhancer = addPix2PixHDLocalEnhancer(net,FilterSizeInFirstAndLastBlocks=[5 7]) adds a local enhancer whose first and last convolution layers have a size of 5-by-7.

Before R2021a, use commas to separate each name and value, and enclose Name in quotes.

Example: netWithEnhancer = addPix2PixHDLocalEnhancer(net,"FilterSizeInFirstAndLastBlocks",[5 7]) adds a local enhancer whose first and last convolution layers have a size of 5-by-7.

Filter size in the first and last convolution layers of the local enhancer network, specified as a positive odd integer or 2-element vector of positive odd integers of the form [height width]. When you specify the filter size as a scalar, the filter has equal height and width.

Filter size in intermediate convolution layers in the local enhancer network, specified as a positive odd integer or 2-element vector of positive odd integers of the form [height width]. The intermediate convolution layers are the convolution layers excluding the first and last convolution layer. When you specify the filter size as a scalar, the filter has identical height and width. Typical values are between 3 and 7.

Number of residual blocks in the local enhancer network, specified as a positive integer. Each residual block consists of a set of convolution, normalization and nonlinear layers with skip connections between every block.

Style of padding used in the local enhancer network, specified as one of these values.

PaddingValueDescriptionExample
Numeric scalarPad with the specified numeric value

[314159265][2222222222222222314222215922222652222222222222222]

"symmetric-include-edge"Pad using mirrored values of the input, including the edge values

[314159265][5115995133144113314415115995622655662265565115995]

"symmetric-exclude-edge"Pad using mirrored values of the input, excluding the edge values

[314159265][5626562951595141314139515951562656295159514131413]

"replicate"Pad using repeated border elements of the input

[314159265][3331444333144433314441115999222655522265552226555]

Method used to upsample activations in the local enhancer network, specified as one of these values:

Data Types: char | string

Weight initialization used in convolution layers of the local enhancer network, specified as "glorot", "he", "narrow-normal", or a function handle. For more information, see Specify Custom Weight Initialization Function (Deep Learning Toolbox).

Activation function to use in the local enhancer network, specified as one of these values. For more information and a list of available layers, see Activation Layers (Deep Learning Toolbox).

  • "relu" — Use a reluLayer (Deep Learning Toolbox)

  • "leakyRelu" — Use a leakyReluLayer (Deep Learning Toolbox) with a scale factor of 0.2

  • "elu" — Use an eluLayer (Deep Learning Toolbox)

  • A layer object

Normalization operation to use after each convolution in the local enhancer network, specified as one of these values. For more information and a list of available layers, see Normalization Layers (Deep Learning Toolbox).

Probability of dropout in the local enhancer network, specified as a number in the range [0, 1]. If you specify a value of 0, then the network does not include dropout layers. If you specify a value greater than 0, then the network includes a dropoutLayer (Deep Learning Toolbox) in each residual block.

Prefix to all layer names in the local enhancer network, specified as a string or character vector.

Data Types: char | string

Output Arguments

collapse all

Pix2pixHD generator network with local enhancer, returned as a dlnetwork (Deep Learning Toolbox) object.

More About

collapse all

References

[1] Wang, Ting-Chun, Ming-Yu Liu, Jun-Yan Zhu, Andrew Tao, Jan Kautz, and Bryan Catanzaro. "High-Resolution Image Synthesis and Semantic Manipulation with Conditional GANs." In 2018 IEEE/CVF Conference on Computer Vision and Pattern Recognition, 8798–8807. Salt Lake City, UT, USA: IEEE, 2018. https://doi.org/10.1109/CVPR.2018.00917.

Version History

Introduced in R2021a