Skip to main content

Visualize easily the loss landscape of your neural networks

Project description

loss + landscape = losscape 🌄

This is losscape, a lightweight, modular, and straightforward Python library that empowers you to visualize the loss landscape of your neural networks, as in Visualizing the Loss Landscape of Neural Nets.

losscape is designed as a plug-and-play extension for your existing PyTorch models. It boasts its simplicity, modularity, and fast rendering speed.

Key Features ✨

  • 🏃 Fast Rendering: Leveraging PyTorch's torch.no_grad() feature and controlling the number of examples to compute the loss, losscape speeds up the visualization process dramatically, thus saving valuable wall time.
  • 📊 Flexible Plotting: Supports both 2D and 3D plotting options for your loss landscapes, giving you the power to choose based on your requirements and computational constraints.
  • 🔌 Plug and Play: Easy to integrate with your existing PyTorch models. No substantial modifications to your codebase are needed!

Installation 📦

You can install losscape via pip:

pip install losscape

Usage ⚙️

Here's a quick example on how to use losscape:

from losscape.train import train
from losscape.create_landscape import create_2D_losscape

model = ... # create your torch model (subclass of torch.nn.Module)
train_loader = ... # the DataLoader containing your favorite dataset

train(model, train_loader) # losscape can perform the training for you
create_2D_losscape(model, train_loader, output_vtp=True)

Typical results :

To visualize the loss landscape in 3D, use the .vtp file created by the library and simply drag-and-drop it in a VTK viewer :

Documentation 📖

For more details, please refer to the documentation. It provides a global overview on how losscape works, and on how you can leverage it with your own model. (to be written : for now you can refer to the code, its simple enough to understand the structure of the library, and you can spin up using the juypter notebook example, all available on the Github repo).

References 📚

Roadmap 🚀

Here are a couple of additions I'm planning to add in the near future:

  • 📈 Validation Loss Landscape: I'm working on the ability to visualize the validation loss landscape, in addition to the training loss landscape.
  • 🛤 Optimizer Path Visualization: Future updates will include the ability to visualize the path of gradient descent (or any other optimizer) on these landscapes using PCA.

Contact 📞

Feel free to open an issue if you find a bug or have any suggestions to improve the library. Feedback is much appreciated!

Enjoy your visualization journey with losscape ! 🎉

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

losscape-1.5.10.tar.gz (9.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

losscape-1.5.10-py3-none-any.whl (8.9 kB view details)

Uploaded Python 3

File details

Details for the file losscape-1.5.10.tar.gz.

File metadata

  • Download URL: losscape-1.5.10.tar.gz
  • Upload date:
  • Size: 9.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.11.3

File hashes

Hashes for losscape-1.5.10.tar.gz
Algorithm Hash digest
SHA256 12e10fc22fdcc538a106d08bf2b059b4f9f86880ee28f42de3fc1142840f1d30
MD5 f0068767e02ce61868848ffda7dd7ba9
BLAKE2b-256 dec3e39273b7bac640c7ad430e6f8a2ad03dab30dc8755db2fd79c670dc49955

See more details on using hashes here.

File details

Details for the file losscape-1.5.10-py3-none-any.whl.

File metadata

  • Download URL: losscape-1.5.10-py3-none-any.whl
  • Upload date:
  • Size: 8.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.11.3

File hashes

Hashes for losscape-1.5.10-py3-none-any.whl
Algorithm Hash digest
SHA256 050efa915a576850ee7dad0ff62ca338be82c4225db4307b1008c185548429bc
MD5 f1e9f012097c282352ed00b0543086b8
BLAKE2b-256 cebcba18fdc62eb858f6901b74f91d7bfea430c3bdda131227c1078af177d587

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page