Skip to main content

Basenji2 in PyTorch

This repo provides a PyTorch re-implementation of the Basenji2 model published in "Cross-species regulatory sequence activity prediction" by David Kelley. This implementation was checked by verifying that the Tensorflow and PyTorch version yielded the same output on random data. Small deviations were found, likely due to differences in the underlying algorithms used by Tensorflow and PyTorch (e.g. different matrix multiplication algorithms). In addition, Qixiu Du kindly computed evaluation metrics and found that the PyTorch re-implementation achieves competitive performance on real data, further validating the port.

Installation

pip install basenji2-pytorch

Usage

import torch
from basenji2_pytorch import Basenji2, basenji2_params, basenji2_weights # or PLBasenji2 to also use training parameters from Kelley et al. 2020

# to use a headless model e.g. for transfer learning
# basenji2_params["model"].pop("head_human", None)

basenji2 = Basenji2(basenji2_params["model"])
basenji2.load_state_dict(torch.load(basenji2_weights()), strict=False)
  • basenji2_params is a dictionary of both training and model parameters matching the implementation in Kelley et al. 2020
  • basenji2_weights is a function that uses pooch to download weights from Zenodo and return the path as a string.
  • Basenji2 is a PyTorch nn.Module that can be initialized from the model parameters of basenji2_params
  • PLBasenji2 is a PyTorch Lightning module that can be initialized from basenji2_params to match both the training and architectural parameters of Basenji2

Metadata

Release files for basenji2-pytorch 0.1.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for basenji2-pytorch 0.1.2
File Size Uploaded
basenji2_pytorch-0.1.2.tar.gz 83.9 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for basenji2-pytorch 0.1.2
File Interpreter ABI Platform
basenji2_pytorch-0.1.2-py3-none-any.whl Python 3 none any Details

Total release size: 91.9 kB

Release files / basenji2_pytorch-0.1.2.tar.gz

Download URL basenji2_pytorch-0.1.2.tar.gz
Size 83.9 kB
Tags Source
SHA-256 checksum
How to use checksums
5219ee21bdc41c09c62818a3ace647112377d26864ea2b9969b27fb08c78d848
BLAKE2b-256 checksum
How to use checksums
d5c55d0b5a5852262b0c04fc56f064c2049aeb637f6c72a5b540fae584c8ad57
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.6.4

Release files / basenji2_pytorch-0.1.2-py3-none-any.whl

Download URL basenji2_pytorch-0.1.2-py3-none-any.whl
Size 8.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
f56c0797eb7758ff11bf9e1b4b9044eda487438e47a0b547e220f6a3ab32658e
BLAKE2b-256 checksum
How to use checksums
2dead6230cc9772edca0fd8c91638dc1c2e2def09b9a22cfabe6532906e96aea
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.6.4

Release history Release notifications | RSS feed

This release

0.1.2 This release

2 release files

0.1.1

2 release files

0.1.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page