<!--
{
  "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/MLCTrainingGraph/init(graphObjects:lossLayer:optimizer:)",
  "metadataVersion" : "0.1.0",
  "role" : "Initializer",
  "symbol" : {
    "kind" : "Initializer",
    "modules" : [
      "ML Compute"
    ],
    "preciseIdentifier" : "c:objc(cs)MLCTrainingGraph(cm)graphWithGraphObjects:lossLayer:optimizer:"
  },
  "title" : "init(graphObjects:lossLayer:optimizer:)"
}
-->

# init(graphObjects:lossLayer:optimizer:)

Creates a training graph with the layers from the graph objects, loss layer, and optimizer you specify.

```
convenience init(graphObjects: [MLCGraph], lossLayer: MLCLayer?, optimizer: MLCOptimizer?)
```

## Parameters

`graphObjects`

The graph objects whose layers you add to the training graph.

`lossLayer`

The loss layer.

`optimizer`

The optimizer.

## Discussion

You can also add a loss layer to a training graph using the [`node(with:sources:lossLabels:)`](/documentation/MLCompute/MLCGraph/node(with:sources:lossLabels:)) method.

---

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)