Input of compute_metrics in ASR model
What should be the input of the function below?Is it the model or a pass forward of the model?def compute_metrics(pred):
    pred_logits = pred.predictions
    pred_ids = np.argmax(pred_logits, axis=-1)

    pred.label_ids[pred.label_ids == -100] = processor.tokenizer.pad_token_id

    pred_str = processor.batch_decode(pred_ids)
    # we do not want to group tokens when computing the metrics
    label_str = processor.batch_decode(pred.label_ids, group_tokens=False)

    wer = wer_metric.compute(predictions=pred_str, references=label_str)

    return {"wer": wer}Also, I have one question about how the Trainer class works…I mean, it encloses everything, but does it update the weights of the model automatically or it creates another instance for model?
2021-04-19T12:57:05Z
The input is a namedtuple of typeEvalPrediction. It should have one keypredictionsfor the predictions (will have the structure as the output of your model, so one tensor if your model outputted one tensor, a tuple of two tensors if that’s what your model returns, et.) and one keylabel_idsthat will contain all the labels.The Trainer does update the weights of the model, otherwise, the model would not be… well… training
2021-04-19T13:23:40Z
I didn’t get the part of trainer not updating the weights of the model… because training would be about updating the weights on the hidden layers after the transformers and before the output… so what exactly does it do? Also, after using it, I cannot use the model to predict results anymore