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
38 39 40 41 42 43 44 45 | |
on_train_start(trainer, pl_module)
Called when training starts.
Source code in src/flowcean/torch/lightning_learner.py
47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 | |
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
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 92 93 94 95 96 97 98 99 100 101 | |
on_train_end(trainer, pl_module)
Called when training ends.
Source code in src/flowcean/torch/lightning_learner.py
103 104 105 106 107 108 | |
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
126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 | |