<!--
{
  "availability" : [
    "iOS: 14.0.0 -",
    "iPadOS: 14.0.0 -",
    "macCatalyst: 14.0.0 -",
    "macOS: 11.0.0 -",
    "tvOS: 14.0.0 -",
    "visionOS: 1.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "MetalPerformanceShadersGraph",
  "identifier" : "/documentation/MetalPerformanceShadersGraph/MPSGraph/normalize(_:mean:variance:gamma:beta:epsilon:name:)",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "Metal Performance Shaders Graph",
      "MetalPerformanceShadersGraph"
    ],
    "preciseIdentifier" : "c:objc(cs)MPSGraph(im)normalizationWithTensor:meanTensor:varianceTensor:gammaTensor:betaTensor:epsilon:name:"
  },
  "title" : "normalize(_:mean:variance:gamma:beta:epsilon:name:)"
}
-->

# normalize(_:mean:variance:gamma:beta:epsilon:name:)

Creates a batch normalization operation and returns the result tensor.

```
func normalize(_ tensor: MPSGraphTensor, mean: MPSGraphTensor, variance: MPSGraphTensor, gamma: MPSGraphTensor?, beta: MPSGraphTensor?, epsilon: Float, name: String?) -> MPSGraphTensor
```

## Parameters

`tensor`

The input tensor.

`mean`

The mean tensor.

`variance`

The variance tensor.

`gamma`

The tensor used to scale the normalized result.

`beta`

The tensor used to bias the normalized result.

`epsilon`

A small value to add to the variance when normalizing the inputs.

`name`

An optional name for the operation.

## Return Value

A valid `MPSGraphTensor` object.

## Discussion

The mean and variance tensors should be outputs of `meanWithTensor:axes:name` and `varianceWithTensor:meanTensor:axes:name`.
Use the axes parameter to achieve different types of normalizations.
For example (assuming your data is in NxHxWxC format)
Batch normalization: axes = [0, 1, 2]
Instance normalization: axes = [1, 2]
Shapes for gamma and beta must match the input data along at least one dimension and will be broadcast along the rest.
For batch normalization, gamma and beta would typically be 1x1x1xC i.e. one value per channel.

---

Copyright &copy; 2026 Apple Inc. All rights reserved. | [Terms of Use](https://www.apple.com/legal/internet-services/terms/site.html) | [Privacy Policy](https://www.apple.com/privacy/privacy-policy)