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 a tensor with rank
N+1 extending the original tensor with a new dimension at the
axis position. The 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. The population is made in the following way:
output[:, ... ,:, i, :, ... ,:] = on_value if (indices[:, ..., :, :, ..., :] == i) else off_value
i is at the
axis position in the
output shape and has values from the range
[0, ..., depth-1].
When some elements from the
indices are greater or equal to the
depth, it is a well-formed operation. The corresponding output rows are populated with
off_value in this case.
The types of input scalars
off_value should match and be equal to any supported type. The output tensor type is derived from the
on_value or the
off_value, they all have the same type.
indices: input tensor of type T1 with non-negative indices, behavior for negative indices is undefined. Can be 0D. Required.
depth: positive scalar (0D tensor) of type T1 that specifies the number of classes and thus the size of the one-hot dimension. Required.
on_value: scalar (0D tensor) of type T2 that fills the locations in output tensor specified in
off_value: scalar (0D tensor) of type T2 that fills the locations not represented in
N+1rank tensor of type T2, where
Nis a rank of the input tensor
indices. A new axis of the size
depthis inserted at the dimension