Protocol

MLCustomLayer

An interface that defines the behavior of a custom layer in your neural network model.

Declaration

protocol MLCustomLayer

Overview

You use the MLCustomLayer protocol to define the behavior of your own neural network layers in Core ML models. You can deploy novel or proprietary models on your own release schedule. Custom layers also provide a mechanism for pre- or post-processing during model evaluation.

Topics

Creating a Layer

init(parameters: [String : Any])

Initializes the custom layer implementation.

Required.

Integrating a Layer

func setWeightData([Data])

Assigns the weights for the connections within the layer.

Required.

func outputShapes(forInputShapes: [[NSNumber]]) -> [[NSNumber]]

Calculates the shapes of the output of this layer for the given input shapes.

Required.

Evaluating a Layer

func evaluate(inputs: [MLMultiArray], outputs: [MLMultiArray])

Evaluates the custom layer with the given inputs.

Required.

See Also

Customization

Integrating Custom Layers

Integrate custom neural network layers into your Core ML app.

Creating a Custom Layer

Make your own custom layer for Core ML models.

protocol MLCustomModel

An interface that defines the behavior of a custom model.