mlx_graphs.utils.array_ops.one_hot#
- mlx_graphs.utils.array_ops.one_hot(labels: mlx.core.array, num_classes: int | None = None) mlx.core.array [source]#
Creates one-hot encoded vectors for all elements provided in labels.
Given an array of labels [num_elements,], returns an array with shape [num_elements, num_classes]where each column is an all-zero vector with a one at the index of the label.
- Parameters:
- Return type:
- Returns:
An array of shape [num_elements, num_classes] with one-hot encoded vectors.