IntersectionRNNCell
RecurrentLayers.IntersectionRNNCell — Type
IntersectionRNNCell(input_size => hidden_size;
init_kernel = glorot_uniform,
init_recurrent_kernel = glorot_uniform,
bias = true, recurrent_bias = true,
independent_recurrence = false, integration_mode = :addition)Intersection RNN (Collins et al., 2016). See IntersectionRNN for a layer that processes entire sequences.
Requires input_size == hidden_size: the output y(t) is a gated mix of x(t) and y^{in}(t), both of dimension hidden_size.
Arguments
input_size => hidden_size: input and inner dimension of the layer. Must be equal.
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.
Equations
\[\begin{aligned} \mathbf{y}^{in}(t) &= s_1\left( \mathbf{W}_{hh}^y \, \mathbf{h}(t-1) + \mathbf{W}_{xh}^y \, \mathbf{x}(t) + \mathbf{b}^y \right), \\ \mathbf{h}^{in}(t) &= s_2\left( \mathbf{W}_{hh}^h \, \mathbf{h}(t-1) + \mathbf{W}_{xh}^h \, \mathbf{x}(t) + \mathbf{b}^h \right), \\ \mathbf{g}^y(t) &= \sigma\left( \mathbf{W}_{hh}^{g^y} \, \mathbf{h}(t-1) + \mathbf{W}_{xh}^{g^y} \, \mathbf{x}(t) + \mathbf{b}^{g^y} \right), \\ \mathbf{g}^h(t) &= \sigma\left( \mathbf{W}_{hh}^{g^h} \, \mathbf{h}(t-1) + \mathbf{W}_{xh}^{g^h} \, \mathbf{x}(t) + \mathbf{b}^{g^h} \right), \\ \mathbf{y}(t) &= \mathbf{g}^y(t) \circ \mathbf{x}(t) + \left( 1 - \mathbf{g}^y(t) \right) \circ \mathbf{y}^{in}(t), \\ \mathbf{h}(t) &= \mathbf{g}^h(t) \circ \mathbf{h}(t-1) + \left( 1 - \mathbf{g}^h(t) \right) \circ \mathbf{h}^{in}(t). \end{aligned}\]
Forward
intersectionrnncell(inp, state)
intersectionrnncell(inp)Arguments
inp: The input to the intersectionrnncell. It should be a vector of sizeinput_sizeor a matrix of sizeinput_size x batch_size.state: The hidden state of the IntersectionRNNCell. It should be a vector of sizehidden_sizeor 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), where both elements are given by the updated statenew_state, a tensor of sizehidden_sizeorhidden_size x batch_size.