pub struct RNNCell<B>where
B: Backend,{
pub input_size: usize,
pub hidden_size: usize,
/* private fields */
}Expand description
A single-step vanilla RNN cell.
Computes: h' = tanh(x @ W_ih^T + b_ih + h @ W_hh^T + b_hh)
§Shapes
- input x:
[batch, input_size] - hidden h:
[batch, hidden_size] - output h’:
[batch, hidden_size]
Fields§
§input_size: usizeImplementations§
Source§impl<B> RNNCell<B>where
B: Backend,
impl<B> RNNCell<B>where
B: Backend,
Sourcepub fn new(
input_size: usize,
hidden_size: usize,
use_bias: bool,
dtype: DType,
device: &<B as Backend>::Device,
) -> Result<RNNCell<B>, Error>
pub fn new( input_size: usize, hidden_size: usize, use_bias: bool, dtype: DType, device: &<B as Backend>::Device, ) -> Result<RNNCell<B>, Error>
Create a new RNNCell with Kaiming uniform initialization.
Sourcepub fn forward(&self, x: &Tensor<B>, h: &Tensor<B>) -> Result<Tensor<B>, Error>
pub fn forward(&self, x: &Tensor<B>, h: &Tensor<B>) -> Result<Tensor<B>, Error>
Forward: h’ = tanh(x @ W_ih^T + b_ih + h @ W_hh^T + b_hh)
x:[batch, input_size]h:[batch, hidden_size]- returns h’:
[batch, hidden_size]
Sourcepub fn parameters(&self) -> Vec<Tensor<B>>
pub fn parameters(&self) -> Vec<Tensor<B>>
Return all trainable parameters.
Sourcepub fn named_parameters(&self) -> Vec<(String, Tensor<B>)>
pub fn named_parameters(&self) -> Vec<(String, Tensor<B>)>
Return all trainable parameters with names.
Auto Trait Implementations§
impl<B> Freeze for RNNCell<B>
impl<B> RefUnwindSafe for RNNCell<B>
impl<B> Send for RNNCell<B>
impl<B> Sync for RNNCell<B>
impl<B> Unpin for RNNCell<B>
impl<B> UnwindSafe for RNNCell<B>
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
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more