<!--
{
  "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/MLCMultiheadAttentionLayer/init(descriptor:weights:biases:attentionBiases:)",
  "metadataVersion" : "0.1.0",
  "role" : "Initializer",
  "symbol" : {
    "kind" : "Initializer",
    "modules" : [
      "ML Compute"
    ],
    "preciseIdentifier" : "c:objc(cs)MLCMultiheadAttentionLayer(cm)layerWithDescriptor:weights:biases:attentionBiases:"
  },
  "title" : "init(descriptor:weights:biases:attentionBiases:)"
}
-->

# init(descriptor:weights:biases:attentionBiases:)

Creates a multi-head attention layer with the descriptor, weights, and biases you specify.

```
convenience init?(descriptor: MLCMultiheadAttentionDescriptor, weights: [MLCTensor], biases: [MLCTensor]?, attentionBiases: [MLCTensor]?)
```

## Parameters

`descriptor`

An object you use to configure the multi-head attention layer.

`weights`

An array that contains the weights that correspond to query, key, value, and output projections for all heads.

`biases`

An array that contains the biases that correspond to query, key, value, and output projections for all heads.

`attentionBiases`

An array that contains the biases you add to the key and value, respectively.

## Discussion

---

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)