init(concatenating:alongAxis:)
Concatenates tensors along the axis dimension.
Declaration
init(concatenating tensors: some Collection<MLTensor>, alongAxis axis: Int = 0)Parameters
- tensors:
The tensors to concatenate. All tensors must have the same rank and all dimensions except
axismust be equal. - axis:
The axis along which to concatenate. Negative values wrap around but must be in the range
[-rank, rank), whererankis the rank of the provided tensors.
Discussion
For example:
// t1 is [[1, 2, 3], [4, 5, 6]]
// t2 is [[7, 8, 9], [10, 11, 12]]
MLTensor(concatenating: [t1, t2]) // is [[1, 2, 3], [4, 5, 6], [7, 8, 9], [10, 11, 12]]
MLTensor(concatenating: [t1, t2], alongAxis: 1) // is [[1, 2, 3, 7, 8, 9], [4, 5, 6, 10, 11, 12]]
// t3 has shape [2, 3]
// t4 has shape [2, 3]
MLTensor(concatenating: [t3, t4]) // has shape [4, 3]
MLTensor(concatenating: [t3, t4], alongAxis: 1) // has shape [2, 6]See Also
Creating a tensor
init(_:)init(_:alongAxis:)init(_:scalarType:)init(bytesNoCopy:shape:scalarType:deallocator:)init(linearSpaceFrom:through:count:)init(linearSpaceFrom:through:count:scalarType:)init(ones:scalarType:)init(randomNormal:mean:standardDeviation:seed:scalarType:)init(randomUniform:in:seed:scalarType:)init(rangeFrom:to:by:)init(rangeFrom:to:by:scalarType:)init(repeating:shape:)init(repeating:shape:scalarType:)init(shape:data:scalarType:)init(shape:scalars:)