Digging Into KITTI With Weights & Biases With PyTorch-Lightning Kitti
In this article, we perform semantic segmentation on the KITTI dataset with Pytorch-Lightning and Weights & Biases
Created on March 29|Last edited on October 10
Comment
This is a simple demo for performing semantic segmentation on the Kitti dataset using Pytorch-Lightning and optimizing the neural network by monitoring and comparing runs with Weights & Biases.
Pytorch-Lightning includes a logger for W&B that can be called simply with:
from pytorch_lightning.loggers import WandbLoggerfrom pytorch_lightning import Trainerwandb_logger = WandbLogger()trainer = Trainer(logger=wandb_logger)
Refer to the documentation for more details. Hyper-parameters can be defined manually and every run is automatically logged onto Weights & Biases for easier analysis/interpretation of results and how to optimize the architecture.
See full code on Github →
Usage
- Install dependencies through requirements.txt, Pipfile or manually (Pytorch, Pytorch-Lightning & Wandb)
- Log in or sign up for an account -> wandb login
- Run python train.py
- Visualize and compare your runs through generated link. It'll log your model performance, gradients and any other metrics you choose.
Sweep: lrqc8fu3
73
Hyperparameter Optimization with Sweeps
- Run wandb sweep sweep.yaml
- Run wandb agent <sweep_id> where <sweep_id> is given by previous command
After running the script a few times, you will be able to compare quickly a large combination of hyperparameters. Feel free to modify the script and define your own hyperparameters.
See full code on Github →
Sweep: lrqc8fu3
73
Pytorch-Lightning let us use Pytorch-based code and easily adds extra features such as distributed computing over several GPU's and machines, half-precision training, and gradient accumulation.
In this example, we optimize the following hyper-parameters:
- u-net -> custom number of layers, features, up-sample
- dataloader -> batch size
- optimizer -> learning rate, gradient accumulation
It's interesting to see the possible combination of parameters to have a good performance (here defined by low val_loss):
- the number of gradients accumulated grad_batches cannot be too high, probably because of the limited dataset which would cause fewer weight updates by epoch
- the number of layers num_layers is best at 3 or 4
- the number of features on each layer is often better when higher
Note: it's important to keep in mind that we limited training to 20 epochs. Deeper networks typically need more time to be trained.
Related Reading
The Semantic KITTI Dataset
Semantic-Kitti is a large semantic segmentation and scene understanding dataset developed for LiDAR-based autonomous driving. But what it is and what is it for?
The Many Datasets of Autonomous Driving
Below we'll explore the datasets used to train autonomous driving systems to perform the various tasks required of them.
A System of Record for Autonomous Driving Machine Learning Models
A look at the most useful Weights & Biases features for autonomous vehicle companies
Training Semantic Segmentation Models for Autonomous Vehicles (A Step-by-Step Guide)
A short tutorial on leveraging Weights & Biases to train a semantic segmentation model for autonomous vehicles.
Add a comment
i getting eror on datamodule
Reply
Iterate on AI agents and models faster. Try Weights & Biases today.