I'm currently facing an issue that's been giving me a hard time. I'm participating in a competition with a looming deadline, and I'm stuck trying to solve this problem.
I'm using the code from this GitHub repository, which unfortunately seems to be inactive. The error I'm encountering is:
"input contains nan, infinity or a value too large for dtype('float32)"
This error occurs within the train function:
def train(train_loader, model, optimizer, loss_fn, device, epoch):
print("\n starting train for epoch %s"%epoch)
losses = []
preds = []
labels = []
for idx, (mfcc, label) in enumerate(train_loader):
mfcc, label = mfcc.to(device), label.to(device)
optimizer.zero_grad()
output = model(mfcc)
# pred = F.sigmoid(output)
loss = loss_fn(torch.flatten(output), label)
loss.backward()
optimizer.step()
losses.append(loss.item())
# get predictions and labels for report
pred = torch.sigmoid(output)
preds += torch.flatten(torch.round(pred)).cpu()
labels += torch.flatten(label).cpu()
print("epoch: {}, Iter: {}/{}, loss: {}".format(epoch, idx, len(train_loader), loss.item()), end="\r")
avg_train_loss = sum(losses)/len(losses)
acc = binary_accuracy(torch.Tensor(preds), torch.Tensor(labels))
print('avg train loss:', avg_train_loss, "avg train acc", acc)
a = torch.Tensor(labels)
b = torch.Tensor(preds)
report = classification_report(a.numpy(), b.numpy())
return acc, report
The error arises when generating the classification_report.
I've tried checking the values of a and b using numpy.isnan() and numpy.isfinite() methods, but I'm getting the error:
"ValueError: The truth value of a boolean with more than one value is ambiguous."
It seems that the .numpy() method is causing this issue, and I'm not sure why.
Some additional information that might be helpful: I'm using Mozilla's Common Voice dataset, where I've converted each audio file into an 8000Hz WAV file. Additionally, the data I'm using for the wake word itself was recorded by me using the collect_wakeword.py file from the repository.
I'd greatly appreciate any assistance you can provide !