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

# expandingShape(at:)

Returns a new shaped array with expanded dimensions.

```
func expandingShape(at axis: Int) -> MLShapedArray<Scalar>
```

## Discussion

The shape of the new `MLShapedArray` gets a new dimension of 1 at the specified axis index.

```swift
let original = MLShapedArray<Int32>(scalars: 0..., shape: [2, 3])
let expanded = original.expandingShape(at: 0)
expanded.shape // [1, 2, 3]
```

---

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)