<!--
{
  "availability" : [
    "iOS: 18.0.0 -",
    "iPadOS: 18.0.0 -",
    "macCatalyst: 18.0.0 -",
    "macOS: 15.0.0 -",
    "tvOS: 18.0.0 -",
    "visionOS: 2.0.0 -",
    "watchOS: 11.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "CoreML",
  "identifier" : "/documentation/CoreML/MLTensor/resized(to:method:)",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "Core ML",
      "CoreML"
    ],
    "preciseIdentifier" : "s:6CoreML8MLTensorV7resized2to6methodACSi9newHeight_Si0G5Widtht_AC12ResizeMethodOtF"
  },
  "title" : "resized(to:method:)"
}
-->

# resized(to:method:)

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

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

For example:

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

---

Copyright &copy; 2026 Apple Inc. All rights reserved. | [Terms of Use](https://www.apple.com/legal/internet-services/terms/site.html) | [Privacy Policy](https://www.apple.com/privacy/privacy-policy)