Suggestion on page 447 and 448 #126
baifanhorst
started this conversation in
General
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
The codes at the bottom of page 447 load the model from the last checkpoint:
if torch.cuda.is_available():
trainer = pl.Trainer(max_epochs=20, accelerator="gpu", devices=1,
resume_from_checkpoint='./lightning_logs/version_9/checkpoints/epoch=19-step=17200.ckpt')
else:
trainer = pl.Trainer(max_epochs=20, resume_from_checkpoint='./lightning_logs/version_9/checkpoints/epoch=19-step=17200.ckpt')
Please ignore the difference between the arguments of the above codes and thos on the book. The codes above do not work for the latest version of pytorch lightning. One should use the following code instead:
mnist_classifier_continue = MultiLayerPerceptron.load_from_checkpoint('./lightning_logs/version_9/checkpoints/epoch=19-step=17200.ckpt')
Then define the trainer again:
if torch.cuda.is_available():
trainer = pl.Trainer(max_epochs=5, accelerator="gpu", devices=1)
else:
trainer = pl.Trainer(max_epochs=5)
And train the model:
trainer.fit(model=mnist_classifier_continue, datamodule=mnist_dm)
Page 448 shows the last two trains of the model. However, this does not show up automatically. One should reload tensorboard:
%reload_ext tensorboard
%tensorboard --logdir lightning_logs/
Beta Was this translation helpful? Give feedback.
All reactions