TGRUCell
RecurrentLayers.TGRUCell
— TypeTGRUCell(input_size => hidden_size;
init_kernel = glorot_uniform,
init_recurrent_kernel = glorot_uniform,
bias = true, recurrent_bias = true,
independent_recurrence = false, integration_mode = :addition)
Strongly typed gated recurrent unit (Balduzzi and Ghifary, 20–22 Jun 2016). See TGRU
for a layer that processes entire sequences.
Arguments
input_size => hidden_size
: input and inner dimension of the layer.
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:addition
and:multiplicative_integration
. Defaults to:addition
.
Equations
\[\begin{aligned} \mathbf{z}(t) &= \mathbf{W}^{z}_{ih} \mathbf{x}(t) + \mathbf{W}^{z}_{hh} \mathbf{x}(t-1) + \mathbf{b}^{z} \\ \mathbf{f}(t) &= \sigma\left( \mathbf{W}^{f}_{ih} \mathbf{x}(t) + \mathbf{W}^{f}_{hh} \mathbf{x}(t-1) + \mathbf{b}^{f} \right) \\ \mathbf{o}(t) &= \tau\left( \mathbf{W}^{o}_{ih} \mathbf{x}(t) + \mathbf{W}^{o}_{hh} \mathbf{x}(t-1) + \mathbf{b}^{o} \right) \\ \mathbf{h}(t) &= \mathbf{f}(t) \odot \mathbf{h}(t-1) + \mathbf{z}(t) \odot \mathbf{o}(t) \end{aligned}\]
Forward
tgrucell(inp, state)
tgrucell(inp)
Arguments
inp
: The input to the tgrucell. It should be a vector of sizeinput_size
or a matrix of sizeinput_size x batch_size
.state
: The hidden state of the TGRUCell. It should be a vector of sizehidden_size
or a matrix of sizehidden_size x batch_size
. If not provided, it is assumed to be a vector of zeros, initialized byFlux.initialstates
.
Returns
- A tuple
(output, state)
, whereoutput = new_state
is the new hidden state andstate = (new_state, inp)
is the new hidden state together with the current input. They are tensors of sizehidden_size
orhidden_size x batch_size
.