You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: CHANGELOG.md
+3Lines changed: 3 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -77,6 +77,9 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/).
77
77
- Added a warning if `Trainer(log_every_n_steps)` is a value too high for the training dataloader ([#7734](https://github.com/PyTorchLightning/pytorch-lightning/pull/7734))
78
78
79
79
80
+
- Added LightningCLI support for argument links applied on instantiation ([#7895](https://github.com/PyTorchLightning/pytorch-lightning/pull/7895))
81
+
82
+
80
83
### Changed
81
84
82
85
- Changed calling of `untoggle_optimizer(opt_idx)` out of the closure function ([#7563](https://github.com/PyTorchLightning/pytorch-lightning/pull/7563)
Copy file name to clipboardExpand all lines: docs/source/common/lightning_cli.rst
+21-1Lines changed: 21 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -19,9 +19,13 @@
19
19
):
20
20
pass
21
21
22
+
class MyClassModel(LightningModule):
23
+
def __init__(self, num_classes: int):
24
+
pass
25
+
22
26
class MyDataModule(LightningDataModule):
23
27
def __init__(self, batch_size: int = 8):
24
-
pass
28
+
self.num_classes = 5
25
29
26
30
def send_email(address, message):
27
31
pass
@@ -402,6 +406,22 @@ The linking of arguments is observed in the help of the tool, which for this exa
402
406
model.batch_size <-- data.batch_size
403
407
Number of samples in a batch (type: int)
404
408
409
+
Sometimes a parameter value is only available after class instantiation. An example could be that your model requires the number of classes to instantiate its fully connected layer (for a classification task) but the value is not available until the data module has been instantiated.
410
+
The code below illustrates how to address this.
411
+
412
+
.. testcode::
413
+
414
+
from pytorch_lightning.utilities.cli import LightningCLI
0 commit comments