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


protocol MLCustomLayer


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.


Creating a Layer

init(parameters: [String : Any])

Initializes the custom layer implementation.


Integrating a Layer

func setWeightData([Data])

Assigns the weights for the connections within the layer.


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

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


Evaluating a Layer

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

Evaluates the custom layer with the given inputs.


See Also


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.

Beta Software

This documentation contains preliminary information about an API or technology in development. This information is subject to change, and software implemented according to this documentation should be tested with final operating system software.

Learn more about using Apple's beta software