tf.random.shuffle  |  TensorFlow v2.16.1 (original) (raw)

Randomly shuffles a tensor along its first dimension.

View aliases

Compat aliases for migration

SeeMigration guide for more details.

tf.compat.v1.random.shuffle, tf.compat.v1.random_shuffle

tf.random.shuffle(
    value, seed=None, name=None
)

Used in the notebooks

Used in the guide Used in the tutorials
Quickstart for the TensorFlow Core APIs Generalized Linear Models

The tensor is shuffled along dimension 0, such that each value[j] is mapped to one and only one output[i]. For example, a mapping that might occur for a 3x2 tensor is:

[[1, 2],       [[5, 6],
 [3, 4],  ==>   [1, 2],
 [5, 6]]        [3, 4]]
Args
value A Tensor to be shuffled.
seed A Python integer. Used to create a random seed for the distribution. Seetf.random.set_seedfor behavior.
name A name for the operation (optional).
Returns
A tensor of same shape and type as value, shuffled along its first dimension.