MCPcopy Create free account
hub / github.com/DeepRec-AI/DeepRec / rnn

Function rnn

tensorflow/python/keras/backend.py:3718–4077  ·  view source on GitHub ↗

Iterates over the time dimension of a tensor. Arguments: step_function: RNN step function. Args; input; Tensor with shape `(samples, ...)` (no time dimension), representing input for the batch of samples at a certain time step.

(step_function,
        inputs,
        initial_states,
        go_backwards=False,
        mask=None,
        constants=None,
        unroll=False,
        input_length=None,
        time_major=False,
        zero_output_for_mask=False)

Source from the content-addressed store, hash-verified

3716
3717@keras_export('keras.backend.rnn')
3718def rnn(step_function,
3719 inputs,
3720 initial_states,
3721 go_backwards=False,
3722 mask=None,
3723 constants=None,
3724 unroll=False,
3725 input_length=None,
3726 time_major=False,
3727 zero_output_for_mask=False):
3728 """Iterates over the time dimension of a tensor.
3729
3730 Arguments:
3731 step_function: RNN step function.
3732 Args;
3733 input; Tensor with shape `(samples, ...)` (no time dimension),
3734 representing input for the batch of samples at a certain
3735 time step.
3736 states; List of tensors.
3737 Returns;
3738 output; Tensor with shape `(samples, output_dim)`
3739 (no time dimension).
3740 new_states; List of tensors, same length and shapes
3741 as 'states'. The first state in the list must be the
3742 output tensor at the previous timestep.
3743 inputs: Tensor of temporal data of shape `(samples, time, ...)`
3744 (at least 3D), or nested tensors, and each of which has shape
3745 `(samples, time, ...)`.
3746 initial_states: Tensor with shape `(samples, state_size)`
3747 (no time dimension), containing the initial values for the states used
3748 in the step function. In the case that state_size is in a nested
3749 shape, the shape of initial_states will also follow the nested
3750 structure.
3751 go_backwards: Boolean. If True, do the iteration over the time
3752 dimension in reverse order and return the reversed sequence.
3753 mask: Binary tensor with shape `(samples, time, 1)`,
3754 with a zero for every element that is masked.
3755 constants: List of constant values passed at each step.
3756 unroll: Whether to unroll the RNN or to use a symbolic `while_loop`.
3757 input_length: If specified, assume time dimension is of this length.
3758 time_major: Boolean. If true, the inputs and outputs will be in shape
3759 `(timesteps, batch, ...)`, whereas in the False case, it will be
3760 `(batch, timesteps, ...)`. Using `time_major = True` is a bit more
3761 efficient because it avoids transposes at the beginning and end of the
3762 RNN calculation. However, most TensorFlow data is batch-major, so by
3763 default this function accepts input and emits output in batch-major
3764 form.
3765 zero_output_for_mask: Boolean. If True, the output for masked timestep
3766 will be zeros, whereas in the False case, output from previous
3767 timestep is returned.
3768 Returns:
3769 A tuple, `(last_output, outputs, new_states)`.
3770 last_output: the latest output of the rnn, of shape `(samples, ...)`
3771 outputs: tensor with shape `(samples, time, ...)` where each
3772 entry `outputs[s, t]` is the output of the step function
3773 at time `t` for sample `s`.
3774 new_states: list of tensors, latest states returned by
3775 the step function, of shape `(samples, ...)`.

Calls 15

unstackMethod · 0.95
swap_batch_timestepFunction · 0.85
tupleFunction · 0.85
_process_single_input_tFunction · 0.85
_get_input_tensorFunction · 0.85
_expand_maskFunction · 0.85
reverseFunction · 0.85
with_rank_at_leastMethod · 0.80
TensorArrayMethod · 0.80
expand_dimsFunction · 0.70
zeros_likeFunction · 0.70
rangeFunction · 0.50