Skip to content

Commit e3bf6a4

Browse files
committed
misc tutorial enhancements
1 parent 25ba9c0 commit e3bf6a4

File tree

1 file changed

+18
-4
lines changed

1 file changed

+18
-4
lines changed

lightning_examples/finetuning-scheduler/finetuning-scheduler.py

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,15 @@
1+
# ---
2+
# jupyter:
3+
# jupytext:
4+
# cell_metadata_filter: -all
5+
# formats: ipynb,py:percent
6+
# text_representation:
7+
# extension: .py
8+
# format_name: percent
9+
# format_version: '1.3'
10+
# jupytext_version: 1.13.2
11+
# ---
12+
113
# %% [markdown]
214
# ## Scheduled Finetuning
315
#
@@ -396,6 +408,7 @@ def validation_step(self, batch, batch_idx, dataloader_idx=0):
396408

397409
labels = batch["labels"]
398410
self.log("val_loss", val_loss, prog_bar=True)
411+
399412
return {"loss": val_loss, "preds": preds, "labels": labels}
400413

401414
def validation_epoch_end(self, outputs):
@@ -518,7 +531,8 @@ def configure_callbacks(self):
518531
# %%
519532
lr_scheduler_init = {
520533
"class_path": "torch.optim.lr_scheduler.CosineAnnealingWarmRestarts",
521-
"init_args": {"T_0": 1, "T_mult": 2, "eta_min": 1e-07},
534+
# "init_args": {"T_0": 1, "T_mult": 2, "eta_min": 1e-07},
535+
"init_args": {"T_0": 1, "T_mult": 2, "eta_min": 0},
522536
}
523537
pl_lrs_cfg = {"interval": "epoch", "frequency": 1, "name": "CosineAnnealingWarmRestarts"}
524538

@@ -551,10 +565,10 @@ def configure_callbacks(self):
551565
def train() -> None:
552566
trainer = pl.Trainer(
553567
enable_progress_bar=enable_progress_bar,
568+
# max_epochs=1,
554569
precision=16,
555-
gpus=1,
556-
# accelerator="auto",
557-
# devices="auto",
570+
accelerator="gpu",
571+
devices=1,
558572
callbacks=callbacks,
559573
logger=logger,
560574
)

0 commit comments

Comments
 (0)