One-hot encodes the given indices.
Each index in the integer input x is encoded as a vector of zeros of length numClasses, with a 1 at the index position specified by its value.
x
numClasses
import { nn, numpy as np } from '@jax-js/jax';nn.oneHot(np.array([1, 1, 2], { dtype: np.int32 }), 3);// Output:// [[0, 1, 0],// [0, 1, 0],// [0, 0, 1]] Copy
import { nn, numpy as np } from '@jax-js/jax';nn.oneHot(np.array([1, 1, 2], { dtype: np.int32 }), 3);// Output:// [[0, 1, 0],// [0, 1, 0],// [0, 0, 1]]
One-hot encodes the given indices.
Each index in the integer input
xis encoded as a vector of zeros of lengthnumClasses, with a 1 at the index position specified by its value.