<!--
{
  "documentType" : "article",
  "framework" : "MLCompute",
  "identifier" : "/documentation/MLCompute/preconfigured-activation-layers",
  "metadataVersion" : "0.1.0",
  "role" : "collectionGroup",
  "title" : "Preconfigured Activation Layers"
}
-->

# Preconfigured Activation Layers

Obtain a preconfigured activation layer with common behavior.

## Discussion

Use a factory to receive a preconfigured activation layer for various activation types.

## Topics

### Factory Methods

[`class func celu(a: Float) -> Self`](/documentation/MLCompute/MLCActivationLayer/celu(a:))

Creates an instance of a CELU activation layer using the alpha value you specify for the CELU formation.

[`class func clamp(min: Float, max: Float) -> Self`](/documentation/MLCompute/MLCActivationLayer/clamp(min:max:))

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

[`class func elu(a: Float) -> Self`](/documentation/MLCompute/MLCActivationLayer/elu(a:))

Creates an instance of an ELU activation layer using the alpha value you specify for the ELU formation.

[`class func hardShrink(a: Float) -> Self`](/documentation/MLCompute/MLCActivationLayer/hardShrink(a:))

Creates an instance of a hard shrink activation layer using the lambda value you specify for the hard shrink formation.

[`class func leakyReLU(negativeSlope: Float) -> Self`](/documentation/MLCompute/MLCActivationLayer/leakyReLU(negativeSlope:))

Creates an instance of a leaky ReLU activation layer using the angle of the negative slope you specify.

[`class func linear(scale: Float, bias: Float) -> Self`](/documentation/MLCompute/MLCActivationLayer/linear(scale:bias:))

Creates an instance of a linear activation layer using the scale factor and bias value you specify.

[`class func relun(a: Float, b: Float) -> Self`](/documentation/MLCompute/MLCActivationLayer/relun(a:b:))

Creates an instance of a ReLUN activation layer using the alpha and beta values you specify.

[`class func softPlus(beta: Float) -> Self`](/documentation/MLCompute/MLCActivationLayer/softPlus(beta:))

Creates an instance of a soft plus activation layer using the beta value you specify for the soft plus formation.

[`class func softShrink(a: Float) -> Self`](/documentation/MLCompute/MLCActivationLayer/softShrink(a:))

Creates an instance of a soft shrink activation layer using the lambda value you specify for the soft shrink formation.

[`class func threshold(Float, replacement: Float) -> Self`](/documentation/MLCompute/MLCActivationLayer/threshold(_:replacement:))

Creates an instance of a threshold activation layer using the threshold and replacement values you specify.

### Factory Properties

[`class var absolute: MLCActivationLayer`](/documentation/MLCompute/MLCActivationLayer/absolute)

Creates an instance of an absolute activation layer.

[`class var celu: MLCActivationLayer`](/documentation/MLCompute/MLCActivationLayer/celu)

Creates an instance of a CELU activation layer.

[`class var elu: MLCActivationLayer`](/documentation/MLCompute/MLCActivationLayer/elu)

Creates an instance of a parametric ELU activation layer.

[`class var gelu: MLCActivationLayer`](/documentation/MLCompute/MLCActivationLayer/gelu)

Creates an instance of a GELU activation layer.

[`class var hardShrink: MLCActivationLayer`](/documentation/MLCompute/MLCActivationLayer/hardShrink)

Creates an instance of a hard shrink activation layer.

[`class var hardSigmoid: MLCActivationLayer`](/documentation/MLCompute/MLCActivationLayer/hardSigmoid)

Creates an instance of a hard sigmoid activation layer.

[`class var hardSwish: MLCActivationLayer`](/documentation/MLCompute/MLCActivationLayer/hardSwish)

Creates an instance of a hard swish activation layer.

[`class var leakyReLU: MLCActivationLayer`](/documentation/MLCompute/MLCActivationLayer/leakyReLU)

Creates an instance of a leaky ReLU activation layer.

[`class var logSigmoid: MLCActivationLayer`](/documentation/MLCompute/MLCActivationLayer/logSigmoid)

Creates an instance of a log sigmoid activation layer.

[`class var relu: MLCActivationLayer`](/documentation/MLCompute/MLCActivationLayer/relu)

Creates an instance of a ReLU activation layer.

[`class var relu6: MLCActivationLayer`](/documentation/MLCompute/MLCActivationLayer/relu6)

Creates an instance of a ReLU6 activation layer.

[`class var selu: MLCActivationLayer`](/documentation/MLCompute/MLCActivationLayer/selu)

Creates an instance of a SELU activation layer.

[`class var sigmoid: MLCActivationLayer`](/documentation/MLCompute/MLCActivationLayer/sigmoid)

Creates an instance of a sigmoid activation layer.

[`class var softPlus: MLCActivationLayer`](/documentation/MLCompute/MLCActivationLayer/softPlus)

Creates an instance of a parametric soft plus activation layer.

[`class var softShrink: MLCActivationLayer`](/documentation/MLCompute/MLCActivationLayer/softShrink)

Creates an instance of a soft shrink activation layer.

[`class var softSign: MLCActivationLayer`](/documentation/MLCompute/MLCActivationLayer/softSign)

Creates an instance of a parametric soft sign activation layer.

[`class var tanh: MLCActivationLayer`](/documentation/MLCompute/MLCActivationLayer/tanh)

Creates an instance of a hyperbolic tangent activation layer.

[`class var tanhShrink: MLCActivationLayer`](/documentation/MLCompute/MLCActivationLayer/tanhShrink)

Creates an instance of a tanh shrink activation layer.



---

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)