shredx.modules.rnn.GRUEncoder#
- class shredx.modules.rnn.GRUEncoder(input_size: int, hidden_size: int, num_layers: int, dropout: float, device: str = 'cpu', **kwargs)#
Bases:
ModuleGRU encoder for sequence-to-sequence modeling.
Wraps PyTorch’s
GRUwith dropout and output reshaping for compatibility with encoder–decoder architectures.- Parameters:
- input_sizeint
Input feature dimension.
- hidden_sizeint
Hidden state dimension.
- num_layersint
Number of stacked GRU layers.
- dropoutfloat
Dropout probability applied to the outputs.
- devicestr, optional
Device on which to place the module. Default is
"cpu".- **kwargs
Additional keyword arguments passed for compatibility but ignored.
Methods
forward(x)Apply the GRU encoder to an input batch.
Notes
Class Methods:
forward(x):
Applies the GRU encoder to an input batch.
- Parameters:
x :
Float[torch.Tensor, "batch sequence input_size"]. Input tensor.
- Returns:
tuple. Tuple containing the final output tensor of shape
(batch_size, 1, 1, hidden_size)andNonefor no auxiliary losses.