grenade-0.1.0: Practical Deep Learning in Haskell

Safe HaskellNone
LanguageHaskell98

Grenade.Utils.OneHot

Synopsis

Documentation

oneHot :: forall n. KnownNat n => Int -> Maybe (S (D1 n)) Source #

From an int which is hot, create a 1D Shape with one index hot (1) with the rest 0. Rerurns Nothing if the hot number is larger than the length of the vector.

hotMap :: (Ord a, KnownNat n) => Proxy n -> [a] -> Maybe (Map a Int, Vector a) Source #

Create a one hot map from any enumerable. Returns a map, and the ordered list for the reverse transformation

makeHot :: forall a n. (Ord a, KnownNat n) => Map a Int -> a -> Maybe (S (D1 n)) Source #

From a map and value, create a 1D Shape with one index hot (1) with the rest 0. Rerurns Nothing if the hot number is larger than the length of the vector or the map doesn't contain the value.

unHot :: forall a n. KnownNat n => Vector a -> S (D1 n) -> Maybe a Source #

sample :: forall a n m. (KnownNat n, MonadRandom m) => Double -> Vector a -> S (D1 n) -> m a Source #