Trait SeqIterative

Source
pub trait SeqIterative {
    type State;

    // Required methods
    fn initial_state(&self) -> Self::State;
    fn step(&self, state: &mut Self::State, input: &Tensor) -> Tensor;

    // Provided methods
    fn iter<I>(&self, inputs: I) -> SeqIterator<&Self, I::IntoIter> 
       where I: IntoIterator,
             I::Item: AsRef<Tensor> { ... }
    fn into_iter<I>(self, inputs: I) -> SeqIterator<Self, I::IntoIter> 
       where I: IntoIterator,
             I::Item: AsRef<Tensor>,
             Self: Sized { ... }
}
Expand description

An iterative transformation of a sequence of input Tensor.

Required Associated Types§

Source

type State

Sequence state managed by the module.

Required Methods§

Source

fn initial_state(&self) -> Self::State

Construct an initial state for the start of a new sequence.

Source

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

Transform the next value in the sequence.

§Args
  • input - The input for one step. A tensor with shape [NUM_INPUT_FEATURES]
  • state - The policy hidden state.
§Returns
  • output - The output tensor. Has shape [NUM_OUT_FEATURES]
  • state - A new value for the hidden state.

Provided Methods§

Source

fn iter<I>(&self, inputs: I) -> SeqIterator<&Self, I::IntoIter>
where I: IntoIterator, I::Item: AsRef<Tensor>,

Iterate over input tensors

Source

fn into_iter<I>(self, inputs: I) -> SeqIterator<Self, I::IntoIter>
where I: IntoIterator, I::Item: AsRef<Tensor>, Self: Sized,

Convert into an iterator over input tensors.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementations on Foreign Types§

Source§

impl<M: SeqIterative> SeqIterative for [M]

Source§

type State = Vec<<M as SeqIterative>::State>

Source§

fn initial_state(&self) -> Self::State

Source§

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

Source§

impl<M: SeqIterative, const N: usize> SeqIterative for [M; N]

Source§

type State = [<M as SeqIterative>::State; N]

Source§

fn initial_state(&self) -> Self::State

Source§

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

Source§

impl<T: SeqIterative + ?Sized> SeqIterative for &T

Source§

type State = <T as SeqIterative>::State

Source§

fn initial_state(&self) -> Self::State

Source§

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

Source§

impl<T: SeqIterative + ?Sized> SeqIterative for Box<T>

Source§

type State = <T as SeqIterative>::State

Source§

fn initial_state(&self) -> Self::State

Source§

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

Implementors§

Source§

impl SeqIterative for Activation

Iterate over a sequence by independently and identically transforming each step.

Source§

impl SeqIterative for Linear

Iterate over a sequence by independently and identically transforming each step.

Source§

impl SeqIterative for Mlp

Iterate over a sequence by independently and identically transforming each step.

Source§

impl<A, B> SeqIterative for Chain<A, B>

Source§

impl<T, F> SeqIterative for BatchMap<T, F>
where T: SeqIterative, F: Fn(Tensor) -> Tensor,