Skip to main content

nnviz — Neural Network Visualiser

Live, real-time visualisation of PyTorch model training. Watch weights update, see predictions change, and understand what your network is learning — frame by frame.

nnviz screenshot


Install

pip install pygame torch numpy pandas scikit-learn
# then clone or copy the nnviz/ folder into your project

(PyPI release coming soon — for now install from source.)


Quickstart

import torch.nn as nn, torch.optim as optim
from torch.utils.data import DataLoader, TensorDataset
from nnviz import Visualizer

# 1. Any model with nn.Linear layers
model = nn.Sequential(
    nn.Linear(784, 128), nn.ReLU(),
    nn.Linear(128,  64), nn.ReLU(),
    nn.Linear( 64,  10),
)

# 2. Any DataLoader that yields (X_batch, y_batch)
loader = DataLoader(TensorDataset(X_train, y_train), batch_size=64)

# 3. Run — a window opens, press T to start training
viz = Visualizer(
    input_shape  = (28, 28),                    # omit for tabular data
    class_names  = [str(i) for i in range(10)],
)
viz.run(model, loader, nn.CrossEntropyLoss(), optim.Adam(model.parameters()))

Controls

Key Action
T or Space Start / pause training
+ / - Speed up / slow down (batches per frame)
Esc Quit

Visualiser parameters

Parameter Default Description
input_shape None (H, W) for image data; None for tabular
class_names None Human-readable label names for output layer
max_visible_neurons 32 Max neurons drawn per layer (large layers are sub-sampled — training is unaffected)
width, height 1400, 820 Window size in pixels
fps 60 Target frame rate
batches_per_step 1 Base batches trained per frame at speed 1×
normalise_input True Normalise pixel grid display to [0,1] per sample

What you see

┌──────────────┬─────────────┬────────────────────────────────────────┐
│  Info panel  │  Pixel grid │         Network diagram                │
│              │  (input)    │                                        │
│  ● TRAIN     │  ██░░██░░   │  ○─────○──────○──────○  ← output      │
│  Epoch  3    │  ░░████░░   │  ○  ╲  ○  ╲   ○  ╲   ○               │
│  Batch  142  │  ░░░░░░░░   │  ○  ╱  ○  ╱   ○  ╱   ○               │
│  Loss 0.312  │  ██░░░░██   │  ○─────○──────○──────○                │
│  Acc  88.3%  │             │                                        │
│              │             │  Blue lines = positive weights         │
│  Pred: 7     │             │  Red  lines = negative weights         │
│  True: 7 ✓  │             │  Brightness = magnitude                │
└──────────────┴─────────────┴────────────────────────────────────────┘

Left panel — live stats: mode, epoch, batch count, loss, accuracy, current prediction vs target.

Pixel grid — the first sample of each batch, rendered as a greyscale image (or a square grid for tabular data).

Network diagram — every inter-layer connection coloured by weight sign and magnitude. Blue = positive, red = negative, dark = near-zero (hidden so the display stays readable). The highest-confidence output neuron glows red; others stay green.


Supported datasets

Type Works? Notes
Image (MNIST, CIFAR-flat, …) Pass input_shape=(H,W)
Tabular (Iris, CSV, …) Leave input_shape=None
Multi-class classification Any number of output classes
Binary classification Use 2 output neurons + CrossEntropyLoss
Regression ⚠️ Renders, but accuracy stats won't be meaningful

Examples

python examples/mnist_example.py   # MNIST digits, image grid
python examples/iris_example.py    # Iris flowers, tabular

Roadmap

  • Loss curve graph panel
  • Save / load checkpoint from UI
  • Activation heatmap overlay
  • Multi-label classification support
  • PyPI release

License

MIT

Download files

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

Source Distribution

nnviz_live-0.1.1.tar.gz (17.1 kB view details)

Uploaded Source

Built Distribution

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

nnviz_live-0.1.1-py3-none-any.whl (15.6 kB view details)

Uploaded Python 3

File details

Details for the file nnviz_live-0.1.1.tar.gz.

File metadata

  • Download URL: nnviz_live-0.1.1.tar.gz
  • Upload date:
  • Size: 17.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/7.0.0 CPython/3.11.13

File hashes

Hashes for nnviz_live-0.1.1.tar.gz
Algorithm Hash digest
SHA256 13bef14017a49584f45f407bdb4fd1af4293f922b16e4ba55a729c5c50cd14a2
MD5 c0408a529b6e3d0bb5e5e40f3e9e2249
BLAKE2b-256 943925903f431113e5eabae4d4eae72f0d7567178b4aad457fafee8668edb2bb

See more details on using hashes here.

File details

Details for the file nnviz_live-0.1.1-py3-none-any.whl.

File metadata

  • Download URL: nnviz_live-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 15.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/7.0.0 CPython/3.11.13

File hashes

Hashes for nnviz_live-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 bbfe3cbd55b8342baf6f2ec281ee9e8b666f54d3cb4b88ac400a41f929ed26c5
MD5 9a0ccfd04ff5d3840636b01a5b95314e
BLAKE2b-256 a352fd35ca9d83ec743e8ff24e1b0419cb3b019754271051dc85fc841e8d0740

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 Sentry Error logging StatusPage Status page