Skip to contents

Create one-hot encoding vector as a LazyTensor object.

Usage

one_hot(x, D)

Arguments

x

A LazyTensor encoding a scalar value.

D

an integer corresponding to the output dimension.

Value

a LazyTensor.

Details

If x is a scalar value encoded as a LazyTensor, one_hot(x, D) encodes, symbolically, a vector of length D where round(x)-th coordinate is equal to 1, and the other ones to 0.

Author

Chloe Serre-Combe, Amelie Vernay

Examples

if (FALSE) {
A <- 7
A_LT <- LazyTensor(A) # LazyTensor from scalar A
D <- 7

onehot_x <- one_hot(A_LT, D) # symbolic vector of length D
}