pub struct GRUCell {Show 17 fields
pub w_ir: Array2<f64>,
pub w_hr: Array2<f64>,
pub b_ir: Array2<f64>,
pub b_hr: Array2<f64>,
pub w_iz: Array2<f64>,
pub w_hz: Array2<f64>,
pub b_iz: Array2<f64>,
pub b_hz: Array2<f64>,
pub w_ih: Array2<f64>,
pub w_hh: Array2<f64>,
pub b_ih: Array2<f64>,
pub b_hh: Array2<f64>,
pub hidden_size: usize,
pub input_dropout: Option<Dropout>,
pub recurrent_dropout: Option<Dropout>,
pub output_dropout: Option<Dropout>,
pub is_training: bool,
}
Expand description
GRU cell with trainable parameters and dropout support
Fields§
§w_ir: Array2<f64>
§w_hr: Array2<f64>
§b_ir: Array2<f64>
§b_hr: Array2<f64>
§w_iz: Array2<f64>
§w_hz: Array2<f64>
§b_iz: Array2<f64>
§b_hz: Array2<f64>
§w_ih: Array2<f64>
§w_hh: Array2<f64>
§b_ih: Array2<f64>
§b_hh: Array2<f64>
§input_dropout: Option<Dropout>
§recurrent_dropout: Option<Dropout>
§output_dropout: Option<Dropout>
§is_training: bool
Implementations§
Source§impl GRUCell
impl GRUCell
Sourcepub fn new(input_size: usize, hidden_size: usize) -> Self
pub fn new(input_size: usize, hidden_size: usize) -> Self
Creates new GRU cell with Xavier-uniform weight initialization
pub fn with_input_dropout(self, dropout_rate: f64, variational: bool) -> Self
pub fn with_recurrent_dropout( self, dropout_rate: f64, variational: bool, ) -> Self
pub fn with_output_dropout(self, dropout_rate: f64) -> Self
pub fn train(&mut self)
pub fn eval(&mut self)
pub fn forward(&mut self, input: &Array2<f64>, hx: &Array2<f64>) -> Array2<f64>
pub fn forward_with_cache( &mut self, input: &Array2<f64>, hx: &Array2<f64>, ) -> (Array2<f64>, GRUCellCache)
Sourcepub fn backward(
&self,
dhy: &Array2<f64>,
cache: &GRUCellCache,
) -> (GRUCellGradients, Array2<f64>, Array2<f64>)
pub fn backward( &self, dhy: &Array2<f64>, cache: &GRUCellCache, ) -> (GRUCellGradients, Array2<f64>, Array2<f64>)
Backward pass implementing GRU gradient computation with dropout
Returns (parameter_gradients, input_gradient, hidden_gradient)
Sourcepub fn zero_gradients(&self) -> GRUCellGradients
pub fn zero_gradients(&self) -> GRUCellGradients
Initialize zero gradients for accumulation
Sourcepub fn update_parameters<O: Optimizer>(
&mut self,
gradients: &GRUCellGradients,
optimizer: &mut O,
prefix: &str,
)
pub fn update_parameters<O: Optimizer>( &mut self, gradients: &GRUCellGradients, optimizer: &mut O, prefix: &str, )
Apply gradients using the provided optimizer
Trait Implementations§
Auto Trait Implementations§
impl Freeze for GRUCell
impl RefUnwindSafe for GRUCell
impl Send for GRUCell
impl Sync for GRUCell
impl Unpin for GRUCell
impl UnwindSafe for GRUCell
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more