---
title: "clamp(min:max:)"
framework: ML Compute
role: symbol
role_heading: Type Method
platforms: [iOS 14.0+, iPadOS 14.0+, Mac Catalyst 14.0+, macOS 11.0+, tvOS 14.0+]
path: "mlcompute/mlcactivationlayer/clamp(min:max:)"
---

# clamp(min:max:)

Creates an instance of a clamp activation layer using the minimum and maximum values you specify for the clamp formation.

## Declaration

```swift
class func clamp(min minValue: Float, max maxValue: Float) -> Self
```

## Parameters

- `minValue`: The minimum value to clamp.
- `maxValue`: The maximum value to clamp.

## Return Value

Return Value A new MLCActivationLayer instance.

## Discussion

Discussion The clamp(min:max:) factory type method creates an activation descriptor using init(type:a:b:), where type = MLCActivationType.clamp and a = minValue, b = maxValue, and passes that descriptor to init(descriptor:).

## See Also

### Factory Methods

- [celu(a:)](mlcompute/mlcactivationlayer/celu(a:).md)
- [elu(a:)](mlcompute/mlcactivationlayer/elu(a:).md)
- [hardShrink(a:)](mlcompute/mlcactivationlayer/hardshrink(a:).md)
- [leakyReLU(negativeSlope:)](mlcompute/mlcactivationlayer/leakyrelu(negativeslope:).md)
- [linear(scale:bias:)](mlcompute/mlcactivationlayer/linear(scale:bias:).md)
- [relun(a:b:)](mlcompute/mlcactivationlayer/relun(a:b:).md)
- [softPlus(beta:)](mlcompute/mlcactivationlayer/softplus(beta:).md)
- [softShrink(a:)](mlcompute/mlcactivationlayer/softshrink(a:).md)
- [threshold(_:replacement:)](mlcompute/mlcactivationlayer/threshold(_:replacement:).md)
