Hi,
I would suggest you to first look at the documentation on how to create models in pytorch, it uses a class implementation and forward function for forward pass, & how nn.Module is inherited in the Model class.
To improve your model, here are a few suggestions :
Firstly I would suggest you to squeeze in the inner dimension of input and cast it into a shape of (batch_size, seq_len) as you want to use batch_first in your model.
Secondly, call the object of embedding layer over input directly (for loop is not needed as you did).
Since you are using bidirectional = True, it will automatically merge the output of forward direction & backward direction. So you don’t need to explicitly concatenate the outputs.
As you want to learn a sentiment analysis model, then there will be 3 possibilities I guess : neutral, positive & negative i.e. 3 classes. So either use the output of last hidden state (or pool the output of all the hidden states) to get a vector of shape (batch_size, 2*hidden_dim).
Use a linear projection layer to convert the dimension size equal to number of classes (i.e. 3). Use softmax if you are using NLL loss or you can directly use Crossentropy loss.