<!--
{
  "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:)",
  "metadataVersion" : "0.1.0",
  "role" : "Initializer",
  "symbol" : {
    "kind" : "Initializer",
    "modules" : [
      "ML Compute"
    ],
    "preciseIdentifier" : "c:objc(cs)MLCActivationDescriptor(cm)descriptorWithType:a:"
  },
  "title" : "init(type:a:)"
}
-->

# init(type:a:)

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

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

## Parameters

`activationType`

A type of activation function.

`a`

Parameter a.

## Discussion

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

- CELU: `f(x) = max(0, x) + min(0, a * (exp(x / a) − 1))`

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

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

- HardShrink: `f(x) = x`, if `x > a` or `x < −a`, else `0`

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

For common behavior, set `a` to `0.5`.

- Parametric ELU: `f(x) = x >= 0 ? x : a * (exp(x) - 1)`

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

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

- ReLU: `f(x) = x >= 0 ? x : a * x`

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

This is also referred to as Leaky ReLU. Some literature defines classical ReLU as `max(0, x)`. If you want this common behavior, set `a` to `0.0`.

- SoftShrink: `f(x) = x - a`, if `x > a, x + a`, if `x < −a`, else `0`

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

For common behavior, set `a` to `0.5`.

---

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)