Skip to main content

PyTorch toolbox for multimodal representation learning and Deep Latent Variable Path Modelling

Project description

Deep LVPM logo

Tests Documentation License DOI

Deep LVPM

Deep LVPM is a PyTorch toolbox for multimodal representation learning and Deep Latent Variable Path Modelling.

Deep Latent Variable Path Modelling (DLVPM) is a method for path/structural equation modelling using deep neural networks. It connects different data types through sets of orthogonal deep latent variables (DLVs), and can also be used in a Siamese configuration to learn representations of a single data type. Full documentation is available at deep-lvpm.readthedocs.io, and the method is described in the Nature Machine Intelligence paper.

DLVPM is implemented directly in PyTorch. The high-level toolbox API (model.fit, model.evaluate, model.predict, etc.) is retained for convenience, but these methods use ordinary PyTorch commands internally (model.train(), forward passes, loss calculation, loss.backward(), optimizer.step(), model.eval(), and torch.no_grad()).

Branches And Legacy Versions

The current default branch is the native PyTorch version of the toolbox. Earlier versions remain available for reproducibility and comparison:

Multimodal Methods

Method Purpose
DLVPM Deep latent variable path models for multimodal structural modelling
CLIP / SimCLR Contrastive image-text, multimodal, and Siamese representation learning
VICReg Variance-invariance-covariance regularized multimodal learning
LeJEPA Latent joint embedding predictive architecture for multimodal views
DGCCA Deep Generalised Canonical Correlation Analysis

This package also contains implementations of Deep Generalised Canonical Correlation Analysis and multimodal adaptations of VICReg, LeJEPA, and CLIP/SimCLR. Each method can be used to connect multimodal datasets or to learn representations of a single data type.

Chord animation

The animation above shows model training in progress on a three-factor DLVPM model linking omics and imaging data types from lung cancer patients. The dataset used for this example is included in the package.

Installation

Deep LVPM supports Python 3.11 and 3.12.

Create and activate a clean environment:

conda create -n dlvpm-torch python=3.11 -y
conda activate dlvpm-torch

Install the package from PyPI:

pip install deep-lvpm

To install directly from GitHub:

pip install "git+https://github.com/alexjamesing/Deep_LVPM.git#egg=deep-lvpm"

For NVIDIA CUDA, install the CUDA-enabled PyTorch wheel for your platform first, then install Deep LVPM:

pip install torch torchvision torchaudio --index-url https://download.pytorch.org/whl/cu126
pip install deep-lvpm

For an editable local install:

git clone https://github.com/alexjamesing/Deep_LVPM.git
cd Deep_LVPM
pip install -e ".[tutorials,dev]"

Useful extras are:

  • deep-lvpm[tutorials] for the standard tutorials.
  • deep-lvpm[coco] for the MS COCO image-text tutorial.
  • deep-lvpm[survival] for the TCGA survival analysis dependencies.
  • deep-lvpm[docs] for building the documentation.
  • deep-lvpm[dev] for tests, package builds, and metadata checks.

Verify the install:

python -c "import torch, deep_lvpm; print('torch:', torch.__version__); print('cuda:', torch.cuda.is_available())"

Apple Silicon uses standard PyTorch wheels with MPS support where available. CUDA-enabled PyTorch wheels should be installed from the PyTorch index for your platform and driver.

Tutorials And Metrics

Turnkey tutorials ship with the toolbox and use native PyTorch. Launch them with:

  • python -m deep_lvpm.tutorial.tutorial_mnist - associate MNIST images with labels and visualise the latent space.
  • python -m deep_lvpm.tutorial.tutorial_tcga - integrate five TCGA lung cancer modalities using residual encoders.
  • python -m deep_lvpm.tutorial.tutorial_siamese - train a residual PyTorch Siamese encoder on CIFAR-10 and compare linear probes on final DLVPM factors and average-pooled convolutional features.
  • python -m deep_lvpm.tutorial.tutorial_coco - train an image-text model on MS COCO and benchmark true five-caption retrieval for DLVPM/CLIP/VICReg.
  • python -m deep_lvpm.tutorial.tutorial_tcga_survival - run the TCGA pan-cancer survival example with PyTorch encoders, integrated gradients, and PyTorch checkpoints.

All tutorials report the expanded StructuralModel.evaluate metrics (total_loss, cross_metric, mse_loss, and redundancy) so you can monitor both cross-view alignment and within-view redundancy.

Citation

If you use Deep LVPM, please cite:

Ing A, Andrades A, Cosenza MR, Korbel JO. Integrating multimodal cancer data using deep latent variable path modelling. Nature Machine Intelligence 7, 1053-1075 (2025). https://doi.org/10.1038/s42256-025-01052-4

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

deep_lvpm-0.2.0.tar.gz (11.2 MB view details)

Uploaded Source

Built Distribution

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

deep_lvpm-0.2.0-py3-none-any.whl (11.1 MB view details)

Uploaded Python 3

File details

Details for the file deep_lvpm-0.2.0.tar.gz.

File metadata

  • Download URL: deep_lvpm-0.2.0.tar.gz
  • Upload date:
  • Size: 11.2 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for deep_lvpm-0.2.0.tar.gz
Algorithm Hash digest
SHA256 6b70569ed8042b071f28b80f36bd8b23b172a5098ed46f69888ccc4280e42ac1
MD5 9b58feed09abb06e64cd1440dbd4ff4d
BLAKE2b-256 874ff0d0a40b2f8e413f8793b06d71b860b3f92cae07fed9ebf3ae8736899899

See more details on using hashes here.

Provenance

The following attestation bundles were made for deep_lvpm-0.2.0.tar.gz:

Publisher: publish-pypi.yml on alexjamesing/Deep_LVPM

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file deep_lvpm-0.2.0-py3-none-any.whl.

File metadata

  • Download URL: deep_lvpm-0.2.0-py3-none-any.whl
  • Upload date:
  • Size: 11.1 MB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for deep_lvpm-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 32c1c11f5fe3d6bfaebb88134e7addfe4f913593c96d8a3bdb687da11f9023ad
MD5 a2f7ed60177b9ebfc2e77897cb59e0c8
BLAKE2b-256 1254d98b30bd02d5009406c15061da8f699ce5d1860c68e5a5eca3ec9fb7f980

See more details on using hashes here.

Provenance

The following attestation bundles were made for deep_lvpm-0.2.0-py3-none-any.whl:

Publisher: publish-pypi.yml on alexjamesing/Deep_LVPM

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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