IntersectionRNN

RecurrentLayers.IntersectionRNN — Type
IntersectionRNN(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 IntersectionRNNCell for a layer that processes a single sequence.

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 is glorot_uniform.
  • init_recurrent_kernel: initializer for the hidden to hidden weights. Default is glorot_uniform.
  • bias: include input to recurrent bias or not. Default is true.
  • recurrent_bias: include recurrent to recurrent bias or not. Default is true.
  • independent_recurrence: flag to toggle independent recurrence. If true, the recurrent to recurrent weights are a vector instead of a matrix. Default false.
  • 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{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

intersectionrnn(inp, state)
intersectionrnn(inp)

Arguments

  • inp: The input to the intersectionrnn. It should be a vector of size input_size x len or a matrix of size input_size x len x batch_size.
  • state: The hidden state of the IntersectionRNN. If given, it is a vector of size hidden_size or a matrix of size hidden_size x batch_size. If not provided, it is assumed to be a vector of zeros, initialized by Flux.initialstates.

Returns

  • New hidden states new_states as an array of size hidden_size x len x batch_size. When return_state = true it returns a tuple of the hidden stats new_states and the last state of the iteration.
source