<!--
{
  "availability" : [
    "iOS: 14.0.0 - 17.0.0",
    "iPadOS: 14.0.0 - 17.0.0",
    "macCatalyst: 14.0.0 - 17.0.0",
    "macOS: 11.0.0 - 14.0.0",
    "tvOS: 14.0.0 - 17.0.0"
  ],
  "documentType" : "symbol",
  "framework" : "MLCompute",
  "identifier" : "/documentation/MLCompute/MLCTensor/init(shape:randomInitializerType:)",
  "metadataVersion" : "0.1.0",
  "role" : "Initializer",
  "symbol" : {
    "kind" : "Initializer",
    "modules" : [
      "ML Compute",
      "MLCompute"
    ],
    "preciseIdentifier" : "s:So9MLCTensorC9MLComputeE5shape21randomInitializerTypeABSaySiG_So09MLCRandomeF0Vtcfc"
  },
  "title" : "init(shape:randomInitializerType:)"
}
-->

# init(shape:randomInitializerType:)

Creates a tensor with the shape and random initializer type you specify.

```
convenience init(shape: [Int], randomInitializerType: MLCRandomInitializerType)
```

## Parameters

`shape`

An array that contains the sizes of each dimension.

`randomInitializerType`

The random initializer type you use to generate random data.

---

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)