NAME

AI::MXNet::RNN::Params

DESCRIPTION

Container for holding variables. Used by RNN cells for parameter sharing between cells.

Parameters ---------- prefix : str All variables name created by this container will be prepended with the prefix

get

Get a variable with the name or create a new one id does not exist.

Parameters ---------- $name : str name of the variable @kwargs: more arguments that are passed to mx->sym->Variable call

NAME

AI::MXNet::RNNCell::Base

DESCRIPTION

Abstract base class for RNN cells

Parameters ---------- prefix : str prefix for name of layers (and name of weight if params is undef) params : AI::MXNet::RNN::Params or undef container for weight sharing between cells. created if undef.

reset

Reset before re-using the cell for another graph

call

Construct symbol for one step of RNN.

Parameters ---------- $inputs : mx->sym->Variable input symbol, 2D, batch * num_units %states : mx->sym->Variable or ArrayRef[AI::MXNet::Symbol] state from previous step or begin_state().

Returns ------- $output : AI::MXNet::Symbol output symbol $states : ArrayRef[AI::MXNet::Symbol] state to next step of RNN. Can be called via overloaded &{}: &{$cell}($inputs, $states);

params

Parameters of this cell

state_shape

shape(s) of states

begin_state

Initial state for this cell.

Parameters ---------- $:func : sub ref, default is AI::MXNet::Symbol->can('zeros') Function for creating initial state. Can be AI::MXNet::Symbol->can('zeros'), AI::MXNet::Symbol->can('uniform'), AI::MXNet::Symbol->can('Variable') etc. Use AI::MXNet::Symbol->can('Variable') if you want to directly feed input as states. @kwargs : more keyword arguments passed to func. For example mean, std, dtype, etc.

Returns ------- $states : ArrayRef[AI::MXNet::Symbol] starting states for first RNN step

unpack_weights

Unpack fused weight matrices into separate weight matrices

Parameters ---------- $args : HashRef[AI::MXNet::NDArray] hash ref containing packed weights. usually from AI::MXNet::Module->get_output()

Returns ------- $args : HashRef[AI::MXNet::NDArray] hash ref with weights associated with this cell, unpacked.

pack_weights

Pack fused weight matrices into common weight matrices

Parameters ---------- args : HashRef[AI::MXNet::NDArray] hash ref containing unpacked weights.

Returns ------- $args : HashRef[AI::MXNet::NDArray] hash ref with weights associated with this cell, packed.

unroll

Unroll an RNN cell across time steps.

Parameters ---------- :$length : Int number of steps to unroll :$inputs : AI::MXNet::Symbol, array ref of Symbols, or undef if inputs is a single Symbol (usually the output of Embedding symbol), it should have shape of [$batch_size, $length, ...] if layout == 'NTC' (batch, time series) or ($length, $batch_size, ...) if layout == 'TNC' (time series, batch).

    If inputs is a array ref of symbols (usually output of
    previous unroll), they should all have shape
    ($batch_size, ...).

    If inputs is undef, a placeholder variables are
    automatically created.
:$begin_state : array ref of Symbol
    input states. Created by begin_state()
    or output state of another cell. Created
    from begin_state() if undef.
:$input_prefix : str
    prefix for automatically created input
    placehodlers.
:$layout : str
    layout of input symbol. Only used if the input
    is a single Symbol.
:$merge_outputs : Bool
    If 0, returns outputs as an array ref of Symbols.
    If 1, concatenates the output across the time steps
    and returns a single symbol with the shape
    [$batch_size, $length, ...) if the layout equal to 'NTC',
    or [$length, $batch_size, ...) if the layout equal tp 'TNC'.
    If undef, output whatever is faster

Returns ------- $outputs : array ref of Symbol or Symbol output symbols. $states : Symbol or nested list of Symbol has the same structure as begin_state()

NAME

AI::MXNet::RNN::Cell

DESCRIPTION

Simple recurrent neural network cell

Parameters ---------- num_hidden : int number of units in output symbol activation : str or Symbol, default 'tanh' type of activation function prefix : str, default 'rnn_' prefix for name of layers (and name of weight if params is undef) params : AI::MXNet::RNNParams or undef container for weight sharing between cells. created if undef.

NAME

    AI::MXNet::RNN::LSTMCell

DESCRIPTION

Long-Short Term Memory (LSTM) network cell.

Parameters ---------- num_hidden : int number of units in output symbol prefix : str, default 'lstm_' prefix for name of layers (and name of weight if params is undef) params : AI::MXNet::RNN::Params or None container for weight sharing between cells. created if undef. forget_bias : bias added to forget gate, default 1.0. Jozefowicz et al. 2015 recommends setting this to 1.0

NAME

AI::MXNet::RNN::GRUCell

DESCRIPTION

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 ---------- num_hidden : int number of units in output symbol prefix : str, default 'gru_' prefix for name of layers (and name of weight if params is undef) params : AI::MXNet::RNN::Params or undef container for weight sharing between cells. created if undef.

NAME

AI::MXNet::RNN::FusedCell

DESCRIPTION

Fusing RNN layers across time step into one kernel. Improves speed but is less flexible. Currently only supported if using cuDNN on GPU.

unfuse

Unfuse the fused RNN

Returns ------- $cell : AI::MXNet::RNN::SequentialCell unfused cell that can be used for stepping, and can run on CPU.

NAME

AI:MXNet::RNN::SequentialCell

DESCRIPTION

Sequentially stacking multiple RNN cells

Parameters ---------- params : AI::MXNet::RNN::Params or undef container for weight sharing between cells. created if undef.

add

Append a cell into the stack.

Parameters ---------- $cell : AI::MXNet::RNN::Cell::Base

NAME

AI::MXNet::RNN::BidirectionalCell

DESCRIPTION

Bidirectional RNN cell

Parameters ---------- l_cell : AI::MXNet::RNN::Cell::Base cell for forward unrolling r_cell : AI::MXNet::RNN::Cell::Base cell for backward unrolling output_prefix : str, default 'bi_' prefix for name of output

NAME

AI::MXNet::RNN::ModifierCell

DESCRIPTION

Base class for modifier cells. A modifier cell takes a base cell, apply modifications on it (e.g. Dropout), and returns a new cell.

After applying modifiers the base cell should no longer be called directly. The modifer cell should be used instead.

NAME

AI::MXNet::RNN::DropoutCell

DESCRIPTION

Apply the dropout on base cell

NAME

AI::MXNet::RNN::ZoneoutCell

DESCRIPTION

Apply Zoneout on base cell