Python module
max.experimental.random
Provides random tensor generation utilities.
This module provides functions for generating random tensors with various distributions. All functions support specifying data type and device, with sensible defaults based on the target device.
You can generate random tensors using different distributions:
from max.experimental import random
from max.dtype import DType
from max.driver import CPU
# Generate 2x3 tensor with values between 0 and 1
tensor1 = random.uniform((2, 3), dtype=DType.float32, device=CPU())
tensor2 = random.uniform((4, 4), range=(0, 1), dtype=DType.float32, device=CPU())Random generation
gaussian | Creates a tensor filled with random values from a Gaussian (normal) distribution. |
|---|---|
normal | Alias for gaussian(). |
uniform | Creates a tensor filled with random values from a uniform distribution. |
Seeding
seed | Gets the global random seed tensor. |
|---|---|
set_seed | Sets the global random seed value. |
Was this page helpful?
Thank you! We'll create more content like this.
Thank you for helping us improve!