Plotting train accuracy and loss with Trainer

can anyone help me for this code, I want build plot the training and validation loss, as well as the training and validation accuracy in Trainer(), but i have some problem to displaying training accuracy? how could i display the train accuracy? and this is my code


from transformers import TrainingArguments

training_args = TrainingArguments(
    "test_trainer",
    per_device_train_batch_size=2,
    learning_rate=1e-05,
    num_train_epochs=2.0,
    evaluation_strategy = "epoch", #To calculate metrics per epoch
    logging_strategy="epoch" #Extra: to log training data stats for loss
)

metric = load_metric("accuracy")

def compute_metrics(eval_pred):
    logits, labels = eval_pred
    predictions = np.argmax(logits, axis=-1)

    return metric.compute(predictions=predictions, references=labels)

torch.cuda.empty_cache()

trainer = Trainer(
    model=model,
    args=training_args,
    train_dataset=train_dataset_cluster_1,
    eval_dataset=eval_dataset_cluster_1,
    compute_metrics=compute_metrics,
)
training_history = trainer.train()

Hi,

Refer to this thread: Metrics for Training Set in Trainer

can u help me in personal? im just newbie in machine learning and im so confused to adjust my coding with ur recommendation, I have tried the code you suggested but doesn’t still work