Skip to main content

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

gaussianCreates a tensor filled with random values from a Gaussian (normal) distribution.
normalAlias for gaussian().
uniformCreates a tensor filled with random values from a uniform distribution.

Seeding

seedGets the global random seed tensor.
set_seedSets the global random seed value.