More strange thing are the following, I slightly modified some places, and the loss started to change but still doesn’t converge. I wonder if someone could help me with this.
import torch.nn as nn
import torch.nn.functional as F

vocab_size = len(vocab_ids) + 1
output_size = 3
embedding_dim = 100
hidden_dim = 128
num_layers = 1

class sentiment_lstm(nn.Module):
    """An LSTM model for text classification."""
    def __init__(self):
        super(sentiment_lstm, self).__init__()
        self.embedding = nn.Embedding(vocab_size, embedding_dim)
        self.lstm = nn.LSTM(embedding_dim, hidden_dim, num_layers, batch_first=True, bidirectional=False)
        # fully connected
        self.linear = nn.Linear(hidden_dim, output_size)
        # softmax
        self.softmax = nn.LogSoftmax(dim=1)
        # dropout layer
        self.dropout = nn.Dropout(0.3)
        
    def forward(self, x, hidden):
        embeds = self.embedding(x)
        out, hidden = self.lstm(embeds, hidden)
        # fully connected
        out = self.linear(out[:, -1, :])
        out = F.relu(out)
        # softmax
        out = self.softmax(out)
        # dropout
        out = self.dropout(out)
        return out, hidden
    
    def init_hidden(self):
        if (train_on_gpu):
            hidden = (torch.zeros(num_layers, batch_size, hidden_dim).cuda(), 
                      torch.zeros(num_layers, batch_size, hidden_dim).cuda())
        else:
            hidden = (torch.zeros(num_layers, batch_size, hidden_dim), 
                      torch.zeros(num_layers, batch_size, hidden_dim))
        return hidden

net = sentiment_lstm()
train_on_gpu = torch.cuda.is_available()
print("train_on_gpu:", train_on_gpu)

lr = 0.00005
criterion = nn.NLLLoss()
optimizer = torch.optim.Adam(net.parameters(), lr=lr)
epochs = 50
print_every = 100
clip = 5  # gradient clipping

training_losses = []

if (train_on_gpu):
    net.cuda()
    
net.train()
for epoch in range(epochs):
    hidden = net.init_hidden()
    temp_loss = []
    for inputs, labels in train_loader:
        optimizer.zero_grad()
        if (train_on_gpu):
            inputs, labels = inputs.cuda(), labels.cuda()
        hidden = tuple([each.data for each in hidden])
        output, hidden = net(inputs, hidden)
        loss = criterion(output, labels)
        loss.backward()
        temp_loss.append(loss.detach().cpu().numpy())
        # prevent exploding gradient problem
        nn.utils.clip_grad_norm_(net.parameters(), clip)
        optimizer.step()
    training_losses.append(sum(temp_loss) / len(temp_loss))
    print("Epoch: {}/{}...".format(epoch + 1, epochs),
         "Loss: {:.6f}...".format(sum(temp_loss) / len(temp_loss)))

Epoch: 1/50... Loss: 0.862115...
Epoch: 2/50... Loss: 0.854747...
Epoch: 3/50... Loss: 0.841312...
Epoch: 4/50... Loss: 0.855828...
Epoch: 5/50... Loss: 0.878623...
Epoch: 6/50... Loss: 0.836831...
Epoch: 7/50... Loss: 0.856545...
Epoch: 8/50... Loss: 0.861678...
Epoch: 9/50... Loss: 0.855534...
Epoch: 10/50... Loss: 0.853875...
Epoch: 11/50... Loss: 0.842848...
Epoch: 12/50... Loss: 0.841553...
Epoch: 13/50... Loss: 0.868869...
Epoch: 14/50... Loss: 0.874237...
Epoch: 15/50... Loss: 0.860539...
Epoch: 16/50... Loss: 0.850290...
Epoch: 17/50... Loss: 0.872914...
Epoch: 18/50... Loss: 0.861847...
Epoch: 19/50... Loss: 0.854308...
Epoch: 20/50... Loss: 0.859626...
Epoch: 21/50... Loss: 0.864332...
Epoch: 22/50... Loss: 0.848013...
Epoch: 23/50... Loss: 0.863113...
Epoch: 24/50... Loss: 0.852868...
Epoch: 25/50... Loss: 0.859522...
Epoch: 26/50... Loss: 0.849938...
Epoch: 27/50... Loss: 0.854970...
Epoch: 28/50... Loss: 0.855755...
Epoch: 29/50... Loss: 0.860601...
Epoch: 30/50... Loss: 0.873638...
Epoch: 31/50... Loss: 0.866688...
Epoch: 32/50... Loss: 0.843742...
Epoch: 33/50... Loss: 0.849657...
Epoch: 34/50... Loss: 0.856069...
Epoch: 35/50... Loss: 0.859831...
Epoch: 36/50... Loss: 0.849212...
Epoch: 37/50... Loss: 0.852001...
Epoch: 38/50... Loss: 0.860625...
Epoch: 39/50... Loss: 0.878451...
Epoch: 40/50... Loss: 0.862692...
Epoch: 41/50... Loss: 0.856125...
Epoch: 42/50... Loss: 0.865457...
Epoch: 43/50... Loss: 0.866801...
Epoch: 44/50... Loss: 0.854730...
Epoch: 45/50... Loss: 0.854684...
Epoch: 46/50... Loss: 0.862919...
Epoch: 47/50... Loss: 0.858217...
Epoch: 48/50... Loss: 0.854350...
Epoch: 49/50... Loss: 0.864497...
Epoch: 50/50... Loss: 0.863351...