I am getting a warning when I create a WeightedLossTrainer object as follows:
/home/ec2-user/anaconda3/envs/python3/lib/python3.10/site-packages/accelerate/accelerator.py:432: FutureWarning: Passing the following arguments to Accelerator
is deprecated and will be removed in version 1.0 of Accelerate: dict_keys([âdispatch_batchesâ, âsplit_batchesâ, âeven_batchesâ, âuse_seedable_samplerâ]). Please pass an accelerate.DataLoaderConfiguration
instead:
dataloader_config = DataLoaderConfiguration(dispatch_batches=None, split_batches=False, even_batches=True, use_seedable_sampler=True)
warnings.warn(
Here is the code for creating the WeightedLossTrainer class:
ââ"
class WeightedLossTrainer(Trainer):
def compute_loss(self, model, inputs, return_outputs=False):
#feed inputs to model and extract outputs
outputs = model(**inputs)
#extract logits
logits = outputs.get(âlogitsâ)
#extract labels
labels = inputs.get(âlabelsâ)
#define loss function with class weights
loss_func = nn.CrossEntropyLoss(weight=class_weights)
#compute loss
loss = loss_func(logits, labels)
return (loss, outputs) if return_outputs else loss
ââ"
I get the warning message on creation of the object with the below code:
ââ"
trainer = WeightedLossTrainer(model=model,
args=training_args,
compute_metrics=compute_metrics,
train_dataset=tokenized_medication_datasets[âtrainâ],
eval_dataset=tokenized_medication_datasets[âvalidationâ],
data_collator=data_collator,
tokenizer=tokenizer)
ââ"
I am not using Accelerator object anywhere in the existing code for a TextClassification traning.