LEM
RecurrentLayers.LEM
— TypeLEM(input_size => hidden_size, [dt];
return_state=false, init_kernel = glorot_uniform,
init_recurrent_kernel = glorot_uniform, bias = true)
Long expressive memory network [Rusch2022]. See LEMCell
for a layer that processes a single sequence.
Arguments
input_size => hidden_size
: input and inner dimension of the layer.dt
: timestep. Defaul is 1.0.
Keyword arguments
init_kernel
: initializer for the input to hidden weights. Default isglorot_uniform
.init_recurrent_kernel
: initializer for the hidden to hidden weights. Default isglorot_uniform
.bias
: include a bias or not. Default istrue
.return_state
: Option to return the last state together with the output. Default isfalse
.
Equations
\[\begin{aligned} \boldsymbol{\Delta t}(t) &= \Delta \hat{t} \, \hat{\sigma} \left( \mathbf{W}^{1}_{hh} \mathbf{h}(t-1) + \mathbf{W}^{1}_{ih} \mathbf{x}(t) + \mathbf{b}^{1} \right), \\ \overline{\boldsymbol{\Delta t}}(t) &= \Delta \hat{t} \, \hat{\sigma} \left( \mathbf{W}^{2}_{hh} \mathbf{h}(t-1) + \mathbf{W}^{2}_{ih} \mathbf{x}(t) + \mathbf{b}^{2} \right), \\ \mathbf{z}(t) &= \left( 1 - \boldsymbol{\Delta t}(t) \right) \odot \mathbf{z}(t-1) + \boldsymbol{\Delta t}(t) \odot \sigma \left( \mathbf{W}^{z}_{hh} \mathbf{h}(t-1) + \mathbf{W}^{z}_{ih} \mathbf{x}(t) + \mathbf{b}^{z} \right), \\ \mathbf{h}(t) &= \left( 1 - \boldsymbol{\Delta t}(t) \right) \odot \mathbf{h}(t-1) + \boldsymbol{\Delta t}(t) \odot \sigma \left( \mathbf{W}^{h}_{zh} \mathbf{z}(t) + \mathbf{W}^{h}_{ih} \mathbf{x}(t) + \mathbf{b}^{h} \right) \end{aligned}\]
Forward
lem(inp, (state, zstate))
lem(inp)
Arguments
inp
: The input to the LEM. It should be a vector of sizeinput_size x len
or a matrix of sizeinput_size x len x batch_size
.(state, cstate)
: A tuple containing the hidden and cell states of the LEM. They should be vectors of sizehidden_size
or matrices of sizehidden_size x batch_size
. If not provided, they are assumed to be vectors of zeros, initialized byFlux.initialstates
.
Returns
- New hidden states
new_states
as an array of sizehidden_size x len x batch_size
. Whenreturn_state = true
it returns a tuple of the hidden statsnew_states
and the last state of the iteration.
- Rusch2022Rusch, T. K. et al. Long Expressive Memory for Sequence Modeling. ICLR 2022.