Trait tch::nn::RNN

source ·
pub trait RNN {
    type State;

    // Required methods
    fn zero_state(&self, batch_dim: i64) -> Self::State;
    fn step(&self, input: &Tensor, state: &Self::State) -> Self::State;
    fn seq_init(
        &self,
        input: &Tensor,
        state: &Self::State
    ) -> (Tensor, Self::State);

    // Provided method
    fn seq(&self, input: &Tensor) -> (Tensor, Self::State) { ... }
}
Expand description

Trait for Recurrent Neural Networks.

Required Associated Types§

Required Methods§

source

fn zero_state(&self, batch_dim: i64) -> Self::State

A zero state from which the recurrent network is usually initialized.

source

fn step(&self, input: &Tensor, state: &Self::State) -> Self::State

Applies a single step of the recurrent network.

The input should have dimensions [batch_size, features].

source

fn seq_init(&self, input: &Tensor, state: &Self::State) -> (Tensor, Self::State)

Applies multiple steps of the recurrent network.

The input should have dimensions [batch_size, seq_len, features].

Provided Methods§

source

fn seq(&self, input: &Tensor) -> (Tensor, Self::State)

Applies multiple steps of the recurrent network.

The input should have dimensions [batch_size, seq_len, features]. The initial state is the result of applying zero_state.

Implementors§