None of the samples have been tested, what is the reason for this

Gorgen: <p>hello everyone:<br>
I don’t know what is wrong about my classification_report.why there is a category and none of the samples have been tested.<br>
classification_report<br>
precision  recall f1-score support<br>
0   0.00   0.00   0.00    37<br>
1   0.39   1.00   0.56    42<br>
2   0.67   0.06   0.11    33<br>
accuracy             0.39   112<br>
macro avg   0.35   0.35   0.22   112<br>
weighted avg   0.34   0.39   0.24   112<br>
What is the reason for this?<br>
here is all of codes.<br>
my task is about audio classification. the loss is criterion = nn.CrossEntropyLoss(), and optimizer = torch.optim.Adam(model.parameters(), lr=learning_rate).<br>
Could you please give me some suggestions?<br>
Thanks<br>
best wishes.<br>
import torch<br>
import torch.nn as nn<br>
import torchvision<br>
import torchvision.transforms as transforms<br>
from torch.utils.data import Dataset, DataLoader<br>
from datasets import SoundDataset</p>
<h1>
<a name="device-configuration-1" class="anchor" href="#device-configuration-1"></a>Device configuration</h1>
<p>device = torch.device(‘cuda’ if torch.cuda.is_available() else ‘cpu’)</p>
<h1>
<a name="hyper-parameters-2" class="anchor" href="#hyper-parameters-2"></a>Hyper-parameters</h1>
<h1>
<a name="input_size-784-28x28-3" class="anchor" href="#input_size-784-28x28-3"></a>input_size = 784 # 28x28</h1>
<p>num_classes = 3<br>
num_epochs = 1<br>
batch_size = 1<br>
learning_rate = 0.001</p>
<p>input_size = 64<br>
sequence_length = 28<br>
hidden_size = 128<br>
num_layers = 2</p>
<h1>
<a name="data-loader-4" class="anchor" href="#data-loader-4"></a>Data loader</h1>
<p>ANNOTATIONS_FILE = “F:/辅导人/姚文瀚/海天AD语音分类/traindata/data.xls”<br>
AUDIO_DIR = “F:/辅导人/姚文瀚/海天AD语音分类/traindata/audio”<br>
data = SoundDataset(ANNOTATIONS_FILE, AUDIO_DIR)<br>
print(f"There are {len(data)} samples in the dataset.")<br>
features, label = data[0]<br>
print(‘features’, features.shape)<br>
print(label)</p>
<h1>
<a name="split-5" class="anchor" href="#split-5"></a>split</h1>
<p>length = len(data)<br>
train_size, validate_size = int(0.8 * length), int(0.2 * length)</p>
<h1>
<a name="first-param-is-data-set-to-be-saperated-the-second-is-list-stating-how-many-sets-we-want-it-to-be-6" class="anchor" href="#first-param-is-data-set-to-be-saperated-the-second-is-list-stating-how-many-sets-we-want-it-to-be-6"></a>first param is data set to be saperated, the second is list stating how many sets we want it to be.</h1>
<p>train_set, test_set = torch.utils.data.random_split(data, [train_size, validate_size])<br>
print(len(train_set), len(test_set))</p>
<p><span class="hashtag">#dataloder</span></p>
<h1>
<a name="data-loader-7" class="anchor" href="#data-loader-7"></a>Data loader</h1>
<p>batch_size = 1<br>
train_loader = torch.utils.data.DataLoader(dataset=train_set,<br>
batch_size=batch_size,<br>
shuffle=True)</p>
<p>test_loader = torch.utils.data.DataLoader(dataset=test_set,<br>
batch_size=batch_size,<br>
shuffle=False)</p>
<h1>
<a name="for-i-featureslabels-in-enumeratetrain_loader-8" class="anchor" href="#for-i-featureslabels-in-enumeratetrain_loader-8"></a>for i, (features,labels) in enumerate(train_loader):</h1>
<h1>
<a name="printfeatures-featuresshape-9" class="anchor" href="#printfeatures-featuresshape-9"></a>print(‘features’, features.shape)</h1>
<h1>
<a name="printlabels-labels-10" class="anchor" href="#printlabels-labels-10"></a>print(‘labels’, labels)</h1>
<h1><a name="h-11" class="anchor" href="#h-11"></a></h1>
<h1>
<a name="print-12" class="anchor" href="#print-12"></a>print(’==================================================’)</h1>
<h1>
<a name="for-i-featureslabels-in-enumeratetest_loader-13" class="anchor" href="#for-i-featureslabels-in-enumeratetest_loader-13"></a>for i, (features,labels) in enumerate(test_loader):</h1>
<h1>
<a name="printfeatures-featuresshape-14" class="anchor" href="#printfeatures-featuresshape-14"></a>print(‘features’, features.shape)</h1>
<h1>
<a name="printlabels-labels-15" class="anchor" href="#printlabels-labels-15"></a>print(‘labels’, labels)</h1>
<p><span class="hashtag">#models</span></p>
<h1>
<a name="fully-connected-neural-network-with-one-hidden-layer-16" class="anchor" href="#fully-connected-neural-network-with-one-hidden-layer-16"></a>Fully connected neural network with one hidden layer</h1>
<p>class LSTM(nn.Module):<br>
def <strong>init</strong>(self, input_size, hidden_size, num_layers, num_classes):<br>
super(LSTM, self).<strong>init</strong>()<br>
self.num_layers = num_layers<br>
self.hidden_size = hidden_size<br>
# self.rnn = nn.RNN(input_size, hidden_size, num_layers, batch_first=True)<br>
# → x needs to be: (batch_size, seq, input_size)</p>
<pre><code>    # self.gru = nn.GRU(input_size, hidden_size, num_layers, batch_first=True)
    self.lstm = nn.LSTM(input_size, hidden_size, num_layers, batch_first=True)
    self.fc = nn.Linear(hidden_size, num_classes)

