<!--
{
  "availability" : [
    "iOS: 14.0.0 - 18.0.0",
    "iPadOS: 14.0.0 - 18.0.0",
    "macCatalyst: 14.0.0 - 18.0.0",
    "macOS: 11.0.0 - 15.0.0",
    "tvOS: 14.0.0 - 18.0.0",
    "visionOS: 1.0.0 - 2.0.0",
    "watchOS: 7.0.0 - 11.0.0"
  ],
  "documentType" : "symbol",
  "framework" : "Accelerate",
  "identifier" : "/documentation/Accelerate/BNNSLayerParametersLossBase/init(function:i_desc:o_desc:reduction:)",
  "metadataVersion" : "0.1.0",
  "role" : "Initializer",
  "symbol" : {
    "kind" : "Initializer",
    "modules" : [
      "Accelerate"
    ],
    "preciseIdentifier" : "s:So27BNNSLayerParametersLossBasea8function6i_desc02o_F09reductionABSo16BNNSLossFunctiona_So21BNNSNDArrayDescriptoraAJSo0h9ReductionI0atcfc"
  },
  "title" : "init(function:i_desc:o_desc:reduction:)"
}
-->

# init(function:i_desc:o_desc:reduction:)

Returns a new loss layer parameters structure from the specified parameters.

```
init(function: BNNSLossFunction, i_desc: BNNSNDArrayDescriptor, o_desc: BNNSNDArrayDescriptor, reduction: BNNSLossReductionFunction)
```

## Parameters

`function`

The function that’s used to compute loss.

`i_desc`

The descriptor of the input.

`o_desc`

The descriptor of the output.

`reduction`

The function that’s used to reduce the computed loss.

## Discussion

> Important:
> The input data type and output data type must be `float`. The output size must be `1`, unless the reduction is ``doc://com.apple.accelerate/documentation/Accelerate/BNNS/LossReduction/none``.

---

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)