I’m trying to instantiate a trainer like I did before in version 3.0.2:
trainer = MyTrainer(
model=model,
args=training_args,
train_dataset=train_dataset,
eval_dataset=eval_dataset,
compute_metrics=compute_metrics,
callbacks=[EarlyStoppingCallback(3, 0.5)]
)
where MyTrainer
is:
class MyTrainer(Trainer):
def __init__(
self,
model: PreTrainedModel,
args: TrainingArguments,
data_collator: Optional[DataCollator] = None,
train_dataset: Optional[Dataset] = None,
eval_dataset: Optional[Dataset] = None,
compute_metrics: Optional[Callable[[EvalPrediction], Dict]] = None,
prediction_loss_only=False,
tb_writer: Optional["SummaryWriter"] = None,
callbacks: Optional[List[TrainerCallback]] = None,
optimizers: Tuple[torch.optim.Optimizer, torch.optim.lr_scheduler.LambdaLR] = (None, None)
):
super().__init__(model, args, data_collator, train_dataset, eval_dataset, compute_metrics, prediction_loss_only,
tb_writer, callbacks, optimizers)
when I try to train the model
train_result = trainer.train(
model_path=model_args.model_name_or_path if os.path.isdir(model_args.model_name_or_path) else None
)
I get the following error
TypeError: False is not a callable object
The model_path
is None
as also in version 3.0.2, but here it doesn’t work anymore.
The value of args.model_name_or_path
is bert-base-uncased
specified in the file run.sh
.
How can I do to solve this problem?
Thanks!