MLMultiArray
A machine learning collection type that stores numeric values in an array with multiple dimensions.
Declaration
class MLMultiArrayMentioned in
Overview
A multidimensional array, or multiarray, is one of the underlying types of an MLFeatureValue that stores numeric values in multiple dimensions. All elements in an MLMultiArray instance are one of the same type, and one of the types that MLMultiArrayDataType defines:
- MLMultiArrayDataType.int32
32-bit integer
- MLMultiArrayDataType.float16
16-bit floating point number
- MLMultiArrayDataType.float32
32-bit floating point number (also known as float)
- float64
64-bit floating point number (also known as
doublein Swift orMLMultiArrayDataTypeDoublein Objective-C)
Each dimension in a multiarray is typically significant or meaningful. For example, a model could have an input that accepts images as a multiarray of pixels with three dimensions, C x H x W. The first dimension, C,_ _represents the number of color channels, and the second and third dimensions, H and W, represent the image’s height and width, respectively. The number of dimensions and size of each dimension define the multiarray’s shape.
The shape property is an integer array that has an element for each dimension in the multiarray. Each element in shape defines the size of the corresponding dimension. To inspect the shape and constraints of a model’s multiarray input or output feature:
Access the model’s modelDescription property.
Find the multiarray input or output feature in the model description’s inputDescriptionsByName or outputDescriptionsByName property, respectively.
Access the feature description’s multiArrayConstraint property.
Inspect the multiarray constraint’s shape and shapeConstraint.
Topics
Creating a multiarray
init(_:)init(shape:dataType:)init(shape:dataType:strides:)init(dataPointer:shape:dataType:strides:deallocator:)init(byConcatenatingMultiArrays:alongAxis:dataType:)init(pixelBuffer:shape:)MLMultiArrayDataType
Inspecting a multiarray
Transfering the contents
Providing buffer access
withUnsafeBufferPointer(ofType:_:)withUnsafeBytes(_:)withUnsafeMutableBufferPointer(ofType:_:)withUnsafeMutableBytes(_:)