DeepLearning
OneHot
construct a one-hot Tensor
Calling Sequence
Parameters
Options
Description
Details
Examples
Compatibility
OneHot(indices,depth,opts)
indices
-
list of integers
depth
integer
opts
(optional) options as specified below
axis = integer
The axis to fill (default: -1, a new inner-most axis).
datatype = one of string,truefalse,integer[4],integer[8],float[4],float[8],complex[4], or complex[8]
The value of option datatype specifies the type of data this Tensor will hold. By default, the datatype is inferred from on_value or off_value.
off_value = scalar
The value to fill in output when indices[j] <> i (default: 0). If a datatype was specified, this value must be compatible with that type.
on_value = scalar
The value to fill in output when indices[j] = i (default: 1). If a datatype was specified, this value must be compatible with that type.
name = string
The value of option name specifies an optional name for this Tensor, to be displayed in output and when visualizing the dataflow graph.
The OneHot(indices,depth,opts) command creates a one-hot Tensor in the active dataflow graph. The term "one-hot" comes from digital circuits and refers to a configuration where every bit in a collection is turned off, except one.
In the Tensor returned, the locations represented by indices take value on_value, while all other locations take value off_value.
If the input indices is rank n, the output will have rank n+1. The new axis is created at the dimension specified by axis. By default, the new axis is appended at the end.
These functions are part of the DeepLearning package, so they can can be used in the short form OneHot(..) only after executing the command with(DeepLearning). However, can always be accessed through the long form of the command by using DeepLearning[OneHot](..).
The implementation of EinsteinSummation uses the tf.one_hot command from the TensorFlow Python API. Consult the TensorFlow Python API documentation for tf.one_hot for more information.
with⁡DeepLearning:
t≔OneHot⁡0,1,2,3,on_value=3.0,off_value=0.
t≔DeepLearning TensorShape: [3, 3]Data Type: float[4]
Shape⁡t
3,3
The DeepLearning[OneHot] command was introduced in Maple 2018.
For more information on Maple 2018 changes, see Updates in Maple 2018.
See Also
DeepLearning Overview
Download Help Document