training_args = TrainingArguments( | |
output_dir="my_awesome_mind_model", | |
evaluation_strategy="epoch", | |
save_strategy="epoch", | |
learning_rate=3e-5, | |
per_device_train_batch_size=32, | |
gradient_accumulation_steps=4, | |
per_device_eval_batch_size=32, | |
num_train_epochs=10, | |
warmup_ratio=0.1, | |
logging_steps=10, | |
load_best_model_at_end=True, | |
metric_for_best_model="accuracy", | |
push_to_hub=True, | |
) | |
trainer = Trainer( | |
model=model, | |
args=training_args, | |
train_dataset=encoded_minds["train"], | |
eval_dataset=encoded_minds["test"], | |
tokenizer=feature_extractor, | |
compute_metrics=compute_metrics, | |
) | |
trainer.train() | |
Once training is completed, share your model to the Hub with the [~transformers.Trainer.push_to_hub] method so everyone can use your model: | |
trainer.push_to_hub() | |
For a more in-depth example of how to finetune a model for audio classification, take a look at the corresponding PyTorch notebook. |