grenade-0.1.0: Practical Deep Learning in Haskell

Safe HaskellNone
LanguageHaskell98

Grenade.Recurrent.Core.Layer

Synopsis

Documentation

class (RecurrentUpdateLayer x, SingI (RecurrentShape x)) => RecurrentLayer x i o where Source #

Minimal complete definition

runRecurrentForwards, runRecurrentBackwards

Associated Types

type RecTape x i o :: * Source #

Wengert Tape

Methods

runRecurrentForwards :: x -> S (RecurrentShape x) -> S i -> (RecTape x i o, S (RecurrentShape x), S o) Source #

Used in training and scoring. Take the input from the previous layer, and give the output from this layer.

runRecurrentBackwards :: x -> RecTape x i o -> S (RecurrentShape x) -> S o -> (Gradient x, S (RecurrentShape x), S i) Source #

Back propagate a step. Takes the current layer, the input that the layer gave from the input and the back propagated derivatives from the layer above. Returns the gradient layer and the derivatives to push back further.

Instances

(KnownNat i, KnownNat o, KnownNat ((+) i o), (<=) i ((+) i o), (~) Nat o ((-) ((+) i o) i)) => RecurrentLayer (BasicRecurrent i o) (D1 i) (D1 o) Source # 

Associated Types

type RecTape (BasicRecurrent i o) (D1 i :: Shape) (D1 o :: Shape) :: * Source #

(KnownNat i, KnownNat o) => RecurrentLayer (LSTM i o) (D1 i) (D1 o) Source # 

Associated Types

type RecTape (LSTM i o) (D1 i :: Shape) (D1 o :: Shape) :: * Source #

Methods

runRecurrentForwards :: LSTM i o -> S (RecurrentShape (LSTM i o)) -> S (D1 i) -> (RecTape (LSTM i o) (D1 i) (D1 o), S (RecurrentShape (LSTM i o)), S (D1 o)) Source #

runRecurrentBackwards :: LSTM i o -> RecTape (LSTM i o) (D1 i) (D1 o) -> S (RecurrentShape (LSTM i o)) -> S (D1 o) -> (Gradient (LSTM i o), S (RecurrentShape (LSTM i o)), S (D1 i)) Source #

class UpdateLayer x => RecurrentUpdateLayer x Source #

Class for a recurrent layer. It's quite similar to a normal layer but for the input and output of an extra recurrent data shape.

Associated Types

type RecurrentShape x :: Shape Source #

Shape of data that is passed between each subsequent run of the layer

Instances

(KnownNat i, KnownNat o, KnownNat ((+) i o), (<=) i ((+) i o), (~) Nat o ((-) ((+) i o) i)) => RecurrentUpdateLayer (BasicRecurrent i o) Source # 

Associated Types

type RecurrentShape (BasicRecurrent i o) :: Shape Source #

(KnownNat i, KnownNat o) => RecurrentUpdateLayer (LSTM i o) Source # 

Associated Types

type RecurrentShape (LSTM i o) :: Shape Source #