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.1.tar.gz (78.6 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.1-py3-none-any.whl (92.0 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: deep_learning_toolkit-0.4.1.tar.gz
  • Upload date:
  • Size: 78.6 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.1.tar.gz
Algorithm Hash digest
SHA256 a5843adc95f4509fb16ca8f01b59f84d17878c4890e02b51b7b26ca3bf0b16d8
MD5 169f0b2bd0d8a03e0b2f45279bf51a7e
BLAKE2b-256 c17d2cec7c16e823395b4502ae3637b622b37c56c3622a593cf04a431966ec8b

See more details on using hashes here.

Provenance

The following attestation bundles were made for deep_learning_toolkit-0.4.1.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.1-py3-none-any.whl.

File metadata

File hashes

Hashes for deep_learning_toolkit-0.4.1-py3-none-any.whl
Algorithm Hash digest
SHA256 debe889fc97c52f3977758de591152f8df05f63c2b9a09e59610c3bbb7a3bbff
MD5 1f4ca3c0a7a816a1b0c441ae158384e3
BLAKE2b-256 b58b633bfe7283e73ab8a7c8007ce979f92af6e24503bd0228fc9def4f0f6ad5

See more details on using hashes here.

Provenance

The following attestation bundles were made for deep_learning_toolkit-0.4.1-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