nlp-with-transformers / notebooks

Jupyter notebooks for the Natural Language Processing with Transformers book
https://transformersbook.com/
Apache License 2.0
3.7k stars 1.13k forks source link

Chapter 8, "creating a Knowledge Distillation Trainer" (FrozenInstanceError) #116

Closed ilanaliouchouche closed 10 months ago

ilanaliouchouche commented 10 months ago

Information

The question or comment is about chapter:

Question or comment

Hello I cant solve an error. When I create an instance of DistillationTrainingArguments I get this error:

FrozenInstanceError Traceback (most recent call last) in <cell line: 1>() ----> 1 stud_training_args = DistillationTrainingArguments( 2 output_dir=finetuned_ckpt, evaluation_strategy = "epoch", 3 num_train_epochs=5, learning_rate=2e-5, per_device_train_batch_size=batch_size, 4 alpha=0.5 5 )

1 frames in init(self, alpha, temperature, *args, kwargs) 2 def init(self, *args, alpha=0.5, temperature=2.0, *kwargs): 3 super().init(args, kwargs) ----> 4 self.alpha = alpha 5 self.temperature = temperature

/usr/local/lib/python3.10/dist-packages/transformers/training_args.py in setattr(self, name, value) 1710 # Once fully through the __post_init__, TrainingArguments are immutable 1711 if not name.startswith("_") and getattr(self, "_frozen", False): -> 1712 raise FrozenInstanceError(f"cannot assign to field {name}") 1713 else: 1714 super().setattr(name, value)

FrozenInstanceError: cannot assign to field alpha

I re-read the code in the book several times but didn't see any error in my implementation.

thank you in advance for your help !!**