tuned parameters for roberta_distilled?
This commit is contained in:
@@ -35,10 +35,11 @@ class WeightedTrainer(Trainer):
|
|||||||
logits = outputs.get("logits")
|
logits = outputs.get("logits")
|
||||||
|
|
||||||
# loss_fct = CrossEntropyLoss(weight=self.class_weights.to(logits.device))
|
# loss_fct = CrossEntropyLoss(weight=self.class_weights.to(logits.device))
|
||||||
# loss_fct = CrossEntropyLoss(
|
loss_fct = CrossEntropyLoss(
|
||||||
# weight=self.class_weights.to(logits.device).to(logits.dtype)
|
weight=self.class_weights.to(logits.device).to(logits.dtype)
|
||||||
# )
|
)
|
||||||
loss_fct = CrossEntropyLoss()
|
# loss_fct = CrossEntropyLoss()
|
||||||
|
|
||||||
# print("DBG: Before loss")
|
# print("DBG: Before loss")
|
||||||
loss = loss_fct(logits, labels)
|
loss = loss_fct(logits, labels)
|
||||||
# loss.backward()
|
# loss.backward()
|
||||||
@@ -172,14 +173,14 @@ def main():
|
|||||||
train_texts,
|
train_texts,
|
||||||
truncation=True,
|
truncation=True,
|
||||||
padding=True,
|
padding=True,
|
||||||
max_length=512
|
max_length=256
|
||||||
)
|
)
|
||||||
|
|
||||||
val_encodings = tokenizer(
|
val_encodings = tokenizer(
|
||||||
val_texts,
|
val_texts,
|
||||||
truncation=True,
|
truncation=True,
|
||||||
padding=True,
|
padding=True,
|
||||||
max_length=512
|
max_length=256
|
||||||
)
|
)
|
||||||
|
|
||||||
class TextDataset(torch.utils.data.Dataset):
|
class TextDataset(torch.utils.data.Dataset):
|
||||||
@@ -202,9 +203,9 @@ def main():
|
|||||||
training_args = TrainingArguments(
|
training_args = TrainingArguments(
|
||||||
output_dir="./results",
|
output_dir="./results",
|
||||||
learning_rate=2e-5,
|
learning_rate=2e-5,
|
||||||
per_device_train_batch_size=16,
|
per_device_train_batch_size=32,
|
||||||
gradient_accumulation_steps=2,
|
# gradient_accumulation_steps=2,
|
||||||
num_train_epochs=10,
|
num_train_epochs=15,
|
||||||
weight_decay=0.01,
|
weight_decay=0.01,
|
||||||
load_best_model_at_end=True,
|
load_best_model_at_end=True,
|
||||||
eval_strategy="epoch",
|
eval_strategy="epoch",
|
||||||
@@ -236,8 +237,8 @@ def main():
|
|||||||
for k, v in metrics.items():
|
for k, v in metrics.items():
|
||||||
print(f"{k}: {v}")
|
print(f"{k}: {v}")
|
||||||
|
|
||||||
trainer.save_model("./roberta_classifier")
|
trainer.save_model("./roberta_distilled_classifier")
|
||||||
tokenizer.save_pretrained("./roberta_classifier")
|
tokenizer.save_pretrained("./roberta_distilled_classifier")
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user