AI::MXNet::Gluon::RNN::RecurrentCell
Abstract role for RNN cells Parameters ---------- prefix : str, optional Prefix for names of `Block`s (this prefix is also used for names of weights if `params` is `None` i.e. if `params` are being created and not reused) params : Parameter or None, optional Container for weight sharing between cells. A new Parameter container is created if `params` is `None`.
Reset before re-using the cell for another graph.
Shape and layout information of states
Initial state for this cell. Parameters ---------- $func : CodeRef, default sub { AI::MXNet::Symbol->zeros(@_) } Function for creating initial state. For Symbol API, func can be `symbol.zeros`, `symbol.uniform`, `symbol.var etc`. Use `symbol.var` if you want to directly feed input as states. For NDArray API, func can be `ndarray.zeros`, `ndarray.ones`, etc. $batch_size: int, default 0 Only required for NDArray API. Size of the batch ('N' in layout) dimension of input. %kwargs : Additional keyword arguments passed to func. For example `mean`, `std`, `dtype`, etc. Returns ------- states : nested array ref of Symbol Starting states for the first RNN step.
Unrolls an RNN cell across time steps. Parameters ---------- $length : int Number of steps to unroll. $inputs : Symbol, list of Symbol, or None If `inputs` is a single Symbol (usually the output of Embedding symbol), it should have shape (batch_size, length, ...) if `layout` is 'NTC', or (length, batch_size, ...) if `layout` is 'TNC'. If `inputs` is a list of symbols (usually output of previous unroll), they should all have shape (batch_size, ...). :$begin_state : nested list of Symbol, optional Input states created by `begin_state()` or output state of another cell. Created from `begin_state()` if `None`. :$layout : str, optional `layout` of input symbol. Only used if inputs is a single Symbol. :$merge_outputs : bool, optional If `False`, returns outputs as a list of Symbols. If `True`, concatenates output across time steps and returns a single symbol with shape (batch_size, length, ...) if layout is 'NTC', or (length, batch_size, ...) if layout is 'TNC'. If `None`, output whatever is faster. Returns ------- outputs : list of Symbol or Symbol Symbol (if `merge_outputs` is True) or list of Symbols (if `merge_outputs` is False) corresponding to the output from the RNN from this unrolling. states : list of Symbol The new state of this RNN after this unrolling. The type of this symbol is same as the output of `begin_state()`.
Unrolls the recurrent cell for one time step. Parameters ---------- inputs : sym.Variable Input symbol, 2D, of shape (batch_size * num_units). states : list of sym.Variable RNN state from previous step or the output of begin_state(). Returns ------- output : Symbol Symbol corresponding to the output from the RNN when unrolling for a single time step. states : list of Symbol The new state of this RNN after this unrolling. The type of this symbol is same as the output of `begin_state()`. This can be used as an input state to the next time step of this RNN. See Also -------- begin_state: This function can provide the states for the first time step. unroll: This function unrolls an RNN for a given number of (>=1) time steps.
AI::MXNet::Gluon::RNN::RNNCell
Simple recurrent neural network cell. Parameters ---------- hidden_size : int Number of units in output symbol activation : str or Symbol, default 'tanh' Type of activation function. i2h_weight_initializer : str or Initializer Initializer for the input weights matrix, used for the linear transformation of the inputs. h2h_weight_initializer : str or Initializer Initializer for the recurrent weights matrix, used for the linear transformation of the recurrent state. i2h_bias_initializer : str or Initializer Initializer for the bias vector. h2h_bias_initializer : str or Initializer Initializer for the bias vector. prefix : str, default 'rnn_' Prefix for name of `Block`s (and name of weight if params is `None`). params : Parameter or None Container for weight sharing between cells. Created if `None`.
AI::MXNet::Gluon::RNN::LSTMCell
Long-Short Term Memory (LSTM) network cell. Parameters ---------- hidden_size : int Number of units in output symbol. i2h_weight_initializer : str or Initializer Initializer for the input weights matrix, used for the linear transformation of the inputs. h2h_weight_initializer : str or Initializer Initializer for the recurrent weights matrix, used for the linear transformation of the recurrent state. i2h_bias_initializer : str or Initializer, default 'lstmbias' Initializer for the bias vector. By default, bias for the forget gate is initialized to 1 while all other biases are initialized to zero. h2h_bias_initializer : str or Initializer Initializer for the bias vector. prefix : str, default 'lstm_' Prefix for name of `Block`s (and name of weight if params is `None`). params : Parameter or None Container for weight sharing between cells. Created if `None`.
AI::MXNet::Gluon::RNN::GRUCell
Gated Rectified Unit (GRU) network cell. Note: this is an implementation of the cuDNN version of GRUs (slight modification compared to Cho et al. 2014). Parameters ---------- hidden_size : int Number of units in output symbol. i2h_weight_initializer : str or Initializer Initializer for the input weights matrix, used for the linear transformation of the inputs. h2h_weight_initializer : str or Initializer Initializer for the recurrent weights matrix, used for the linear transformation of the recurrent state. i2h_bias_initializer : str or Initializer Initializer for the bias vector. h2h_bias_initializer : str or Initializer Initializer for the bias vector. prefix : str, default 'gru_' prefix for name of `Block`s (and name of weight if params is `None`). params : Parameter or None Container for weight sharing between cells. Created if `None`.
AI::MXNet::Gluon::RNN::SequentialRNNCell
Sequentially stacking multiple RNN cells.
Appends a cell into the stack. Parameters ---------- cell : rnn cell
AI::MXNet::Gluon::RNN::DropoutCell
Applies dropout on input. Parameters ---------- rate : float Percentage of elements to drop out, which is 1 - percentage to retain.
AI::MXNet::Gluon::RNN::ModifierCell
Base class for modifier cells. A modifier cell takes a base cell, apply modifications on it (e.g. Zoneout), and returns a new cell. After applying modifiers the base cell should no longer be called directly. The modifier cell should be used instead.
AI::MXNet::Gluon::RNN::ZoneoutCell
Applies Zoneout on base cell.
AI::MXNet::Gluon::RNN::ResidualCell
Adds residual connection as described in Wu et al, 2016 (https://arxiv.org/abs/1609.08144). Output of the cell is output of the base cell plus input.
AI::MXNet::Gluon::RNN::BidirectionalCell
Bidirectional RNN cell. Parameters ---------- l_cell : RecurrentCell Cell for forward unrolling r_cell : RecurrentCell Cell for backward unrolling
To install AI::MXNet, copy and paste the appropriate command in to your terminal.
cpanm
cpanm AI::MXNet
CPAN shell
perl -MCPAN -e shell install AI::MXNet
For more information on module installation, please visit the detailed CPAN module installation guide.