Skip to main content

Deep Learning Toolkit — Reusable PyTorch building blocks for artificial intelligence & scientific machine learning: networks, losses, training loops, and utilities.

Project description

Deep Learning Toolkit

Format Compile Lint Tests

Reusable PyTorch building blocks for artificial intelligence & scientific machine learning: networks, losses, training loops, and utilities.


Installing the deep-learning-toolkit

Requirements

  • Python >=3.11

Runtime dependencies

  • prettytable>=3,<4
  • pyyaml>=6,<7
  • torch>=2,<3
  • tqdm>=4,<5

Install in regular mode

pip install deep-learning-toolkit

Install the package in editable mode

When using a clone of the Git repository, run this command from inside the cloned directory:

pip install -e .

Install with optional extras

Dependencies for kernel density estimation:

pip install -e ".[kde]"

Dependencies for running tests:

pip install -e ".[test]"

Install with optional extras for development

pip install -e ".[dev]"

Using [dev] includes extras from [test].


Importing and using dlk

To use the toolkit, import its modules in your Python code like this:

from dlk.nets.mlp import MLPNet
from dlk.opt.train import train_epochs

# load your data
...

# create the model
net = MLPNet(input_size=784, output_size=10)

# train the model
train_epochs(n_epochs=100, net=net, dataloader=..., optimizer=..., loss_fn=...)

# evaluate
...

Architecture

Neural network architectures → dlk/nets/

  • mlp.py: Multilayer Perceptron (MLPNet, MLPNet_MultIn, MLPResNet with residual and attention blocks)
  • autoencoder.py: Generic autoencoder wrapper for encoder/decoder pairs
  • conv1d.py, conv2d.py: 1D/2D convolutional networks and UNet components (Downsample, Upsample)
  • unet.py: Complete UNet implementations (older UNet1D/UNet2D and newer UNetXd_2025 architecture)
  • transformer1d.py: 1D transformer networks with patch embeddings and multi-head attention
  • efficientnet.py: EfficientNet architecture

Network initialization

All network modules follow a consistent pattern:

  • Constructor calls self.init_parameters() at the end
  • init_parameters() uses Xavier initialization with gain calculated from activation functions
  • Utility functions _get_gain() and _set_init_parameters() handle activation-aware initialization

Training and optimization → dlk/opt/

  • train.py: Training loops (train_epochs, train_batches) with checkpointing and validation hooks
  • train_gan.py: GAN-specific training loops
  • scheduler.py: Learning rate schedulers (multi-stage: linear warmup, constant, cosine annealing)

Logging of the training progress

Training functions return detailed logging dictionaries (dlog) containing:

  • Per-epoch loss statistics (loss_mean, loss_std)
  • Batch-level logs nested in batch_dlog
  • Total training time in time_train
  • Checkpointing saves model and optimizer states at specified intervals

Additional components of the package

  • dlk/mgmt/: Management of configuration parameter loading/saving, logging, etc.
  • dlk/loss/: Loss functions
  • dlk/metrics/: Metrics for evaluating trained nets

Development

Commands for development

  • make format: run isort and black on dlk/ and tests/
  • make format-check: check isort and black formatting without modifying files
  • make compile: run python -m compileall -q -f on dlk/ and tests/
  • make lint: run basedpyright on dlk/ and tests/
  • make test: run pytest (after make compile)
  • make testq: run pytest -q (after make compile)
  • make testv: run pytest -v (after make compile)
  • make testvv: run pytest -sv (after make compile)

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_learning_toolkit-0.4.0.tar.gz (78.7 kB view details)

Uploaded Source

Built Distribution

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

deep_learning_toolkit-0.4.0-py3-none-any.whl (92.2 kB view details)

Uploaded Python 3

File details

Details for the file deep_learning_toolkit-0.4.0.tar.gz.

File metadata

  • Download URL: deep_learning_toolkit-0.4.0.tar.gz
  • Upload date:
  • Size: 78.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for deep_learning_toolkit-0.4.0.tar.gz
Algorithm Hash digest
SHA256 49b8b646ae511838c9e825109f3f504d0d51e0b58c92bb123bf5796f3de0bc49
MD5 110c6227239d3e3faae07eebf8fe64cf
BLAKE2b-256 c3d80be5b2731ce1f452765f5c12dffc2f1628d92ad81ecb400643e8661ddbb3

See more details on using hashes here.

Provenance

The following attestation bundles were made for deep_learning_toolkit-0.4.0.tar.gz:

Publisher: publish.yml on johannrudi/deep-learning-toolkit

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_learning_toolkit-0.4.0-py3-none-any.whl.

File metadata

File hashes

Hashes for deep_learning_toolkit-0.4.0-py3-none-any.whl
Algorithm Hash digest
SHA256 f3bb655160dd4fd64060cb33a9d09a36a7290b2cd31a936099eacb0119210acd
MD5 7f337df245d8e6b7e76d99c47bb6cc02
BLAKE2b-256 0f5d6a1600f4f0c51cbb274a2930f3ca314bbd9ee3509c0b4021eca6d287a6ec

See more details on using hashes here.

Provenance

The following attestation bundles were made for deep_learning_toolkit-0.4.0-py3-none-any.whl:

Publisher: publish.yml on johannrudi/deep-learning-toolkit

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