init(byConcatenatingMultiArrays:alongAxis:dataType:)
Merges an array of multiarrays into one multiarray along an axis.
Declaration
convenience init(byConcatenatingMultiArrays multiArrays: [MLMultiArray], alongAxis axis: Int, dataType: MLMultiArrayDataType)Parameters
- multiArrays:
An Mlmultiarray array.
- axis:
A zero-based axis number the instances in
multiArraymerge along. - dataType:
An Mlmultiarraydatatype instance that represents the underlying type of all the instances in
multiArrays.
Discussion
All multiarray instances in multiArrays must have:
The same data type
The same number of dimensions
The same size for each corresponding dimension, except for the concatenation axis
For example, this code concatenates two multiarrays along their first dimension:
let multiarray1 = try MLMultiArray(shape: [1, 5, 7], dataType: .int32)
let multiarray2 = try MLMultiArray(shape: [2, 5, 7], dataType: .int32)
// Merge the two multiarrays along the first dimension.
let multiArray3 = MLMultiArray(concatenating: [multiarray1, multiarray2],
axis: 0,
dataType: .int32)
assert(multiArray3.shape == [3, 5, 7])