one_hot¶
- dragon.vm.tensorflow.- one_hot(
 indices,
 depth,
 on_value=1,
 off_value=0,
 name=None
 )[source]¶
- Return the one-hot representation of input. \[\text{out}_{ij} = \begin{cases} \text{off\_value}, & \text{ if } \text{input}_{i} \neq j \\ \text{on\_value}, & \text{ otherwise } \end{cases} \]- The max value of input, i.e., the - depthshould be specified:- x = tf.constant([0, 1, 2, 3], tf.int64) print(tf.one_hot(x, depth=5)) # depth >= 4 will be ok - Use - on_valueor- off_valuecustom filling:- print(tf.one_hot(x, depth=4, on_value=2, off_value=3)) - Parameters:
- indices (dragon.Tensor) – The input tensor.
- depth (int) – The depth of representation.
- on_value (int, optional, default=1) – The value for equal branch.
- off_value (int, optional, default=0) – The value for not-equal branch.
- name (str, optional) – The operation name.
 
 - Returns:
- dragon.Tensor – The output tensor. 
 
