-
-
Notifications
You must be signed in to change notification settings - Fork 615
Closed
Labels
Description
Could we generalize onehot encoding in Flux to more than one or two dimensions? In general, we can have an N
dimensional binary array, where the first dimension always has exactly one bit on and the rest are off. This represents a onehot encoding of an N-1
dimensional array where each entry is a category.
An application is a sequence of length L
where each site can be one of q
letters. Then one sequence can be onehot encoded as a q * L
matrix. But to encode a batch of B
sequences, we need a multi-dimensional q * L * B
array.
One possible implementation: https://github.com/cossio/OneHot.jl/blob/master/src/array.jl.
I can make a PR if people agree this can be useful in general.
azev77