---
title: "reshaped(to:)"
framework: coreml
role: symbol
role_heading: Instance Method
path: "coreml/mlshapedarray/reshaped(to:)"
---

# reshaped(to:)

Returns a new reshaped shaped array.

## Declaration

```swift
func reshaped(to newShape: [Int]) -> MLShapedArray<Scalar>
```

## Parameters

- `newShape`: The new shape after reshaping.

## Discussion

Discussion The reshaped array gets scalars of the original array in first-major order. Therefore, the initializer is semantically equivalent to: let reshaped = MLShapedArray(scalars: original.scalars, shape: newShape) Usage example: let original = MLShapedArray<Int32>(scalars: 0..., shape: [4]) let reshaped = original.reshaping(to: [1, 2, 2]) A scalar can be reshaped to and from a shape where the product of dimensions is one. The method raises a runtime error if the product of dimensions in the new shape is different from the current one.

## See Also

### Shaping the array

- [changingLayout(to:)](coreml/mlshapedarray/changinglayout(to:).md)
- [expandingShape(at:)](coreml/mlshapedarray/expandingshape(at:).md)
- [squeezingShape()](coreml/mlshapedarray/squeezingshape().md)
- [transposed()](coreml/mlshapedarray/transposed().md)
- [transposed(permutation:)](coreml/mlshapedarray/transposed(permutation:).md)
