deepmd.tf.utils.random

Alias for backward compatibility.

Module Contents

Functions

choice(a[, size, replace, p])

Generates a random sample from a given 1-D array.

random([size])

Return random floats in the half-open interval [0.0, 1.0).

seed([val])

Seed the generator.

shuffle(x)

Modify a sequence in-place by shuffling its contents.

deepmd.tf.utils.random.choice(a: numpy.ndarray | int, size: int | Tuple[int, Ellipsis] | None = None, replace: bool = True, p: numpy.ndarray | None = None)[source]

Generates a random sample from a given 1-D array.

Parameters:
a1-D array_like or int

If an ndarray, a random sample is generated from its elements. If an int, the random sample is generated as if it were np.arange(a)

sizeint or tuple of ints, optional

Output shape. If the given shape is, e.g., (m, n, k), then m * n * k samples are drawn. Default is None, in which case a single value is returned.

replacebool, optional

Whether the sample is with or without replacement. Default is True, meaning that a value of a can be selected multiple times.

p1-D array_like, optional

The probabilities associated with each entry in a. If not given, the sample assumes a uniform distribution over all entries in a.

Returns:
np.ndarray

arrays with results and their shapes

deepmd.tf.utils.random.random(size=None)[source]

Return random floats in the half-open interval [0.0, 1.0).

Parameters:
size

Output shape.

Returns:
np.ndarray

Arrays with results and their shapes.

deepmd.tf.utils.random.seed(val: int | None = None)[source]

Seed the generator.

Parameters:
valint

Seed.

deepmd.tf.utils.random.shuffle(x: numpy.ndarray)[source]

Modify a sequence in-place by shuffling its contents.

Parameters:
xnp.ndarray

The array or list to be shuffled.