<!--
{
  "availability" : [
    "iOS: 14.0.0 - 17.4.0",
    "iPadOS: 14.0.0 - 17.4.0",
    "macCatalyst: 14.0.0 - 17.4.0",
    "macOS: 11.0.0 - 14.3.0",
    "tvOS: 14.0.0 - 17.4.0"
  ],
  "documentType" : "symbol",
  "framework" : "MLCompute",
  "identifier" : "/documentation/MLCompute/MLCActivationDescriptor/init(type:a:b:)",
  "metadataVersion" : "0.1.0",
  "role" : "Initializer",
  "symbol" : {
    "kind" : "Initializer",
    "modules" : [
      "ML Compute"
    ],
    "preciseIdentifier" : "c:objc(cs)MLCActivationDescriptor(cm)descriptorWithType:a:b:"
  },
  "title" : "init(type:a:b:)"
}
-->

# init(type:a:b:)

Creates an activation descriptor with the activation type and parameters a and b that you specify.

```
convenience init?(type activationType: MLCActivationType, a: Float, b: Float)
```

## Parameters

`activationType`

A type of activation function.

`a`

Parameter a.

`b`

Parameter b.

## Discussion

Use this initializer to create one of the following activation descriptors:

- Hard Sigmoid: `f(x) = clamp((x * a) + b, 0, 1)`

Activation type: [`MLCActivationType.hardSigmoid`](/documentation/MLCompute/MLCActivationType/hardSigmoid)

For common behavior, set `a` to `0.2` and `b` to `0.5`.

- Hyperbolic tangent (TanH): `f(x) = a * tanh(b * x)`

Activation type: [`MLCActivationType.tanh`](/documentation/MLCompute/MLCActivationType/tanh)

For common behavior, set `a` to `1.0` and `b` to `1.0`.

- Linear: `f(x) = a * x + b`

Activation type: [`MLCActivationType.linear`](/documentation/MLCompute/MLCActivationType/linear)

For common behavior, set `a` to `1.0` and `b` to `0.0`.

- Parametric Soft Plus: `f(x) = a * log(1 + e^(b * x))`

Activation type: [`MLCActivationType.softPlus`](/documentation/MLCompute/MLCActivationType/softPlus)

For common behavior, set `a` to `1.0` and `b` to `1.0`.

- ReLUN: `f(x) = min((x >= 0 ? x : a * x), b)`

Activation type: [`MLCActivationType.relun`](/documentation/MLCompute/MLCActivationType/relun)

For common behavior, set `a` to `0.0` and `b` to `6.0`.

- Threshold: `f(x) = x`, if `x > a`, else `b`, where:

`a = threshold`

`b = replacement`

Activation type: [`MLCActivationType.threshold`](/documentation/MLCompute/MLCActivationType/threshold)

---

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)