How to save predictions for each epoch by Trainer?
During training, I make prediction and evaluate my model at the end of each epoch. I want to save the prediction results every time I evaluate my model. How to achieve this using Trainer?Thanks a lot!
2022-07-17T11:33:45Z
Anyone can help? Even a few simple instructions would be much appreciated!
2022-12-28T17:30:10Z
Hi, this may be a late reply and you may have already got a solution.If not, you can try to export your predictions and true labels in to a pandas data frame in side your compute_metrics, sample code below:def compute_metrics(pred):labels = pred.label_ids
      preds = pred.predictions.argmax(-1)
      new_df = pd.DataFrame( )
      new_df['pred_label'] = y_pred
      new_df['true_label'] = y_true
      new_df.to_csv('/content/drive/MyDrive/results.csv', header=True)
      # your regular metrics computation code....ThanksSatya
2023-03-23T12:57:01Z
This will only save the latest result for evaluation. I think he might need the result after each epoch.
2023-09-19T20:23:04Z
Is there an update on this? Is it possible to pass savedir or filename through the trainer? say something like epoch number, etc.