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 prefix

get

Get a variable with name or create a new one if missing.

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 : RNNParams 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[Symbol]
    state from previous step or begin_state().

Returns
-------
output : Symbol
    output symbol
states : 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 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 : array ref of Symbol
    starting states for first RNN step

unpack_weights

Unpack fused weight matrices into separate
weight matrices

Parameters
----------
args : hash ref of str -> NDArray
    dictionary containing packed weights.
    usually from Module.get_output()

Returns
-------
args : hash ref of str -> NDArray
    dictionary with weights associated to
    this cell unpacked.

pack_weights

Unpack fused weight matrices into separate
weight matrices

Parameters
----------
args : hash ref of str -> NDArray
    dictionary containing unpacked weights.

Returns
-------
args : hash ref of str -> NDArray
    dictionary with weights associated to
    this cell packed.

unroll

Unroll an RNN cell across time steps.

Parameters
----------
length : int
    number of steps to unroll
inputs : Symbol, list of Symbol, or undef
    if inputs is a single Symbol (usually the output
    of Embedding symbol), it should have shape
    (batch_size, length, ...) if layout == 'NTC',
    or (length, batch_size, ...) if layout == 'TNC'.

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

    If inputs is undef, 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 inputs
    is a single Symbol.
merge_outputs : bool
    if 0, return outputs as a list of Symbols.
    If 1, concatenate output across time steps
    and return a single symbol with shape
    (batch_size, length, ...) if layout == 'NTC',
    or (length, batch_size, ...) if layout == 'TNC'.

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.

state_shape

shape(s) of states

call

Construct symbol for one step of RNN.

Parameters
----------
inputs : sym.Variable
    input symbol, 2D, batch * num_units
states : sym.Variable
    state from previous step or begin_state().

Returns
-------
output : Symbol
    output symbol
states : Symbol
    state to next step of RNN.

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.

state_shape

shape(s) of states

unpack_weights

Unpack fused weight matrices into separate
weight matrices

Parameters
----------
args : hashref of str -> NDArray
    dictionary containing packed weights.
    usually from $Module->get_output()

Returns
-------
args : hashref of str -> NDArray
    dictionary with weights associated to
    this cell unpacked.

pack_weights

Pack separate weight matrices into fused
weight.

Parameters
----------
args : hashref of str -> NDArray
    dictionary containing unpacked weights.

Returns
-------
args : hashref of str -> NDArray
    dictionary with weights associated to
    this cell packed.

call

Construct symbol for one step of RNN.

Parameters
----------
inputs : sym.Variable
    input symbol, 2D, batch * num_units
states : sym.Variable
    state from previous step or begin_state().

Returns
-------
output : Symbol
    output symbol
states : Symbol
    state to next step of RNN.

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 None.

unpack_weights

Unpack fused weight matrices into separate
weight matrices

Parameters
----------
args : hashref of str -> NDArray
    dictionary containing packed weights.
    usually from $Module->get_output()

Returns
-------
args : hashref of str -> NDArray
    dictionary with weights associated to
    this cell unpacked.

pack_weights

Pack separate weight matrices into fused
weight.

Parameters
----------
args : hashref of str -> NDArray
    dictionary containing unpacked weights.

Returns
-------
args : hashref of str -> NDArray
    dictionary with weights associated to
    this cell packed.

call

Construct symbol for one step of RNN.

Parameters
----------
inputs : sym.Variable
    input symbol, 2D, batch * num_units
states : sym.Variable
    state from previous step or begin_state().

Returns
-------
output : Symbol
    output symbol
states : Symbol
    state to next step of RNN.

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.

unroll

Unroll an RNN cell across time steps.

Parameters
----------
length : int
    number of steps to unroll
inputs : Symbol, array ref of Symbol, or undef
    if inputs is a single Symbol (usually the output
    of Embedding symbol), it should have shape
    (batch_size, length, ...) if layout == 'NTC',
    or (length, batch_size, ...) if layout == 'TNC'.
    using 'TNC' is more efficient for RNN::FusedCell.

    If inputs is a array ref of symbols (usually output of
    previous unroll), they should all have shape
    (batch_size, ...). using single symbol is
    more efficient for RNN::FusedCell.

    If inputs is undef, a single placeholder variable is
    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/output symbol.
merge_outputs : Bool
    default 0

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

NAME

AI:MXNet::RNN::SequentialCell

DESCRIPTION

Sequentially stacking multiple RNN cells

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

add

Append a cell into the stack.

Parameters
----------
cell : rnn cell

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 dropout on base cell

NAME

AI::MXNet::RNN::ZoneoutCell

DESCRIPTION

Apply Zoneout on base cell