Class

MLMultiArray

A multidimensional array used as a feature input or feature output for a model.

Declaration

@interface MLMultiArray : NSObject

Overview

Multidimensional arrays are commonly used to represent input and output data. Often, each dimension of a multidimensional array has an associated label or meaning. For example, Core ML neural network models use a C x H x W layout for images, where C is the number of channels, H is the height of the image, and W is the width.

When an MLMultiArray instance of a specific shape and data type is expected as input for a Core ML model, the specifications are defined in an MLMultiArrayConstraint instance associated with the feature's MLFeatureDescription.

All features with type MLFeatureTypeMultiArray must be provided as an MLMultiArray instance.

Topics

Creating a Multidimensional Array

- initWithShape:dataType:error:

Creates a multidimensional array of the given dimensions.

- initWithDataPointer:shape:dataType:strides:deallocator:error:

Creates a multidimensional array of the given dimensions with the given data.

MLMultiArrayDataType

The different types the array can hold.

Accessing Values

- objectForKeyedSubscript:

Subscript access, with an array of indexes, for the multidimensional array.

- objectAtIndexedSubscript:

Single, linear subscript access for the multidimensional array.

- setObject:atIndexedSubscript:

Assign a value, given a subscripted index.

- setObject:forKeyedSubscript:

Assign a value, given a subscripted index.

Inspecting the Multidimensional Array

count

The total number of elements in the multidimensional array.

dataType

The type of value held in the array.

shape

The array containing the sizes of each dimension of the multidimensional array.

strides

An array containing the number of data elements to step in each dimension, when traversing the array.

dataPointer

Pointer to the underlying buffer holding the elements of the array.

Relationships

Inherits From

See Also

Accessing the Value

undefined

A Boolean value indicating whether the feature value is undefined.

int64Value

The integer wrapped in this feature value.

doubleValue

The double wrapped in this feature value.

stringValue

The string wrapped in this feature value.

dictionaryValue

The dictionary wrapped in this feature value.

imageBufferValue

The image, or pixelBuffer, wrapped in this feature value.

multiArrayValue

The multidimensional array wrapped in this feature value.

sequenceValue

The sequence wrapped in this feature value.

MLSequence

A sequence of data used as a feature input or feature output for a model.