主要内容

instanceNorm.

Normalize across each channel for each observation independently

描述

The instance normalization operation normalizes the input data across each channel for each observation independently. To improve the convergence of training the convolutional neural network and reduce the sensitivity to network hyperparameters, use instance normalization between convolution and nonlinear operations such asrelu

After normalization, the operation shifts the input by a learnable offsetβ并通过学习的比例因子来缩放它γ.

TheinstanceNorm.function applies the layer normalization operation todlarray.data.Usingdlarray.对象通过允许您标记尺寸来更轻松地使用高维数据。例如,您可以使用使用的标记对应于空间,时间,通道和批量尺寸的维度标记“S”,“t”,“C”, 和“b”labels, respectively. For unspecified and other dimensions, use the"U"标签。为了dlarray.object functions that operate over particular dimensions, you can specify the dimension labels by formatting thedlarray.object directly, or by using theDataFormat选项。

Note

To apply instance normalization within a分层图对象或者array, useinstanceNormalizationLayer

example

Y= instancenorm(X,抵消,scaleFactor)将实例归一化操作应用于输入数据Xand transforms using the specified offset and scale factor.

The function normalizes over grouped subsets of the'S'(spatial),'T'(时间和'U'(未指定的)尺寸Xfor each observation in the'C'(channel) and'B'(批量)尺寸独立。

为了unformatted input data, use the'dataformat'选项。

Y= instancenorm(X,抵消,scaleFactor,'dataformat',fmt)applies the instance normalization operation to the unformatteddlarray.objectXwith format specified byFMT使用任何先前的语法。输出Y是一个不形式的dlarray.具有尺寸的对象与相同的顺序X。为了example,'dataformat','sscb'specifies data for 2-D image input with format'SSCB'(spatial, spatial, channel, batch).

Y= instancenorm(___名称,价值)specifies options using one or more name-value pair arguments in addition to the input arguments in previous syntaxes. For example,'Epsilon',3e-5sets the variance offset to3E-5

例子

全部收缩

使用两个空间,一个通道和一个观察维度创建随机输入数据。

宽度= 12;高度= 12;频道= 6;numobservations = 16;X = RANDN(宽度,高度,频道,NUMOBSERATIONS);dlx = dlarray(x,'SSCB');

Create the learnable parameters.

offset = dlarray(零(通道,1));scalefactor = dlarray((频道,1));

计算实例归一化。

DLZ = InstanceNorm(DLX,偏移,Scalefactor);

View the size and format of the normalized data.

size(dlZ)
ans =1×412 12 6 16
dims(dlZ)
ANS ='SSCB'

Input Arguments

全部收缩

输入数据,指定为格式化dlarray.,一个不形式的dlarray.或数字数组。

如果X是一个不形式的dlarray.或者numeric array, then you must specify the format using theDataFormat选项。如果Xis a numeric array, then eitherscaleFactor或者抵消必须是A.dlarray.目的。

Xmust have a'C'(channel) dimension.

Offsetβ, specified as a formatteddlarray.,一个不形式的dlarray.或者一个数字数组,其中一个unonsingleton维度,大小与匹配的大小'C'(通道)输入的尺寸X

如果抵消是一个格式化的dlarray.object, then the nonsingleton dimension must have label'C'(channel).

Scale factorγ., specified as a formatteddlarray.,一个不形式的dlarray.或者一个数字数组,其中一个unonsingleton维度,大小与匹配的大小'C'(通道)输入的尺寸X

如果scaleFactor是一个格式化的dlarray.object, then the nonsingleton dimension must have label'C'(channel).

Name-Value Arguments

指定可选的参数成对Name1=Value1,...,NameN=ValueN, 在哪里Nameis the argument name and价值是相应的价值。名称 - 值参数必须在其他参数之后出现,但对的顺序无关紧要。

Before R2021a, use commas to separate each name and value, and encloseNamein quotes.

例子:'Epsilon',3e-5sets the variance offset to3E-5

未格式化的输入数据的维度顺序,指定为字符向量或字符串标量FMT为数据的每个维度提供标签。

指定a的格式dlarray.对象,提供每个字符es a label for each dimension of the data and must be one of the following:

  • “S”— Spatial

  • “C”— Channel

  • “b”- 批次(例如,样品和观察)

  • “t”- 时间(例如,序列的时间步长)

  • "U"— Unspecified

您可以指定标记的多个维度“S”或者"U"。您可以使用标签“C”,“b”, 和“t”最多一次。

You must specifyDataFormatwhen the input data is not a formatteddlarray.

Data Types:char|string

用于防止返回归零错误的方差偏移,指定为包括的逗号分隔对'Epsilon'和数字标量大于或等于1e-5

Data Types:single|双倍的

Output Arguments

全部收缩

Normalized data, returned as adlarray.。输出Y具有与输入相同的底层数据类型X

如果the input dataX是一个格式化的dlarray.,Yhas the same dimension format asX。如果输入数据不是格式化的dlarray.,Y是一个不形式的dlarray.with the same dimension order as the input data.

算法

The instance normalization operation normalizes the elementsxi首先计算平均值的输入μ.I和方差σ.I2over the spatial and time dimensions for each channel in each observation independently. Then, it calculates the normalized activations as

x i ^ = x i μ. I σ. I 2 + ε. ,

whereε.is a constant that improves numerical stability when the variance is very small.

To allow for the possibility that inputs with zero mean and unit variance are not optimal for the operations that follow instance normalization, the instance normalization operation further shifts and scales the activations using the transformation

y i = γ. x ^ i + β ,

where the offsetβ和规模因子γ.are learnable parameters that are updated during network training.

Extended Capabilities

Version History

在R2021A介绍