when i try the tutorial ASR_with_NeMo , AttributeError: 'EncDecCTCModel' object has no attribute 'wer' #8659
Unanswered
Daniel70-liu
asked this question in
Q&A
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
This error occurs when I perform the inference step. I don't know why. Can anyone kindly teach me?
Bigger batch-size = bigger throughput
params['model']['validation_ds']['batch_size'] = 16
first_asr_model.setup_test_data(test_data_config=params['model']['validation_ds'])
first_asr_model.cuda()
first_asr_model.eval()
wer_nums = []
wer_denoms = []
for test_batch in first_asr_model.test_dataloader():
test_batch = [x.cuda() for x in test_batch]
targets = test_batch[2]
targets_lengths = test_batch[3]
log_probs, encoded_len, greedy_predictions = first_asr_model(
input_signal=test_batch[0], input_signal_length=test_batch[1]
)
first_asr_model.wer.update(predictions=greedy_predictions, predictions_lengths=None, targets=targets, targets_lengths=targets_lengths)
_, wer_num, wer_denom = first_asr_model.wer.compute()
first_asr_model.wer.reset()
wer_nums.append(wer_num.detach().cpu().numpy())
wer_denoms.append(wer_denom.detach().cpu().numpy())
del test_batch, log_probs, targets, targets_lengths, encoded_len, greedy_predictions
print(f"WER = {sum(wer_nums)/sum(wer_denoms)}")
AttributeError Traceback (most recent call last)
Cell In[59], line 29
25 log_probs, encoded_len, greedy_predictions = first_asr_model(
26 input_signal=test_batch[0], input_signal_length=test_batch[1]
27 )
28 # Notice the model has a helper object to compute WER
---> 29 first_asr_model.wer.update(predictions=greedy_predictions, predictions_lengths=None, targets=targets, targets_lengths=targets_lengths)
30 _, wer_num, wer_denom = first_asr_model.wer.compute()
31 first_asr_model.wer.reset()
File ~/anaconda3/envs/nemo/lib/python3.10/site-packages/torch/nn/modules/module.py:1695, in Module.getattr(self, name)
1693 if name in modules:
1694 return modules[name]
-> 1695 raise AttributeError(f"'{type(self).name}' object has no attribute '{name}'")
AttributeError: 'EncDecCTCModel' object has no attribute 'wer'
Beta Was this translation helpful? Give feedback.
All reactions