Delve lets you monitor PyTorch model layer saturation during training
Project description
# Delve: Deep Live Visualization and Evaluation
[![PyPI version](https://badge.fury.io/py/delve.svg)](https://badge.fury.io/py/delve)
Inspect layer saturation for optimizing your PyTorch models.
Delve is a Python package for visualizing deep learning model training.
Use Delve if you need a lightweight PyTorch extension that:
- Plots live statistics of network activations to TensorBoard
- Performs spectral analysis to identify layer saturation for network pruning
- Is easily extendible and configurable
------------------
## Motivation
Designing a deep neural network involves optimizing over a wide range of parameters and hyperparameters. Delve allows you to visualize your layer saturation during training so you can grow and shrink layers as needed.
## Demo
![live layer saturation demo](images/layer-saturation-convnet.gif)
## Getting Started
```bash
pip install delve
```
### Layer Saturation
Pass a PyTorch model or `Linear` layers to CheckLayerSat:
```python
from delve import CheckLayerSat
model = TwoLayerNet() # PyTorch network
stats = CheckLayerSat('runs', model) #logging directory and input
... # setup data loader
for i, data in enumerate(train_loader):
stats.saturation() # output saturation
```
Only fully-connected layers are currently supported.
To log the saturation to console, call `stats.saturation()`. For example:
```bash
Regression - SixLayerNet - Hidden layer size 10 │
loss=0.231825: 68%|████████████████████▎ | 1350/2000 [00:04<00:02, 289.30it/s]│
linear1: 90%|█████████████████████████████████▎ | 90.0/100 [00:00<00:00, 453.47it/s]│
linear2: 18%|██████▊ | 18.0/100 [00:00<00:00, 90.68it/s]│
linear3: 32%|███████████▊ | 32.0/100 [00:00<00:00, 161.22it/s]│
linear4: 32%|███████████▊ | 32.0/100 [00:00<00:00, 161.24it/s]│
linear5: 28%|██████████▎ | 28.0/100 [00:00<00:00, 141.11it/s]│
linear6: 90%|██████████████████████████████████▏ | 90.0/100 [00:01<00:00, 56.04it/s]
```
#### Optimize neural network topology
Ever wonder how big your fully-connected layers should be? Delve helps you visualize the effect of modifying the layer size on your layer saturation.
For example, see how modifying the hidden layer size of this network affects the second layer saturation but not the first. Multiple runs show that the fully-connected "linear2" layer (light blue is 256-wide and orange is 8-wide) saturation is sensitive to layer size:
![saturation](images/layer1-saturation.png)
![saturation](images/layer2-saturation.png)
### Log spectral analysis
Writes the top 5 eigenvalues of each layer to TensorBoard summaries:
```python
stats = CheckLayerSat('runs', layers, 'spectrum')
```
Other options
![spectrum](images/spectrum.png)
### Intrinsic dimensionality
View the intrinsic dimensionality of models in realtime:
![intrinsic_dimensionality-layer2](images/layer2-intrinsic.png)
This comparison suggests that the 8-unit layer (light blue) is too saturated and that a larger layer is needed.
### Why this name, Delve?
__delve__ (*verb*):
- reach inside a receptacle and search for something
- to carry on intensive and thorough research for data, information, or the like
[![PyPI version](https://badge.fury.io/py/delve.svg)](https://badge.fury.io/py/delve)
Inspect layer saturation for optimizing your PyTorch models.
Delve is a Python package for visualizing deep learning model training.
Use Delve if you need a lightweight PyTorch extension that:
- Plots live statistics of network activations to TensorBoard
- Performs spectral analysis to identify layer saturation for network pruning
- Is easily extendible and configurable
------------------
## Motivation
Designing a deep neural network involves optimizing over a wide range of parameters and hyperparameters. Delve allows you to visualize your layer saturation during training so you can grow and shrink layers as needed.
## Demo
![live layer saturation demo](images/layer-saturation-convnet.gif)
## Getting Started
```bash
pip install delve
```
### Layer Saturation
Pass a PyTorch model or `Linear` layers to CheckLayerSat:
```python
from delve import CheckLayerSat
model = TwoLayerNet() # PyTorch network
stats = CheckLayerSat('runs', model) #logging directory and input
... # setup data loader
for i, data in enumerate(train_loader):
stats.saturation() # output saturation
```
Only fully-connected layers are currently supported.
To log the saturation to console, call `stats.saturation()`. For example:
```bash
Regression - SixLayerNet - Hidden layer size 10 │
loss=0.231825: 68%|████████████████████▎ | 1350/2000 [00:04<00:02, 289.30it/s]│
linear1: 90%|█████████████████████████████████▎ | 90.0/100 [00:00<00:00, 453.47it/s]│
linear2: 18%|██████▊ | 18.0/100 [00:00<00:00, 90.68it/s]│
linear3: 32%|███████████▊ | 32.0/100 [00:00<00:00, 161.22it/s]│
linear4: 32%|███████████▊ | 32.0/100 [00:00<00:00, 161.24it/s]│
linear5: 28%|██████████▎ | 28.0/100 [00:00<00:00, 141.11it/s]│
linear6: 90%|██████████████████████████████████▏ | 90.0/100 [00:01<00:00, 56.04it/s]
```
#### Optimize neural network topology
Ever wonder how big your fully-connected layers should be? Delve helps you visualize the effect of modifying the layer size on your layer saturation.
For example, see how modifying the hidden layer size of this network affects the second layer saturation but not the first. Multiple runs show that the fully-connected "linear2" layer (light blue is 256-wide and orange is 8-wide) saturation is sensitive to layer size:
![saturation](images/layer1-saturation.png)
![saturation](images/layer2-saturation.png)
### Log spectral analysis
Writes the top 5 eigenvalues of each layer to TensorBoard summaries:
```python
stats = CheckLayerSat('runs', layers, 'spectrum')
```
Other options
![spectrum](images/spectrum.png)
### Intrinsic dimensionality
View the intrinsic dimensionality of models in realtime:
![intrinsic_dimensionality-layer2](images/layer2-intrinsic.png)
This comparison suggests that the 8-unit layer (light blue) is too saturated and that a larger layer is needed.
### Why this name, Delve?
__delve__ (*verb*):
- reach inside a receptacle and search for something
- to carry on intensive and thorough research for data, information, or the like
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
delve-0.1.3.tar.gz
(10.1 kB
view details)
Built Distribution
File details
Details for the file delve-0.1.3.tar.gz
.
File metadata
- Download URL: delve-0.1.3.tar.gz
- Upload date:
- Size: 10.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | eff0e036473660a6e054ebe539252a3014c374b4dc827bbc8f5d286072e23eb8 |
|
MD5 | 0a4db84e2383482e91853576bd8802a0 |
|
BLAKE2b-256 | ffd1ce976c4eced023290f6b201668b58eb0dae03b24f7a0c3d8e8c0ae75410e |
Provenance
File details
Details for the file delve-0.1.3-py2.py3-none-any.whl
.
File metadata
- Download URL: delve-0.1.3-py2.py3-none-any.whl
- Upload date:
- Size: 9.9 kB
- Tags: Python 2, Python 3
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | a1608dc0fd83aeb28974b055ffc7473fa6aa552e4eb87814e6e7c6c111e37634 |
|
MD5 | d9cb5114d6b90e37604577d1ef768742 |
|
BLAKE2b-256 | f5a0120a012146c3110cdc69657c65df917b43dfee257bd91dfd21c3c3f3df35 |