Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Model ¶
type Model struct { nn.Module UseRefinedGates bool // Input gate WIn *nn.Param WInRec *nn.Param BIn *nn.Param // Output gate WOut *nn.Param WOutRec *nn.Param BOut *nn.Param // Forget gate WFor *nn.Param WForRec *nn.Param BFor *nn.Param // Candiate gate WCand *nn.Param WCandRec *nn.Param BCand *nn.Param }
Model contains the serializable parameters.
func (*Model) Forward ¶
Forward performs the forward step for each input node and returns the result.
func (*Model) Init ¶ added in v1.1.0
func (m *Model) Init(rndGen *rand.LockedRand) *Model
Init initializes the parameters using Xavier uniform randomization. It follows the LSTM bias hack setting the Forget gate to 1 (http://proceedings.mlr.press/v37/jozefowicz15.pdf).
func (*Model) Next ¶
Next performs a single forward step, producing a new state.
It computes the results with the following equations: inG = sigmoid(wIn (dot) x + bIn + wInRec (dot) yPrev) outG = sigmoid(wOut (dot) x + bOut + wOutRec (dot) yPrev) forG = sigmoid(wFor (dot) x + bFor + wForRec (dot) yPrev) cand = f(wCand (dot) x + bC + wCandRec (dot) yPrev) cell = inG * cand + forG * cellPrev y = outG * f(cell)
func (*Model) WithRefinedGates ¶
WithRefinedGates sets whether to use refined gates. Refined Gate: A Simple and Effective Gating Mechanism for Recurrent Units (https://arxiv.org/pdf/2002.11338.pdf)
Refined gates setting requires input size and output size be the same.