pub struct LSTMCell<B>where
B: Backend,{
pub input_size: usize,
pub hidden_size: usize,
/* private fields */
}Expand description
A single-step LSTM cell.
§Shapes
- input x:
[batch, input_size] - hidden h:
[batch, hidden_size] - cell c:
[batch, hidden_size] - output (h’, c’):
([batch, hidden_size], [batch, hidden_size])
Fields§
§input_size: usizeImplementations§
Source§impl<B> LSTMCell<B>where
B: Backend,
impl<B> LSTMCell<B>where
B: Backend,
Sourcepub fn new(
input_size: usize,
hidden_size: usize,
use_bias: bool,
dtype: DType,
device: &<B as Backend>::Device,
) -> Result<LSTMCell<B>, Error>
pub fn new( input_size: usize, hidden_size: usize, use_bias: bool, dtype: DType, device: &<B as Backend>::Device, ) -> Result<LSTMCell<B>, Error>
Create a new LSTMCell with Kaiming uniform initialization.
Sourcepub fn forward(
&self,
x: &Tensor<B>,
h: &Tensor<B>,
c: &Tensor<B>,
) -> Result<(Tensor<B>, Tensor<B>), Error>
pub fn forward( &self, x: &Tensor<B>, h: &Tensor<B>, c: &Tensor<B>, ) -> Result<(Tensor<B>, Tensor<B>), Error>
Forward: compute (h’, c’) from (x, h, c)
x:[batch, input_size]h:[batch, hidden_size]c:[batch, hidden_size]- returns
(h', c'):([batch, hidden_size], [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 LSTMCell<B>
impl<B> RefUnwindSafe for LSTMCell<B>
impl<B> Send for LSTMCell<B>
impl<B> Sync for LSTMCell<B>
impl<B> Unpin for LSTMCell<B>
impl<B> UnwindSafe for LSTMCell<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