Skip to content

Commit

Permalink
removed hparams assignment example (#7639)
Browse files Browse the repository at this point in the history
  • Loading branch information
deng-cy authored May 21, 2021
1 parent 7eafd8e commit 03ea68f
Showing 1 changed file with 1 addition and 17 deletions.
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

0 comments on commit 03ea68f

Please sign in to comment.