Accuracy not change after increasing epochs

Asonjay: <p>Hi, I have been implementing a deep averaging network with GloVE pre-trained weights using PyTorch. I haven’t implemented batching in my code yet, but so far my prediction accuracy is only 50% even after I increase my epoch it is still the same. I have been researching a lot and found nothing. Could you please help me with it?</p>
<p>Model:</p>
<blockquote>
<p>class NeuralSentimentClassifier(SentimentClassifier, nn.Module):<br>
def <strong>init</strong>(<br>
self,<br>
word_embeddings,<br>
inp_size,<br>
hid_size,<br>
out_size,<br>
dp = 0.3<br>
):<br>
super(NeuralSentimentClassifier, self).<strong>init</strong>()<br>
self.word_embeddings = word_embeddings<br>
self.embedding = nn.Embedding.from_pretrained(<br>
torch.from_numpy(self.word_embeddings.vectors),<br>
padding_idx=0,<br>
)<br>
self.embedding.weight.requires_grad = False<br>
self.model = nn.Sequential(<br>
<span class="hashtag-raw">#nn</span>.BatchNorm1d(inp_size),<br>
<span class="hashtag-raw">#nn</span>.Dropout(dp),<br>
nn.Linear(inp_size, hid_size),<br>
nn.ReLU(),<br>
<span class="hashtag-raw">#nn</span>.BatchNorm1d(emb_size),<br>
nn.Linear(hid_size, out_size),<br>
<span class="hashtag-raw">#nn</span>.Dropout(dp)<br>
)<br>
self.log_softmax = nn.LogSoftmax(dim=0)</p>
</blockquote>
<pre><code>def get_mean_embedding(self, ex_words: List[str]):
    word_idx = []
    for word in ex_words:
        idx = self.word_embeddings.word_indexer.index_of(word)
        word_idx.append(idx if idx != -1 else 1)
    emb = self.embedding(torch.LongTensor(word_idx))
    return torch.mean(emb, dim=0)
    
def forward(self, ex_words: List[str]):
    out = self.model(self.get_mean_embedding(ex_words))
    return self.log_softmax(out)

def predict(self, ex_words: List[str]) -&gt; int:
    return torch.argmax(self.forward(ex_words))
</code></pre>
<p>Train DAN:</p>
<blockquote>
<p>def train_deep_averaging_network(args, train_exs: List[SentimentExample], dev_exs: List[SentimentExample], word_embeddings: WordEmbeddings) → NeuralSentimentClassifier:<br>
“”"<br>
:param args: Command-line args so you can access them here<br>
:param train_exs: training examples<br>
:param dev_exs: development set, in case you wish to evaluate your model during training<br>
:param word_embeddings: set of loaded word embeddings<br>
:return: A trained NeuralSentimentClassifier model<br>
“”"<br>
num_classes = 2<br>
num_epoch = 5<br>
batch_size = 128<br>
DAN = NeuralSentimentClassifier(<br>
word_embeddings,<br>
inp_size=word_embeddings.get_embedding_length(), # 50 or 300<br>
hid_size=4,<br>
out_size=num_classes,<br>
)<br>
DAN.double() # Numpy float64 problem<br>
optimizer = optim.Adam(DAN.parameters(), lr=0.1)<br>
loss_function = nn.NLLLoss()</p>
</blockquote>
<pre><code>random.shuffle(train_exs)
for epoch in range(num_epoch):
    total_loss = 0.0
    for se in train_exs:
        #1# Prepare for inputs
        x = se.words
        y = torch.zeros(num_classes, dtype=torch.long)
        # scatter will write the value of 1 into the position of y_onehot given by y
        y.scatter_(0, torch.from_numpy(np.asarray(se.label, dtype=np.int64)), 1)
        #2# Zero the weights             
        DAN.zero_grad()
        #3# Forward the embedding
        log_probs = DAN.forward(x)
        #4# Calculate Loss
        loss = loss_function(log_probs, y)
        #5# Backprop and update loss
        loss.backward()
        optimizer.step()    
        total_loss += loss
    print(epoch, "-&gt;", total_loss)       
return DAN
</code></pre>
<p>My train_exs is a list of object with consists of {list[str]; words, list[int]:label}. This DAN is used to do sentiment analysis from given sentences.</p>