CFNCell
LuxRecurrentLayers.CFNCell — TypeCFNCell(in_dims => out_dims, [activation];
use_bias=true, use_recurrent_bias=true, train_state=false, init_bias=nothing,
init_recurrent_bias=nothing, init_weight=nothing,
init_recurrent_weight=nothing, init_state=zeros32)Equations
\[\begin{aligned} \boldsymbol{\theta}(t) &= \sigma\left(\mathbf{W}_{ih}^{\theta} \mathbf{x}(t) + \mathbf{b}_{ih}^{\theta} + \mathbf{W}_{hh}^{\theta} \mathbf{h}(t-1) + \mathbf{b}_{hh}^{\theta}\right) \\ \boldsymbol{\eta}(t) &= \sigma\left(\mathbf{W}_{ih}^{\eta} \mathbf{x}(t) + \mathbf{b}_{ih}^{\eta} + \mathbf{W}_{hh}^{\eta} \mathbf{h}(t-1) + \mathbf{b}_{hh}^{\eta} \right) \\ \mathbf{h}(t) &= \boldsymbol{\theta}(t) \circ \tanh(\mathbf{h}(t-1)) + \boldsymbol{\eta}(t) \circ \tanh(\mathbf{W}_{ih}^h \mathbf{x}(t) + \mathbf{b}_{ih}^{h}) \end{aligned}\]
Arguments
in_dims: Input Dimensionout_dims: Output (Hidden State & Memory) Dimensionactivation: activation function. Default istanh
Keyword arguments
use_bias: Flag to use bias $\mathbf{b}_{ih}$ in the computation. Default set totrue.use_recurrent_bias: Flag to use recurrent bias $\mathbf{b}_{hh}$ in the computation. Default set totrue.train_state: Flag to set the initial hidden state as trainable. Default set tofalse.init_bias: Initializer for input to hidden bias $\mathbf{b}_{ih}^{\theta}, \mathbf{b}_{ih}^{\eta}, \mathbf{b}_{ih}^{h}$. Must be a tuple containing 3 functions, e.g.,(glorot_normal, kaiming_uniform). If a single functionfnis provided, it is automatically expanded into a 3-element tuple (fn, fn, fn). If set tonothing, weights are initialized from a uniform distribution within[-bound, bound]wherebound = inv(sqrt(out_dims)). Default isnothing.init_recurrent_bias: Initializer for hidden to hidden bias $\mathbf{b}_{hh}^{\theta}, \mathbf{b}_{hh}^{\eta}$. Must be a tuple containing 2 functions, e.g.,(glorot_normal, kaiming_uniform). If a single functionfnis provided, it is automatically expanded into a 2-element tuple (fn, fn). If set tonothing, weights are initialized from a uniform distribution within[-bound, bound]wherebound = inv(sqrt(out_dims)). Default isnothing.init_weight: Initializer for input to hidden weights $\mathbf{W}_{ih}^{\theta}, \mathbf{W}_{ih}^{\eta}, \mathbf{W}_{ih}^{h}$. Must be a tuple containing 3 functions, e.g.,(glorot_normal, kaiming_uniform). If a single functionfnis provided, it is automatically expanded into a 3-element tuple (fn, fn, fn). If set tonothing, weights are initialized from a uniform distribution within[-bound, bound]wherebound = inv(sqrt(out_dims)). Default isnothing.init_recurrent_weight: Initializer for input to hidden weights $\mathbf{W}_{hh}^{\theta}, \mathbf{W}_{hh}^{\eta}$. Must be a tuple containing 2 functions, e.g.,(glorot_normal, kaiming_uniform). If a single functionfnis provided, it is automatically expanded into a 2-element tuple (fn, fn). If set tonothing, weights are initialized from a uniform distribution within[-bound, bound]wherebound = inv(sqrt(out_dims)). Default isnothing.init_state: Initializer for hidden state. Default set tozeros32.
Inputs
- Case 1a: Only a single input
xof shape(in_dims, batch_size),train_stateis set tofalse- Creates a hidden state usinginit_stateand proceeds to Case 2. - Case 1b: Only a single input
xof shape(in_dims, batch_size),train_stateis set totrue- Repeatshidden_statefrom parameters to match the shape ofxand proceeds to Case 2. - Case 2: Tuple
(x, (h, ))is provided, then the output and a tuple containing the updated hidden state is returned.
Returns
Tuple containing
- Output $h_{new}$ of shape
(out_dims, batch_size) - Tuple containing new hidden state $h_{new}$
- Output $h_{new}$ of shape
Updated model state
Parameters
weight_ih: Concatenated weights to map from input to the hidden state. $\{ \mathbf{W}_{ih}^{\theta}, \mathbf{W}_{ih}^{\eta}, \mathbf{W}_{ih}^{h} \}$ The initializers ininit_weightare applied in the order they appear: the first function is used for $\mathbf{W}_{ih}^{\theta}$, the second for $\mathbf{W}_{ih}^{\eta}$, and the third for $\mathbf{W}_{ih}^h$.weight_hh: Concatenated weights to map from hidden to hidden state. $\{ \mathbf{W}_{hh}^{\theta}, \mathbf{W}_{hh}^{\eta} \}$ The initializers ininit_recurrent_weightare applied in the order they appear: the first function is used for $\mathbf{W}_{hh}^{\theta}$, and the second for $\mathbf{W}_{hh}^{\eta}$.bias_ih: Bias vector for the input-hidden connection (not present ifuse_bias=false) $\{ \mathbf{b}_{ih}^{\theta}, \mathbf{b}_{ih}^{\eta}, \mathbf{b}_{ih}^{h} \}$ The initializers ininit_biasare applied in the order they appear: the first function is used for $\mathbf{b}_{ih}^{\theta}$, the second for $\mathbf{b}_{ih}^{\eta}$, and the third for $\mathbf{b}_{ih}^{h}$.bias_ih: Bias vector for the input-hidden connection (not present ifuse_bias=false) $\{ \mathbf{b}_{hh}^{\theta}, \mathbf{b}_{hh}^{\eta} \}$ The initializers ininit_recurrent_biasare applied in the order they appear: the first function is used for $\mathbf{b}_{hh}^{\theta}$, and the second for $\mathbf{b}_{hh}^{\eta}$.hidden_state: Initial hidden state vector (not present iftrain_state=false)
States
rng: Controls the randomness (if any) in the initial state generation