pix2pixHDGlobalGenerator
Create pix2pixHD global generator network
Syntax
Description
creates a pix2pixHD generator network for input of sizenet
= pix2pixHDGlobalGenerator(inputSize
)inputSize
. For more information about the network architecture, seepix2pixHD Generator Network.
This function requires Deep Learning Toolbox™.
modifies properties of the pix2pixHD network using name-value arguments.net
= pix2pixHDGlobalGenerator(inputSize
,Name,Value
)
Examples
Create Pix2PixHD Generator
Specify the network input size for 32-channel data of size 512-by-1024 pixels.
inputSize = [512 1024 32];
Create a pix2pixHD global generator network.
net = pix2pixHDGlobalGenerator(inputSize)
net = dlnetwork with properties: Layers: [84x1 nnet.cnn.layer.Layer] Connections: [92x2 table] Learnables: [110x3 table] State: [0x3 table] InputNames: {'GlobalGenerator_inputLayer'} OutputNames: {'GlobalGenerator_fActivation'} Initialized: 1
Display the network.
analyzeNetwork(net)
Create Pix2PixHD Generator with Batch Normalization
Specify the network input size for 32-channel data of size 512-by-1024 pixels.
inputSize = [512 1024 32];
Create a pix2pixHD generator network that performs batch normalization after each convolution.
net = pix2pixHDGlobalGenerator(inputSize,"Normalization","batch")
net = dlnetwork with properties: Layers: [84x1 nnet.cnn.layer.Layer] Connections: [92x2 table] Learnables: [110x3 table] State: [54x3 table] InputNames: {'GlobalGenerator_inputLayer'} OutputNames: {'GlobalGenerator_fActivation'} Initialized: 1
Display the network.
analyzeNetwork(net)
Input Arguments
inputSize
—Network input size
3-element vector of positive integers
Network input size, specified as a 3-element vector of positive integers.inputSize
has the form [HWC], whereHis the height,Wis the width, andCis the number of channels.
Example:[28 28 3]
specifies an input size of 28-by-28 pixels for a 3-channel image.
Name-Value Arguments
Specify optional pairs of arguments asName1=Value1,...,NameN=ValueN
, whereName
is the argument name andValue
is the corresponding value. Name-value arguments must appear after other arguments, but the order of the pairs does not matter.
Before R2021a, use commas to separate each name and value, and encloseName
in quotes.
Example:'NumFiltersInFirstBlock',32
creates a network with 32 filters in the first convolution layer
NumDownsamplingBlocks
—Number of downsampling blocks
4
(default) |positive integer
Number of downsampling blocks in the network encoder module, specified as a positive integer. In total, the network downsamples the input by a factor of 2^NumDownsamplingBlocks
. The decoder module consists of the same number of upsampling blocks.
NumFiltersInFirstBlock
—Number of filters in first convolution layer
64
(default) |positive even integer
Number of filters in the first convolution layer, specified as a positive even integer.
NumOutputChannels
—Number of output channels
3
(default) |positive integer
Number of output channels, specified as a positive integer.
FilterSizeInFirstAndLastBlocks
—Filter size in first and last convolution layers
7
(default) |positive odd integer|2-element vector of positive odd integers
Filter size in the first and last convolution layers of the network, specified as a positive odd integer or 2-element vector of positive odd integers of the form [heightwidth]。When you specify the filter size as a scalar, the filter has equal height and width.
FilterSizeInIntermediateBlocks
—Filter size in intermediate convolution layers
3
(default) |2-element vector of positive odd integers|positive odd integer
Filter size in intermediate convolution layers, specified as a positive odd integer or 2-element vector of positive odd integers of the form [heightwidth]。中间卷积层是反对的volution 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.
NumResidualBlocks
—Number of residual blocks
9
(default) |positive integer
Number of residual blocks, specified as a positive integer.
ConvolutionPaddingValue
—Style of padding
"symmetric-exclude-edge"
(default) |"symmetric-include-edge"
|"replicate"
|numeric scalar
Style of padding used in the network, specified as one of these values.
PaddingValue |
Description | Example |
---|---|---|
Numeric scalar | Pad with the specified numeric value |
|
'symmetric-include-edge' |
Pad using mirrored values of the input, including the edge values |
|
'symmetric-exclude-edge' |
Pad using mirrored values of the input, excluding the edge values |
|
“复制” |
Pad using repeated border elements of the input |
|
UpsampleMethod
—Method used to upsample activations
"transposedConv"
(default) |"bilinearResize"
|"pixelShuffle"
Method used to upsample activations, specified as one of these values:
"transposedConv"
— Use atransposedConv2dLayer
(Deep Learning Toolbox)with a stride of [2 2]"bilinearResize"
— Use aconvolution2dLayer
(Deep Learning Toolbox)with a stride of [1 1] followed by aresize2dLayer
with a scale of [2 2]"pixelShuffle"
— Use aconvolution2dLayer
(Deep Learning Toolbox)with a stride of [1 1] followed by adepthToSpace2dLayer
with a block size of [2 2]
Data Types:char
|string
ConvolutionWeightsInitializer
—Weight initialization used in convolution layers
"narrow-normal"
(default) |"glorot"
|"he"
|function
Weight initialization used in convolution layers, specified as"glorot"
,"he"
,"narrow-normal"
, or a function handle. For more information, seeSpecify Custom Weight Initialization Function(Deep Learning Toolbox).
ActivationLayer
—Activation function
"relu"
(default) |"leakyRelu"
|"elu"
|layer object
Activation function to use in the network, specified as one of these values. For more information and a list of available layers, seeActivation Layers(Deep Learning Toolbox).
"relu"
— Use areluLayer
(Deep Learning Toolbox)"leakyRelu"
— Use aleakyReluLayer
(Deep Learning Toolbox)with a scale factor of 0.2"elu"
— Use aneluLayer
(Deep Learning Toolbox)A layer object
FinalActivationLayer
—Activation function after final convolution
"tanh"
(default) |"sigmoid"
|"softmax"
|"none"
|layer object
Activation function after the final convolution layer, specified as one of these values. For more information and a list of available layers, seeOutput Layers(Deep Learning Toolbox).
"tanh"
— Use atanhLayer
(Deep Learning Toolbox)"sigmoid"
— Use asigmoidLayer
(Deep Learning Toolbox)"softmax"
— Use asoftmaxLayer
(Deep Learning Toolbox)"none"
— Do not use a final activation layerA layer object
NormalizationLayer
—Normalization operation
"instance"
(default) |"none"
|"batch"
|layer object
Normalization operation to use after each convolution, specified as one of these values. For more information and a list of available layers, seeNormalization, Dropout, and Cropping Layers(Deep Learning Toolbox).
"instance"
— Use aninstanceNormalizationLayer
(Deep Learning Toolbox)"batch"
— Use abatchNormalizationLayer
(Deep Learning Toolbox)"none"
— Do not use a normalization layerA layer object
Dropout
—Probability of dropout
0
(default) |number in the range [0, 1]
Probability of dropout, specified as a number in the range [0, 1]. If you specify a value of0
, then the network does not include dropout layers. If you specify a value greater than0
, then the network includes adropoutLayer
(Deep Learning Toolbox)in each residual block.
NamePrefix
—Prefix to all layer names
"GlobalGenerator_"
(default) |string|character vector
Prefix to all layer names in the network, specified as a string or character vector.
Data Types:char
|string
Output Arguments
net
— pix2pixHD generator network
dlnetwork
object
Pix2pixHD generator network, returned as adlnetwork
(Deep Learning Toolbox)object.
More About
pix2pixHD Generator Network
A pix2pixHD generator network consists of an encoder module followed by a decoder module. The default network follows the architecture proposed by Wang et. al.[1].
The encoder module downsamples the input by a factor of 2^NumDownsamplingBlocks
. The encoder module consists of an initial block of layers,NumDownsamplingBlocks
downsampling blocks, andNumResidualBlocks
residual blocks. The decoder module upsamples the input by a factor of 2^NumDownsamplingBlocks
. The decoder module consists ofNumDownsamplingBlocks
upsampling blocks and a final block.
The table describes the blocks of layers that comprise the encoder and decoder modules.
Block Type | Layers | Diagram of Default Block |
---|---|---|
Initial block |
|
|
Downsampling block |
|
|
Residual block |
|
|
Upsampling block |
|
|
Final block |
|
|
Tips
You can create the discriminator network for pix2pixHD by using the
patchGANDiscriminator
function.Train the pix2pixHD GAN network using a custom training loop.
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." In2018 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
See Also
addPix2PixHDLocalEnhancer
|encoderDecoderNetwork
|blockedNetwork
|cycleGANGenerator
|unitGenerator
Topics
- Generate Image from Segmentation Map Using Deep Learning(计算机Vision Toolbox)
- Get Started with GANs for Image-to-Image Translation
- Create Modular Neural Networks
- List of Deep Learning Layers(Deep Learning Toolbox)
Ouvrir l'exemple
Vous possédez une version modifiée de cet exemple. Souhaitez-vous ouvrir cet exemple avec vos modifications ?
Commande MATLAB
Vous avez cliqué sur un lien qui correspond à cette commande MATLAB :
Pour exécuter la commande, saisissez-la dans la fenêtre de commande de MATLAB. Les navigateurs web ne supportent pas les commandes MATLAB.
Select a Web Site
Choose a web site to get translated content where available and see local events and offers. Based on your location, we recommend that you select:.
You can also select a web site from the following list:
How to Get Best Site Performance
Select the China site (in Chinese or English) for best site performance. Other MathWorks country sites are not optimized for visits from your location.
Americas
- América Latina(Español)
- Canada(English)
- United States(English)
Europe
- Belgium(English)
- Denmark(English)
- Deutschland(Deutsch)
- España(Español)
- Finland(English)
- France(Français)
- Ireland(English)
- Italia(Italiano)
- Luxembourg(English)
- Netherlands(English)
- Norway(English)
- Österreich(Deutsch)
- Portugal(English)
- Sweden(English)
- Switzerland
- United Kingdom(English)