nvidia.dali.experimental.dynamic.random.choice#
- nvidia.dali.experimental.dynamic.random.choice(a, shape_like=None, /, *, batch_size=None, device=None, p=None, seed=None, shape=None, rng=None)#
Generates a random sample from a given 1D array.
The probability of selecting a sample from the input is determined by the corresponding probability specified in
pargument.The shape of the generated data can be either specified explicitly with a
shapeargument, or chosen to match the shape of the __shape_like input, if provided. If none are present, a single value per sample is generated.The type of the output matches the type of the input. For scalar inputs, only integral types are supported, otherwise any type can be used. The operator supports selection from an input containing elements of one of DALI enum types, that is:
nvidia.dali.types.DALIDataType(),nvidia.dali.types.DALIImageType(), ornvidia.dali.types.DALIInterpType().- Supported backends
‘cpu’
- Parameters:
a¶ (scalar or Tensor/Batch) – If a scalar value __a is provided, the operator behaves as if
[0, 1, ..., __a-1]list was passed as input. Otherwise __a is treated as 1D array of input samples.shape_like¶ (Tensor/Batch, optional) – Shape of this input will be used to infer the shape of the output, if provided.
- Keyword Arguments:
p¶ (float or list of float or Tensor/Batch of float, optional) – Distribution of the probabilities. If not specified, uniform distribution is assumed.
shape¶ (int or list of int or Tensor/Batch of int, optional) – Shape of the output data.
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.