RNN_Sent140#
- class fl_sim.models.RNN_Sent140(latent_size: int = 100, num_classes: int = 2, num_layers: int = 2, embedding: str | object = 'glove.6B.50d')[source]#
Bases:
Module
,CLFMixin
,SizeMixin
,DiffMixin
Stacked
LSTM
model for sentiment analysis on theSent140
dataset.Adapted from FedProx/flearn/models/sent140/stacked_lstm.py [1].
- Parameters:
latent_size (int, default 100) – The number of features in the hidden state h.
num_classes (int, default 2) – The number of output classes.
num_layers (int, default 2) – The number of recurrent layers (
LSTM
).embedding (str or
GloveEmbedding
, default “glove.6B.50d”) – The name of the pre-trained GloVe embedding to use or aGloveEmbedding
object.
References
- forward(input_seq: Tensor) Tensor [source]#
Forward pass.
- Parameters:
input_seq (torch.Tensor) – Shape
(batch_size, seq_len)
, dtypetorch.long
.- Returns:
Shape
(batch_size, num_classes)
, dtypetorch.float32
.- Return type: