% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/EncoderRNN.R
\name{EncoderRNN}
\alias{EncoderRNN}
\title{EncoderRNN Neural Network Module}
\usage{
EncoderRNN(input_size, nhidden, nlayers, dropout)
}
\arguments{
\item{input_size}{A numeric value representing the number of features in the input data.}

\item{nhidden}{A numeric value representing the number of hidden units in each LSTM layer.}

\item{nlayers}{A numeric value indicating the number of LSTM layers.}

\item{dropout}{A numeric value between 0 and 1 indicating the dropout probability to be applied between LSTM layers.}
}
\value{
An \code{nn_module} object (torch LSTM-based encoder). When called
with a tensor of shape \code{(batch_size, seq_len, input_size)}, returns a
list of: (1) processed output tensor, (2) list of hidden and cell states
\code{(hn, cn)}, and (3) the input with a leading zero tensor prepended.
}
\description{
An RNN-based encoder module using Long Short-Term Memory (LSTM) architecture, implemented with the \code{torch} package.
This module is designed to process sequential data and is commonly used in tasks like sequence-to-sequence modeling, language modeling, and time series forecasting.
}
\section{Usage}{

\preformatted{
EncoderRNN <- nn_module(
  "EncoderRNN",

  initialize = function(input_size, nhidden, nlayers, dropout) {
    ...
  },

  forward = function(x) {
    ...
  }
)
}
}

\section{Methods}{

\describe{
\item{\code{initialize(input_size, nhidden, nlayers, dropout)}}{
Initializes the EncoderRNN module.

\if{html}{\out{<div class="sourceCode">}}\preformatted{\\itemize\{
  \\item\{\code{input_size}: A numeric value representing the number of features in the input data.\}
  \\item\{\code{nhidden}: A numeric value representing the number of hidden units in each LSTM layer.\}
  \\item\{\code{nlayers}: A numeric value indicating the number of LSTM layers.\}
  \\item\{\code{dropout}: A numeric value between 0 and 1 indicating the dropout probability to be applied between LSTM layers.\}
\}
}\if{html}{\out{</div>}}

}

\item{\code{forward(x)}}{
Executes the forward pass of the EncoderRNN module.

\if{html}{\out{<div class="sourceCode">}}\preformatted{\\itemize\{
  \\item\{\code{x}: A tensor of shape (batch_size, sequence_length, input_size) representing the input data.\}
\}

\\value\{
A list containing:
  \\itemize\{
    \\item\{\code{output}: The output tensor from the LSTM, processed and flipped.\}
    \\item\{\code{list(hn, cn)}: A list containing the hidden state (\code{hn}) and cell state (\code{cn}) from the LSTM.\}
    \\item\{\code{newinput}: A tensor representing the input data with an additional zero tensor at the beginning.\}
  \}
\}
}\if{html}{\out{</div>}}

}
}
}

\examples{
\donttest{
enc <- EncoderRNN(input_size = 4L, nhidden = 8L, nlayers = 1L, dropout = 0.0)
x   <- torch::torch_randn(2L, 1L, 4L)   # batch=2, seq_len=1, features=4
out <- enc(x)
dim(out[[1]])  # encoded output
}
}
