A-Hackers-AI-Voice-Assistant icon indicating copy to clipboard operation
A-Hackers-AI-Voice-Assistant copied to clipboard

Decode without beam search

Open Khanifsaleh opened this issue 3 years ago • 0 comments

Hi, what a amazing repository.

After got out/logits of model, how to decode it without beamsearch? i've been run like this in my model ( and I have id2labels

{0: "'", 1: ' ', 2: 'a', 3: 'b', 4: 'c', 5: 'd', 6: 'e', 7: 'f', 8: 'g', 9: 'h', 10: 'i', 11: 'j', 12: 'k', 13: 'l', 14: 'm', 15: 'n', 16: 'o', 17: 'p', 18: 'q', 19: 'r', 20: 's', 21: 't', 22: 'u', 23: 'v', 24: 'w', 25: 'x', 26: 'y', 27: 'z', 28: '_'}

)

with torch.no_grad():
        log_mel = featurizer(waveform).unsqueeze(1)
        out, hidden = model(log_mel, hidden)
        out = torch.nn.functional.softmax(out, dim=2)
        out = out.transpose(0, 1)
        pred_ids = torch.argmax(out, -1)
        preds = [id2label[i] for i in pred_ids[0].tolist() if id2label[i]!='_']

is that right?

Khanifsaleh avatar Jul 06 '21 14:07 Khanifsaleh