coRNNCell
LuxRecurrentLayers.coRNNCell
— TypecoRNNCell(in_dims => out_dims;
use_bias=true, train_state=false, train_memory=false,
init_bias=nothing, init_recurrent_bias=nothing, init_cell_bias=nothing,
init_weight=nothing, init_recurrent_weight=nothing,
init_cell_weight=nothing, init_state=zeros32, init_memory=zeros32,
gamma=0.0, epsilon=0.0, dt=1.0)
Coupled oscillatory recurrent neural unit.
Equations
\[\begin{aligned} \mathbf{c}(t) &= \mathbf{c}(t-1) + \Delta t \, \sigma\left( \mathbf{W}_{ih} \mathbf{x}(t) + \mathbf{b}_{ih} + \mathbf{W}_{hh} \mathbf{h}(t-1) + \mathbf{b}_{hh} + \mathbf{W}_{ch} \mathbf{c}(t-1) + \mathbf{b}_{ch} \right) - \Delta t \, \gamma \, \mathbf{h}(t-1) - \Delta t \, \epsilon \, \mathbf{c}(t), \\ \mathbf{h}(t) &= \mathbf{h}(t-1) + \Delta t \, \mathbf{c}(t) \end{aligned}\]
Arguments
in_dims
: Input Dimensionout_dims
: Output (Hidden State & Memory) Dimension
Keyword Arguments
use_bias
: Flag to use bias in the computation. Default set totrue
.train_state
: Flag to set the initial hidden state as trainable. Default set tofalse
.train_memory
: Flag to set the initial memory state as trainable. Default set tofalse
.init_bias
: Initializer for input to hidden bias $\mathbf{b}_{ih}$. 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}$. If set tonothing
, weights are initialized from a uniform distribution within[-bound, bound]
wherebound = inv(sqrt(out_dims))
. Default isnothing
.init_cell_bias
: Initializer for cell to hidden bias $\mathbf{b}_{ch}$. 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 weight $\mathbf{W}_{ih}$. 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 hidden to hidden weight $\mathbf{W}_{hh}$. If set tonothing
, weights are initialized from a uniform distribution within[-bound, bound]
wherebound = inv(sqrt(out_dims))
. Default isnothing
.init_cell_weight
: Initializer for cell to hidden weight $\mathbf{W}_{ch}$. 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
.init_memory
: Initializer for memory. Default set tozeros32
.dt
: time step. Default is 1.0.gamma
: Damping for state. Default is 0.0.epsilon
: Damping for candidate state. Default is 0.0.
Inputs
- Case 1a: Only a single input
x
of shape(in_dims, batch_size)
,train_state
is set tofalse
,train_memory
is set tofalse
- Creates a hidden state usinginit_state
, hidden memory usinginit_memory
and proceeds to Case 2. - Case 1b: Only a single input
x
of shape(in_dims, batch_size)
,train_state
is set totrue
,train_memory
is set tofalse
- Repeatshidden_state
vector from the parameters to match the shape ofx
, creates hidden memory usinginit_memory
and proceeds to Case 2. - Case 1c: Only a single input
x
of shape(in_dims, batch_size)
,train_state
is set tofalse
,train_memory
is set totrue
- Creates a hidden state usinginit_state
, repeats the memory vector from parameters to match the shape ofx
and proceeds to Case 2. - Case 1d: Only a single input
x
of shape(in_dims, batch_size)
,train_state
is set totrue
,train_memory
is set totrue
- Repeats the hidden state and memory vectors from the parameters to match the shape ofx
and proceeds to Case 2. - Case 2: Tuple
(x, (h, c))
is provided, then the output and a tuple containing the updated hidden state and memory is returned.
Returns
Tuple Containing
- Output $h_{new}$ of shape
(out_dims, batch_size)
- Tuple containing new hidden state $h_{new}$ and new memory $c_{new}$
- Output $h_{new}$ of shape
Updated model state
Parameters
weight_ih
: Weights to map the input to the hidden state $\mathbf{W}_{ih}$.weight_hh
: Weights to map the hidden state to the hidden state $\mathbf{W}_{hh}$.weight_ch
: Weights to map the cell state to the hidden state $\mathbf{W}_{ch}$.bias_ih
: Bias vector for the input-hidden connection (not present ifuse_bias=false
) $\mathbf{b}_{ih}$bias_hh
: Bias vector for the hidden-hidden connection (not present ifuse_bias=false
) $\mathbf{b}_{hh}$bias_ch
: Bias vector for the cell-hidden connection (not present ifuse_bias=false
) $\mathbf{b}_{ch}$hidden_state
: Initial hidden state vector (not present iftrain_state=false
)memory
: Initial memory vector (not present iftrain_memory=false
)
States
rng
: Controls the randomness (if any) in the initial state generation