Skip to main content

Dualing

CI PyPI Python License

Dualing provides small TensorFlow building blocks for contrastive, cross-entropy, and triplet Siamese networks.

Install

uv add dualing

Dualing requires Python 3.11 or newer.

Quick start

import numpy as np

from dualing import MLP, ContrastiveSiamese, balanced_pair_dataset

samples = np.random.default_rng(0).normal(size=(100, 16))
labels = np.repeat([0, 1], 50)
dataset = balanced_pair_dataset(samples, labels, n_pairs=100, batch_size=16)

model = ContrastiveSiamese(MLP((32, 8)))
model.compile(optimizer="adam")
model.fit(dataset, epochs=5)

Dataset helpers return native tf.data.Dataset objects and all models use standard Keras compile, fit, and evaluate behavior. The original dualing.core, dualing.datasets, dualing.models.base, and dualing.utils APIs remain available.

Native pair datasets yield ((left, right), labels) or ((left, right), labels, sample_weights). The original pair dataset classes yield (left, right, labels) through their .batches attribute. Both forms work with pair-model fit, evaluate, and fit(validation_data=...). Default pair losses retain one value per pair so Keras can apply sample weights.

Native and original dataset APIs share preprocessing: normalization maps constant data to the lower bound instead of producing NaNs. Use normalize=None to leave values unscaled.

Development

uv sync
uv run pytest
uv run ruff check .
uv run ruff format --check .
uv run --group docs sphinx-build -W -b html docs docs/_build/html
uv build

API documentation is available at dualing.readthedocs.io.

Download files

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

Source Distribution

dualing-2.0.2.tar.gz (23.2 kB view details)

Uploaded Source

Built Distribution

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

dualing-2.0.2-py3-none-any.whl (25.6 kB view details)

Uploaded Python 3

File details

Details for the file dualing-2.0.2.tar.gz.

File metadata

  • Download URL: dualing-2.0.2.tar.gz
  • Upload date:
  • Size: 23.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.12.10 {"installer":{"name":"uv","version":"0.12.10","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for dualing-2.0.2.tar.gz
Algorithm Hash digest
SHA256 4c63a96460bc3554cd557362e98e5d2f847173a5dfe317cd4c9837494899f0cf
MD5 1b9e435285866c34b380ce612008995e
BLAKE2b-256 490fdca282ca7d30c690ea9d219f0a74a7ffbed2807450df51cdde60f5ecb8e8

See more details on using hashes here.

File details

Details for the file dualing-2.0.2-py3-none-any.whl.

File metadata

  • Download URL: dualing-2.0.2-py3-none-any.whl
  • Upload date:
  • Size: 25.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.12.10 {"installer":{"name":"uv","version":"0.12.10","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for dualing-2.0.2-py3-none-any.whl
Algorithm Hash digest
SHA256 b88a56df7ace2418b0ab9d2a6347f8a9e2b6b9bcdd87934da518754217eb9be3
MD5 920993996a41983712091c763d3d21ba
BLAKE2b-256 ea76532f2c25bdb9c7f6baeadcb76a4554b0e07ea152641ff2cee31ddc18e64d

See more details on using hashes here.

Release history Release notifications | RSS feed

2.0.3

2 files

This release

2.0.2 This release

2 files

2.0.1

2 files

2.0.0

2 files

1.0.3

2 files

1.0.2

2 files

1.0.1

2 files

1.0.0

2 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