pub struct Rnn { /* private fields */ }Expand description
Stacked batch-first Elman recurrent network using whole-sequence GPU scans.
Input uses [batch, sequence, input]; output uses
[batch, sequence, hidden]. Every layer starts from a zero hidden state.
Implementations§
Source§impl Rnn
impl Rnn
pub fn new_with_seed( input_size: usize, hidden_size: usize, num_layers: usize, seed: u64, ) -> Result<Self>
Sourcepub fn new_with_seed_on(
runtime: &Runtime,
input_size: usize,
hidden_size: usize,
num_layers: usize,
seed: u64,
) -> Result<Self>
pub fn new_with_seed_on( runtime: &Runtime, input_size: usize, hidden_size: usize, num_layers: usize, seed: u64, ) -> Result<Self>
Construct a deterministically initialized stacked RNN with biases.
§Errors
Returns an error when a dimension or layer count is zero, hidden size exceeds the 1024-element scan limit, arithmetic overflows, or parameter allocation and registration fail.
pub fn new_with_seed_and_bias( input_size: usize, hidden_size: usize, num_layers: usize, bias: bool, seed: u64, ) -> Result<Self>
Sourcepub fn new_with_seed_and_bias_on(
runtime: &Runtime,
input_size: usize,
hidden_size: usize,
num_layers: usize,
bias: bool,
seed: u64,
) -> Result<Self>
pub fn new_with_seed_and_bias_on( runtime: &Runtime, input_size: usize, hidden_size: usize, num_layers: usize, bias: bool, seed: u64, ) -> Result<Self>
Construct a deterministically initialized stacked RNN with optional biases.
§Errors
Returns an error when a dimension or layer count is zero, hidden size exceeds the 1024-element scan limit, arithmetic overflows, or parameter allocation and registration fail.
Sourcepub fn new_from_matrices(
weight_ih: Matrix,
weight_hh: Matrix,
bias_ih: Matrix,
bias_hh: Matrix,
) -> Result<Self>
pub fn new_from_matrices( weight_ih: Matrix, weight_hh: Matrix, bias_ih: Matrix, bias_hh: Matrix, ) -> Result<Self>
Construct a one-layer biased RNN from exact parameter matrices.
§Errors
Returns an error unless weights use [H, I] and [H, H], biases use
[H], and all values satisfy the F32 runtime and hidden-size contract.
Sourcepub fn new_from_weights(weight_ih: Matrix, weight_hh: Matrix) -> Result<Self>
pub fn new_from_weights(weight_ih: Matrix, weight_hh: Matrix) -> Result<Self>
Construct a one-layer bias-free RNN from exact weight matrices.
§Errors
Returns an error unless both weights satisfy the F32 runtime, shape, and hidden-size contract.
Sourcepub fn forward(&self, input: &Matrix) -> Result<Matrix>
pub fn forward(&self, input: &Matrix) -> Result<Matrix>
Evaluate the complete sequence with one input projection and one recurrent scan dispatch per layer.
§Errors
Returns an error unless input is same-runtime F32 [B, S, I] with nonzero
extents and the configured input width, or when recording fails.
Sourcepub const fn input_size(&self) -> usize
pub const fn input_size(&self) -> usize
Return the configured input width.
Return the recurrent hidden width.
Sourcepub fn num_layers(&self) -> usize
pub fn num_layers(&self) -> usize
Return the number of stacked recurrent layers.
Sourcepub fn all_parameters(&self) -> Result<Vec<Parameter>>
pub fn all_parameters(&self) -> Result<Vec<Parameter>>
Return every parameter through the registered layer tree.
Trait Implementations§
Source§impl Module for Rnn
impl Module for Rnn
Source§fn forward(&self, input: &Matrix) -> Result<Matrix>
fn forward(&self, input: &Matrix) -> Result<Matrix>
Source§fn registry(&self) -> &ModuleRegistry
fn registry(&self) -> &ModuleRegistry
Source§fn parameters(&self) -> Vec<Parameter>
fn parameters(&self) -> Vec<Parameter>
Source§fn named_parameters(&self) -> Vec<NamedParameter>
fn named_parameters(&self) -> Vec<NamedParameter>
Source§fn named_buffers(&self) -> Vec<NamedBuffer>
fn named_buffers(&self) -> Vec<NamedBuffer>
Source§fn all_parameters(&self) -> Result<Vec<Parameter>>
fn all_parameters(&self) -> Result<Vec<Parameter>>
Source§fn all_named_parameters(&self) -> Result<Vec<NamedParameter>>
fn all_named_parameters(&self) -> Result<Vec<NamedParameter>>
Source§fn all_named_buffers(&self) -> Result<Vec<NamedBuffer>>
fn all_named_buffers(&self) -> Result<Vec<NamedBuffer>>
Source§fn all_named_state_u32(&self) -> Result<Vec<NamedStateU32>>
fn all_named_state_u32(&self) -> Result<Vec<NamedStateU32>>
u32 scalar state in
deterministic depth-first order. Read more