NASCell
RecurrentLayers.NASCell — TypeNASCell(input_size => hidden_size;
init_kernel = glorot_uniform,
init_recurrent_kernel = glorot_uniform,
bias = true, recurrent_bias = true,
independent_recurrence = false, integration_mode = :addition)Neural Architecture Search unit (Zoph and Le, 2017). See NAS 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:additionand:multiplicative_integration. Defaults to:addition.
Equations
\[\begin{aligned} \mathbf{o}_1 &= \sigma\left( \mathbf{W}^{(1)}_{ih} \mathbf{x}(t) + \mathbf{W}^{(1)}_{hh} \mathbf{h}(t-1) + \mathbf{b}^{(1)} \right), \\ \mathbf{o}_2 &= \text{ReLU}\left( \mathbf{W}^{(2)}_{ih} \mathbf{x}(t) + \mathbf{W}^{(2)}_{hh} \mathbf{h}(t-1) + \mathbf{b}^{(2)} \right), \\ \mathbf{o}_3 &= \sigma\left( \mathbf{W}^{(3)}_{ih} \mathbf{x}(t) + \mathbf{W}^{(3)}_{hh} \mathbf{h}(t-1) + \mathbf{b}^{(3)} \right), \\ \mathbf{o}_4 &= \text{ReLU}\left( \mathbf{W}^{(4)}_{ih} \mathbf{x}(t) \cdot \mathbf{W}^{(4)}_{hh} \mathbf{h}(t-1) \right), \\ \mathbf{o}_5 &= \tanh\left( \mathbf{W}^{(5)}_{ih} \mathbf{x}(t) + \mathbf{W}^{(5)}_{hh} \mathbf{h}(t-1) + \mathbf{b}^{(5)} \right), \\ \mathbf{o}_6 &= \sigma\left( \mathbf{W}^{(6)}_{ih} \mathbf{x}(t) + \mathbf{W}^{(6)}_{hh} \mathbf{h}(t-1) + \mathbf{b}^{(6)} \right), \\ \mathbf{o}_7 &= \tanh\left( \mathbf{W}^{(7)}_{ih} \mathbf{x}(t) + \mathbf{W}^{(7)}_{hh} \mathbf{h}(t-1) + \mathbf{b}^{(7)} \right), \\ \mathbf{o}_8 &= \sigma\left( \mathbf{W}^{(8)}_{ih} \mathbf{x}(t) + \mathbf{W}^{(8)}_{hh} \mathbf{h}(t-1) + \mathbf{b}^{(8)} \right), \\[1ex] \mathbf{l}_1 &= \tanh\left( \mathbf{o}_1 \cdot \mathbf{o}_2 \right), \\ \mathbf{l}_2 &= \tanh\left( \mathbf{o}_3 + \mathbf{o}_4 \right), \\ \mathbf{l}_3 &= \tanh\left( \mathbf{o}_5 \cdot \mathbf{o}_6 \right), \\ \mathbf{l}_4 &= \sigma\left( \mathbf{o}_7 + \mathbf{o}_8 \right), \\[1ex] \mathbf{l}_1 &= \tanh\left( \mathbf{l}_1 + \mathbf{c}_{\text{state}} \right), \\[1ex] \mathbf{c}_{\text{new}} &= \mathbf{l}_1 \cdot \mathbf{l}_2, \\ \mathbf{l}_5 &= \tanh\left( \mathbf{l}_3 + \mathbf{l}_4 \right), \\ \mathbf{h}_{\text{new}} &= \tanh\left( \mathbf{c}_{\text{new}} \cdot \mathbf{l}_5 \right) \end{aligned}\]
Forward
nascell(inp, (state, cstate))
nascell(inp)Arguments
inp: The input to the nascell. It should be a vector of sizeinput_sizeor a matrix of sizeinput_size x batch_size.(state, cstate): A tuple containing the hidden and cell states of the NASCell. 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
- A tuple
(output, state), whereoutput = new_stateis the new hidden state andstate = (new_state, new_cstate)is the new hidden and cell state. They are tensors of sizehidden_sizeorhidden_size x batch_size.