MiRU2
RecurrentLayers.MiRU2 — Type
MiRU2(input_size => hidden_size, [activation];
init_kernel = glorot_uniform,
init_recurrent_kernel = glorot_uniform,
bias = true, recurrent_bias = true,
independent_recurrence = false, integration_mode = :addition,
update_coefficient = 0.5, reset_coefficient = 0.5)Minion gated recurrent unit 2 (Zyarah and Kudithipudi, 2026). See MiRU2 for a layer that processes entire sequences.
Arguments
input_size => hidden_size: input and inner dimension of the layer.activation: activation function. Defaulttanh_fast.
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 input to recurrent bias or not. Default istrue.recurrent_bias: include recurrent to recurrent bias or not. Default istrue.independent_recurrence: flag to toggle independent recurrence. Iftrue, the recurrent to recurrent weights are a vector instead of a matrix. Defaultfalse.integration_mode: determines how the input and hidden projections are combined. The options are:additionand:multiplicative_integration. Defaults to:addition.update_coefficient: controls the dynamic update of the hidden states. Default is 0.5.reset_coefficient: determines how much of the previous hidden state should be forgotten or reset before combining it with the new input. Default is 0.5.
Equations
\[\begin{aligned} \tilde{\mathbf{h}}(t) &= \tanh\!\left( \mathbf{W}_{h}\mathbf{x}(t) + \mathbf{b}_{h} + \mathbf{U}_{h}\!\left(\boldsymbol{\theta} \odot \mathbf{h}(t-1)\right) \right), \\ \mathbf{h}(t) &= \boldsymbol{\lambda} \odot \mathbf{h}(t-1) + \left(1 - \boldsymbol{\lambda}\right) \odot \tilde{\mathbf{h}}(t) \end{aligned}\]
Forward
miru(inp, (state, cstate))
miru(inp)Arguments
inp: The input to the miru. It should be a vector of sizeinput_size x lenor a matrix of sizeinput_size x len x batch_size.(state, cstate): A tuple containing the hidden and cell states of the MiRU2. They should be vectors of sizehidden_sizeor 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_statesas an array of sizehidden_size x len x batch_size. Whenreturn_state = trueit returns a tuple of the hidden statsnew_statesand the last state of the iteration.