ivy.one_hot(indices, depth, dev_str=None, f=None)[source]

Returns a one-hot array :param indices: Indices for where the ones should be scattered [batch_shape, dim] :type indices: array :param depth: Scalar defining the depth of the one-hot dimension. :type depth: int :param dev_str: device on which to create the array ‘cuda:0’, ‘cuda:1’, ‘cpu’ etc. Same as x if None. :type dev_str: str, optional :param f: Machine learning framework. Inferred from inputs if None. :type f: ml_framework, optional :return: Tensor of zeros with the same shape and type as a, unless dtype provided which overrides.

Supported Frameworks:

empty jax_logo empty tf_logo empty pytorch_logo empty mxnet_logo empty numpy_logo empty