Confusion Matrix Only predicting 1 Class/Label in Multiclassification sequence classifier

Uts_geek: <p>Hi. I created a Sequence Classifier but it is only returning True Positive of B-O class. I have total of 4 classes. There is a class imbalance as B-O is almost 80-90% of the dataset but my professor told me it should not give 0’s for other classes.</p>
<p><div class="lightbox-wrapper"><a class="lightbox" href="https://discuss.pytorch.org/uploads/default/original/3X/0/f/0fc5a5037733ff886c301a3b2fb99d2dc2917899.png" data-download-href="https://discuss.pytorch.org/uploads/default/0fc5a5037733ff886c301a3b2fb99d2dc2917899" title="image"><img src="https://discuss.pytorch.org/uploads/default/optimized/3X/0/f/0fc5a5037733ff886c301a3b2fb99d2dc2917899_2_648x500.png" alt="image" data-base62-sha1="2fwC2M5BBccPWQuDkEVFNM0jqt3" width="648" height="500" srcset="https://discuss.pytorch.org/uploads/default/optimized/3X/0/f/0fc5a5037733ff886c301a3b2fb99d2dc2917899_2_648x500.png, https://discuss.pytorch.org/uploads/default/optimized/3X/0/f/0fc5a5037733ff886c301a3b2fb99d2dc2917899_2_972x750.png 1.5x, https://discuss.pytorch.org/uploads/default/original/3X/0/f/0fc5a5037733ff886c301a3b2fb99d2dc2917899.png 2x" data-dominant-color="D4D7DC"><div class="meta"><svg class="fa d-icon d-icon-far-image svg-icon" aria-hidden="true"><use href="#far-image"></use></svg><span class="filename">image</span><span class="informations">1248×962 70.3 KB</span><svg class="fa d-icon d-icon-discourse-expand svg-icon" aria-hidden="true"><use href="#discourse-expand"></use></svg></div></a></div></p>
<p>The structure of my project is<br>
word2vec for vectorization<br>
seqeval for compute_metrics<br>
RNN from PyTorch<br>
class RNN(nn.Module)<br>
SGD optimizer with lr = 1e-3</p>
<p>This is the result of my epoch<br>
Train Loss: 0.555 | Train Overall Precision: 82.43% | Train Overall Recall: 89.58% | Train Overall F1: 0.86 | Train Overall Accuracy: 82.43%<br>
Valid Loss: 0.499 | Valid Overall Precision: 85.22% | Valid Overall Recall: 91.12% | Valid Overall F1: 0.88 | Valid Overall Accuracy: 85.22%</p>
<p>I have tried changing learning rates, hidden-layers and basically everything. I even tried the same with LSTM and it was only detecting B-O. Could you potentially tell where the problem can be?<br>
Please help. I will share the relevant code but if you could tell me which part to share<br>
<a class="mention" href="/u/ptrblck">@ptrblck</a></p>

Uts_geek: <p><a class="mention" href="/u/ptrblck">@ptrblck</a><br>
I tried another setup and it showed slightly different confusion matrix. There still are zeros but it might help you identify the problem.<br>
Setup:<br>
word2vec<br>
LSTM with 1 layer<br>
SGD Optimizer with lr = 2e-5<br>
hidden_dimensions = 256</p>
<p>Everything else is the same as the other project.</p>
<p>Confusion Matrix:<br>
<div class="lightbox-wrapper"><a class="lightbox" href="https://discuss.pytorch.org/uploads/default/original/3X/0/9/092098ed7b6b1ed3417e85fc7d60ab9e704db795.png" data-download-href="https://discuss.pytorch.org/uploads/default/092098ed7b6b1ed3417e85fc7d60ab9e704db795" title="image"><img src="https://discuss.pytorch.org/uploads/default/optimized/3X/0/9/092098ed7b6b1ed3417e85fc7d60ab9e704db795_2_639x500.png" alt="image" data-base62-sha1="1iK8tNIdu7copQqLseaLXGo4o7z" width="639" height="500" srcset="https://discuss.pytorch.org/uploads/default/optimized/3X/0/9/092098ed7b6b1ed3417e85fc7d60ab9e704db795_2_639x500.png, https://discuss.pytorch.org/uploads/default/original/3X/0/9/092098ed7b6b1ed3417e85fc7d60ab9e704db795.png 1.5x, https://discuss.pytorch.org/uploads/default/original/3X/0/9/092098ed7b6b1ed3417e85fc7d60ab9e704db795.png 2x" data-dominant-color="EAF0F7"><div class="meta"><svg class="fa d-icon d-icon-far-image svg-icon" aria-hidden="true"><use href="#far-image"></use></svg><span class="filename">image</span><span class="informations">809×633 22.1 KB</span><svg class="fa d-icon d-icon-discourse-expand svg-icon" aria-hidden="true"><use href="#discourse-expand"></use></svg></div></a></div></p>

vdw: <p>Can you share the code of your model and the training loop?</p>
<p>Maybe you can look at this <a href="https://github.com/chrisvdweth/nus-cs5246/blob/master/notebooks/Named%20Entity%20Recognition%20(RNN).ipynb" rel="noopener nofollow ugc">notebook</a> and the corresponding <a href="https://github.com/chrisvdweth/nus-cs5246/blob/master/notebooks/src/rnn.py" rel="noopener nofollow ugc">source file</a> for a working example of an RNN-based NER tagger.</p>