A normalization kernel applied across feature channels.


class MPSCNNCrossChannelNormalization : MPSCNNKernel


The normalization kernel applies the kernel to a local region across nearby feature channels, but with no spatial extent (i.e., they have the shape kernel size x 1 x 1). The normalized output is given by the function:

Y(i,j,k) = X(i,j,k) / L(i,j,k)^beta

Where the normalizing factor is:

L(i,j,k) = delta + alpha/N * (sum_{q in Q(k)} X(i,j,q)^2

Where N is the kernel size. The window Q(k) itself is defined as:

Q(k) = [max(0, k-floor(N/2)), min(D-1, k+floor((N-1)/2)]

Where k is the feature channel index (running from 0 to D-1) and D is the number of feature channels, and the values of alpha, beta, and delta are set via properties.

It is your responsibility to ensure that the combination of the values of the delta and alpha properties does not result in a situation where the denominator becomes zero - in such situations the resulting pixel-value is undefined.



init?(coder: NSCoder, device: MTLDevice)

Initializes a normalization kernel in a channel.

init(device: MTLDevice, kernelSize: Int)

Initializes a normalization kernel in a channel.

Instance Properties

var alpha: Float

The "alpha" variable of the kernel function.

var beta: Float

The "beta" variable of the kernel function.

var delta: Float

The "delta" variable of the kernel function.

var kernelSize: Int

The size of the square kernel window.


Inherits From

Conforms To

See Also

Normalization Layers

class MPSCNNCrossChannelNormalizationGradient

A gradient normalization kernel applied across feature channels.

class MPSCNNLocalContrastNormalization

A local-contrast normalization kernel.

class MPSCNNLocalContrastNormalizationGradient

A gradient local-contrast normalization kernel.

class MPSCNNSpatialNormalization

A spatial normalization kernel.

class MPSCNNSpatialNormalizationGradient

A gradient spatial normalization kernel.

class MPSCNNBatchNormalization

A batch normalization kernel.

class MPSCNNBatchNormalizationGradient

A gradient batch normalization kernel.

class MPSCNNBatchNormalizationState

An object that stores data required to execute batch normalization.

class MPSCNNNormalizationMeanAndVarianceState

An object that stores mean and variance terms used to execute batch normalization.

class MPSCNNBatchNormalizationStatistics

An object that stores statistics required to execute batch normalization.

class MPSCNNBatchNormalizationStatisticsGradient

An object that stores the gradient of the loss function with respect to the batch statistics and batch normalization weights.

class MPSCNNInstanceNormalization

An instance normalization kernel.

class MPSCNNInstanceNormalizationGradient

A gradient instance normalization kernel.

class MPSCNNInstanceNormalizationGradientState

An object that stores information required to execute a gradient pass for instance normalization.

class MPSCNNNormalizationGammaAndBetaState

An object that stores gamma and beta terms used to apply a scale and bias in instance- or batch-normalization operations.

Beta Software

This documentation contains preliminary information about an API or technology in development. This information is subject to change, and software implemented according to this documentation should be tested with final operating system software.

Learn more about using Apple's beta software