Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 1 addition & 17 deletions docs/source/common/hyperparameters.rst
Original file line number Diff line number Diff line change
Expand Up @@ -152,23 +152,7 @@ improve readability and reproducibility.
model = LitMNIST.load_from_checkpoint(PATH, loss_fx=torch.nn.SomeOtherLoss, generator_network=MyGenerator())


3. Assign to `self.hparams`. Anything assigned to `self.hparams` will also be saved automatically.

.. code-block:: python

# using a argparse.Namespace
class LitMNIST(LightningModule):
def __init__(self, hparams, *args, **kwargs):
super().__init__()
self.hparams = hparams
self.layer_1 = nn.Linear(28 * 28, self.hparams.layer_1_dim)
self.layer_2 = nn.Linear(self.hparams.layer_1_dim, self.hparams.layer_2_dim)
self.layer_3 = nn.Linear(self.hparams.layer_2_dim, 10)
def train_dataloader(self):
return DataLoader(mnist_train, batch_size=self.hparams.batch_size)


4. You can also save full objects such as `dict` or `Namespace` to the checkpoint.
3. You can also save full objects such as `dict` or `Namespace` to the checkpoint.

.. code-block:: python

Expand Down