Hello.
I have created my own trainer with a custom loss function.
During Training , I got this error:
RuntimeError: Expected target size [8, 101126], got [8, 22]
class MLTimeseriesTrainer(Trainer):
    def __init__(self, *args, **kwargs):
        super().__init__(*args, **kwargs)   
        
    def compute_loss(self, model, inputs, return_outputs=False):
        labels = inputs.pop("labels")
        outputs = model(**inputs)[0]
        loss_fct = nn.CrossEntropyLoss()
        return loss_fct(outputs, labels)

    training_args = TrainingArguments(
        output_dir="./ml_ts",
        overwrite_output_dir=True,
        num_train_epochs=200,
        logging_steps= 200,
        prediction_loss_only=True,
        #learning_rate=0.002
    )

    trainer = MLTimeseriesTrainer(
        model=model,
        args=training_args,
        data_collator=data_collator,
        train_dataset=dataset,
    )

It seems to me that 22 is the number of words in input string and 101126 is size of my vocabulary. Please explain what I’m doing wrong… With usual Trainer all are Ok,