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()