---
title: MPSCNNSpatialNormalization
framework: metalperformanceshaders
role: symbol
role_heading: Class
path: metalperformanceshaders/mpscnnspatialnormalization
---

# MPSCNNSpatialNormalization

A spatial normalization kernel.

## Declaration

```swift
class MPSCNNSpatialNormalization
```

## Overview

Overview The spatial normalization for a feature channel applies the kernel over local regions which extend spatially, but are in separate feature channels (i.e., they have the shape 1 x kernel width x kernel height). For each feature channel, the function computes the sum of squares of X inside each rectangle, N2(i,j). It then divides each element of X as follows:

Where kw and kh are the values of the kernelWidth and kernelHeight properties, respectively. It is your responsibility to ensure that the combination of the values of the delta and alpha kernelWidth kernelHeight properties does not result in a situation where the denominator becomes zero (in such situations the resulting pixel-value is undefined). note: The encoding methods in the MPSUnaryImageKernel class can be used to encode an MPSCNNSpatialNormalization object to a MTLCommandBuffer object.

## Topics

### Initializers

- [init(coder:device:)](metalperformanceshaders/mpscnnspatialnormalization/init(coder:device:).md)
- [init(device:kernelWidth:kernelHeight:)](metalperformanceshaders/mpscnnspatialnormalization/init(device:kernelwidth:kernelheight:).md)

### Instance Properties

- [alpha](metalperformanceshaders/mpscnnspatialnormalization/alpha.md)
- [beta](metalperformanceshaders/mpscnnspatialnormalization/beta.md)
- [delta](metalperformanceshaders/mpscnnspatialnormalization/delta.md)

### Instance Methods

- [init(device:kernelWidth:kernelHeight:)](metalperformanceshaders/mpscnnspatialnormalization/init(device:kernelwidth:kernelheight:).md)

## Relationships

### Inherits From

- [MPSCNNKernel](metalperformanceshaders/mpscnnkernel.md)

### Conforms To

- [CVarArg](swift/cvararg.md)
- [CustomDebugStringConvertible](swift/customdebugstringconvertible.md)
- [CustomStringConvertible](swift/customstringconvertible.md)
- [Equatable](swift/equatable.md)
- [Hashable](swift/hashable.md)
- [NSCoding](foundation/nscoding.md)
- [NSCopying](foundation/nscopying.md)
- [NSObjectProtocol](objectivec/nsobjectprotocol.md)
- [NSSecureCoding](foundation/nssecurecoding.md)

## See Also

### Normalization Layers

- [MPSCNNCrossChannelNormalization](metalperformanceshaders/mpscnncrosschannelnormalization.md)
- [MPSCNNCrossChannelNormalizationGradient](metalperformanceshaders/mpscnncrosschannelnormalizationgradient.md)
- [MPSCNNLocalContrastNormalization](metalperformanceshaders/mpscnnlocalcontrastnormalization.md)
- [MPSCNNLocalContrastNormalizationGradient](metalperformanceshaders/mpscnnlocalcontrastnormalizationgradient.md)
- [MPSCNNSpatialNormalizationGradient](metalperformanceshaders/mpscnnspatialnormalizationgradient.md)
- [MPSCNNBatchNormalization](metalperformanceshaders/mpscnnbatchnormalization.md)
- [MPSCNNBatchNormalizationGradient](metalperformanceshaders/mpscnnbatchnormalizationgradient.md)
- [MPSCNNBatchNormalizationState](metalperformanceshaders/mpscnnbatchnormalizationstate.md)
- [MPSCNNNormalizationMeanAndVarianceState](metalperformanceshaders/mpscnnnormalizationmeanandvariancestate.md)
- [MPSCNNBatchNormalizationStatistics](metalperformanceshaders/mpscnnbatchnormalizationstatistics.md)
- [MPSCNNBatchNormalizationStatisticsGradient](metalperformanceshaders/mpscnnbatchnormalizationstatisticsgradient.md)
- [MPSCNNInstanceNormalization](metalperformanceshaders/mpscnninstancenormalization.md)
- [MPSCNNInstanceNormalizationGradient](metalperformanceshaders/mpscnninstancenormalizationgradient.md)
- [MPSCNNInstanceNormalizationGradientState](metalperformanceshaders/mpscnninstancenormalizationgradientstate.md)
- [MPSCNNNormalizationGammaAndBetaState](metalperformanceshaders/mpscnnnormalizationgammaandbetastate.md)
