nvidia.dali.experimental.dynamic.random.uniform#

nvidia.dali.experimental.dynamic.random.uniform(shape_like=None, /, *, batch_size=None, device=None, dtype=None, range=None, seed=None, shape=None, values=None, rng=None)#

Generates random numbers following a uniform distribution.

It can be configured to produce a continuous uniform distribution in the range [min, max), or a discrete uniform distribution where any of the specified values [v0, v1, …, vn] occur with equal probability.

The shape of the generated data can be either specified explicitly with a shape argument, or chosen to match the shape of the __shape_like input, if provided. If none are present, a single value per sample is generated.

Supported backends
  • ‘cpu’

  • ‘gpu’

Parameters:

shape_like (Tensor/Batch, optional) – Shape of this input will be used to infer the shape of the output, if provided.

Keyword Arguments:
  • dtype (nvidia.dali.types.DALIDataType, optional) –

    Output data type.

    Note

    The generated numbers are converted to the output data type, rounding and clamping if necessary.

  • range (float or list of float or Tensor/Batch of float, optional, default = [-1.0, 1.0]) –

    Range [min, max) of a continuous uniform distribution.

    This argument is mutually exclusive with values.

    Warning

    When specifying an integer type as dtype, the generated numbers can go outside the specified range, due to rounding.

  • shape (int or list of int or Tensor/Batch of int, optional) – Shape of the output data.

  • values (float or list of float or Tensor/Batch of float, optional) –

    The discrete values [v0, v1, …, vn] produced by a discrete uniform distribution.

    This argument is mutually exclusive with range.

  • rng (RNG, optional) – A random number generator instance. Can be obtained by calling nvidia.dali.experimental.dynamic.random.RNG(seed)(). If not provided, the default RNG is used.