---
title: "init(graphObjects:lossLayer:optimizer:)"
framework: ML Compute
role: symbol
role_heading: Initializer
platforms: [iOS 14.0+, iPadOS 14.0+, Mac Catalyst 14.0+, macOS 11.0+, tvOS 14.0+]
path: "mlcompute/mlctraininggraph/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.

## Declaration

```swift
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

Discussion You can also add a loss layer to a training graph using the node(with:sources:lossLabels:) method.

## See Also

### Creating Training Graphs

- [Optimizers](mlcompute/optimizers.md)
- [MLCTensorParameter](mlcompute/mlctensorparameter.md)
