Deep Learning with PyTorch Lightning by Kunal Sawarkar

Deep Learning with PyTorch Lightning by Kunal Sawarkar

Author:Kunal Sawarkar
Language: eng
Format: epub
Publisher: Packt Publishing Ltd.
Published: 2022-04-29T00:00:00+00:00


The easiest way to check the learning rate is shown in the following code snippet:

print("model learning rate:",model.hparams)

The output is as follows:

Figure 5.21 – The model learning rate

Now, since we have identified the optimal learning rate, it's time to train our model:

trainer.fit(model)

We are passing the model, which is an instance of TrafficVolumePrediction, using the fit method on the trainer to train the model.

The following output is displayed:

Figure 5.22 – The training result

Important Note

When we pass the auto_lr_find input as True, PyTorch Lightning searches for the variable with the learning_rate name or lr within our LSTM class. Make sure you have created a variable with the learning_rate name or lr within the LSTM class.

The learning rate is one of the most important hyperparameters, and it's not easy to determine the best learning rate. PyTorch Lightning helps us to determine the optimal learning rate, but it may not be the best learning rate. However, it's a good way to start identifying the best learning rate. We will also train the model here without the suggested learning rate from PyTorch Lightning and compare the results.



Download



Copyright Disclaimer:
This site does not store any files on its server. We only index and link to content provided by other sites. Please contact the content providers to delete copyright contents if any and email us, we'll remove relevant links or contents immediately.