Category: Sequence processing
Short description: OneHot sets the elements in the output tensor with specified indices to
on_value and fills all other locations with
Taking a tensor with rank
N as the first input
indices, OneHot produces tensor with rank
N+1 extending original tensor with a new dimension at
axis position in shape. Output tensor is populated with two scalar values:
on_value that comes from the 3rd input and
off_value that comes from the 4nd input. Population is made in the following way:
output[:, ... ,:, i, :, ... ,:] = on_value if (indices[:, ..., :, :, ..., :] == i) else off_value
i is at
axis position in
output shape and has values from range
[0, ..., depth-1].
When index element from
indices is greater or equal to
depth, it is a well-formed operation. In this case the corresponding row
output[..., i, ...] is populated with
off_value only for all
Types of input scalars
off_value should match and can be any of the supported types. The type of output tensor is derived from
off_value, they all have the same type.
indices: input tensor of rank
Nwith indices of any supported integer data type. Can be 0D. Required.
depth: scalar (0D tensor) of any supported integer type that specifies number of classes and the size of one-hot dimension.
on_value: scalar (0D tensor) of any type that is the value that the locations in output tensor represented by indices in input take.
off_value: scalar (0D tensor) of any type that is the value that the locations not represented by indices in input take.
Nis a rank of input tensor
indices. A new axis of the size
depthis inserted at the dimension