DeepLearning - Maple Programming Help

Online Help

All Products    Maple    MapleSim


Home : Support : Online Help : Programming : DeepLearning Package : Tensors : Managing Tensors : DeepLearning/OneHot

DeepLearning

  

OneHot

  

construct a one-hot Tensor

 

Calling Sequence

Parameters

Options

Description

Details

Examples

Compatibility

Calling Sequence

OneHot(indices,depth,opts)

Parameters

indices

-

list of integers

depth

-

integer

opts

-

(optional) options as specified below

Options

• 

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.

Description

• 

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](..).

Details

• 

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.

Examples

withDeepLearning&colon;

tOneHot0&comma;1&comma;2&comma;3&comma;on_value=3.0&comma;off_value=0.

tDeepLearning TensorName: one_hot:0Shape: [3, 3]Data Type: float[4]

(1)

Shapet

3&comma;3

(2)

Compatibility

• 

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