lightning_learner
LightningCallbackBridge(learner, callback_manager)
Bases: Callback
Bridge between PyTorch Lightning callbacks and flowcean callbacks.
This adapter forwards Lightning training events to flowcean callbacks.
Source code in src/flowcean/torch/lightning_learner.py
28 29 30 31 32 33 34 35 | |
on_train_start(trainer, pl_module)
Called when training starts.
Source code in src/flowcean/torch/lightning_learner.py
37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 | |
on_train_batch_end(trainer, pl_module, outputs, batch, batch_idx)
Called after each training batch.
Source code in src/flowcean/torch/lightning_learner.py
53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 | |
on_train_end(trainer, pl_module)
Called when training ends.
Source code in src/flowcean/torch/lightning_learner.py
93 94 95 96 97 98 | |
LightningLearner(module, num_workers=None, batch_size=32, max_epochs=100, accelerator='auto', callbacks=None)
Bases: SupervisedLearner
A learner that uses PyTorch Lightning.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
module
|
LightningModule
|
The PyTorch Lightning module. |
required |
num_workers
|
int | None
|
The number of workers to use for the DataLoader. |
None
|
batch_size
|
int
|
The batch size to use for training. |
32
|
max_epochs
|
int
|
The maximum number of epochs to train for. |
100
|
accelerator
|
str
|
The accelerator to use. |
'auto'
|
callbacks
|
list[LearnerCallback] | LearnerCallback | None
|
Optional callbacks for progress feedback. Use |
None
|
Initialize the learner.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
module
|
LightningModule
|
The PyTorch Lightning module. |
required |
num_workers
|
int | None
|
The number of workers to use for the DataLoader. |
None
|
batch_size
|
int
|
The batch size to use for training. |
32
|
max_epochs
|
int
|
The maximum number of epochs to train for. |
100
|
accelerator
|
str
|
The accelerator to use. |
'auto'
|
callbacks
|
list[LearnerCallback] | LearnerCallback | None
|
Optional callbacks for progress feedback. Use |
None
|
Source code in src/flowcean/torch/lightning_learner.py
116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 | |