resized(to:method:)
Resize the tensor’s spatial dimensions to size using the specified method.
Declaration
func resized(to size: (newHeight: Int, newWidth: Int), method: MLTensor.ResizeMethod = .nearestNeighbor) -> MLTensorParameters
- size:
The new size for the spatial dimensions of the tensor. The size must be positive.
- method:
The resize method. The default value is
.nearest.
Discussion
For example:
let image = MLTensor(shape: [1, 1, 2, 2], scalars: [
1, 0,
0, 1
], scalarType: Float.self)
let resizedImage = image.resized(to: (4, 4), method: .nearest)
// [[[[1, 1, 0, 0],
// [1, 1, 0, 0],
// [0, 0, 1, 1],
// [0, 0, 1, 1]]]]The tensor must be either a 4-dimensional float tensor of shape [batch, channels, height, width] or 3-dimensional float tensor of shape [channel, height, width].