---
title: "resized(to:method:)"
framework: coreml
role: symbol
role_heading: Instance Method
path: "coreml/mltensor/resized(to:method:)"
---

# resized(to:method:)

Resize the tensor’s spatial dimensions to size using the specified method.

## Declaration

```swift
func resized(to size: (newHeight: Int, newWidth: Int), method: MLTensor.ResizeMethod = .nearestNeighbor) -> MLTensor
```

## Parameters

- `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

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].

## See Also

### Resizing the tensor

- [MLTensor.ResizeMethod](coreml/mltensor/resizemethod.md)