def forward(self, x):
    # Set initial hidden states (and cell states for LSTM)
    h0 = torch.zeros(self.num_layers, x.size(0), self.hidden_size).to(device)
    c0 = torch.zeros(self.num_layers, x.size(0), self.hidden_size).to(device)

    # x: (n, 28, 28), h0: (2, n, 128)

    # Forward propagate RNN
    # out, _ = self.rnn(x, h0)
    # or:
    out, _ = self.lstm(x, (h0, c0))

    # out: tensor of shape (batch_size, seq_length, hidden_size)
    # out: (n, 28, 128)

    # Decode the hidden state of the last time step
    out = out[:, -1, :]
    # out: (n, 128)

    out = self.fc(out)
    # out: (n, 10)
    return out
</code></pre>
<p>model = LSTM(input_size, hidden_size, num_layers, num_classes).to(device)<br>
print(model)</p>
<h1>
<a name="loss-and-optimizer-17" class="anchor" href="#loss-and-optimizer-17"></a>Loss and optimizer</h1>
<p>criterion = nn.CrossEntropyLoss()<br>
optimizer = torch.optim.Adam(model.parameters(), lr=learning_rate)</p>
<h1>
<a name="train-the-model-18" class="anchor" href="#train-the-model-18"></a>Train the model</h1>
<p>n_total_steps = len(train_loader)<br>
for epoch in range(num_epochs):<br>
for i, (features, labels) in enumerate(train_loader):<br>
# batch, seq, mel<br>
features = features.to(device)<br>
labels = labels.to(device)</p>
<pre><code>    # Forward pass
    outputs = model(features)
    loss = criterion(outputs, labels)

    # Backward and optimize
    optimizer.zero_grad()
    loss.backward()
    optimizer.step()

    if (i + 1) % 100 == 0:
        print(f'Epoch [{epoch + 1}/{num_epochs}], Step [{i + 1}/{n_total_steps}], Loss: {loss.item():.4f}')
</code></pre>
<h1>
<a name="test-the-model-19" class="anchor" href="#test-the-model-19"></a>Test the model</h1>
<h1>
<a name="in-test-phase-we-dont-need-to-compute-gradients-for-memory-efficiency-20" class="anchor" href="#in-test-phase-we-dont-need-to-compute-gradients-for-memory-efficiency-20"></a>In test phase, we don’t need to compute gradients (for memory efficiency)</h1>
<p>with torch.no_grad():<br>
n_correct = 0<br>
n_samples = 0<br>
for features, labels in test_loader:<br>
features = features.to(device)<br>
labels = labels.to(device)</p>
<pre><code>    # Forward pass
    outputs = model(features)
    # max returns (value ,index)
    _, predicted = torch.max(outputs.data, 1)
    n_samples += labels.size(0)
    n_correct += (predicted == labels).sum().item()

acc = 100.0 * n_correct / n_samples
print(f'Accuracy of the network on the 10000 test images: {acc} %')
</code></pre>
<p>from sklearn.metrics import confusion_matrix, classification_report<br>
import seaborn as sn<br>
import pandas as pd<br>
import numpy as np</p>
<h1>
<a name="plt-21" class="anchor" href="#plt-21"></a>plt</h1>
<p>import matplotlib.pyplot as plt</p>
<p>y_pred = []<br>
y_true = []</p>
<h1>
<a name="iterate-over-test-data-22" class="anchor" href="#iterate-over-test-data-22"></a>iterate over test data</h1>
<p>for features, labels in test_loader:<br>
features = features.to(device)<br>
labels = labels.to(device)</p>
<pre><code># Forward pass
output = model(features)
output = (torch.max(torch.exp(output), 1)[1]).data.cpu().numpy()
y_pred.extend(output)  # Save Prediction

labels = labels.data.cpu().numpy()
y_true.extend(labels)  # Save Truth
</code></pre>
<h1>
<a name="constant-for-classes-23" class="anchor" href="#constant-for-classes-23"></a>constant for classes</h1>
<p>classes = (‘AD’, ‘HC’, ‘MCI’)</p>
<h1>
<a name="build-confusion-report-24" class="anchor" href="#build-confusion-report-24"></a>Build confusion report</h1>
<p>cf_report = classification_report(y_true, y_pred)<br>
print(cf_report)</p>
<h1>
<a name="build-confusion-matrix-25" class="anchor" href="#build-confusion-matrix-25"></a>Build confusion matrix</h1>
<p>cf_matrix = confusion_matrix(y_true, y_pred)<br>
df_cm = pd.DataFrame(cf_matrix / np.sum(cf_matrix) * 10, index=[i for i in classes],<br>
columns=[i for i in classes])<br>
plt.figure(figsize=(12, 7))<br>
sn.heatmap(df_cm, annot=True)<br>
plt.savefig(‘output.png’)</p>