Tversky Neural Network - PyTorch
Implementation of Tversky Neural Networks in PyTorch.
Tversky (1977) argued that similarity judgments can be regarded as extensions of similarity statements. Such statements are directional, in the sense that "a is like b" may differ from "b is like a." However, most neural network architectures in deep learning model similarity through dot-product measures, which are symmetric and therefore have generally not incorporated asymmetry, given the challenges of representing it in differentiable form. Motivated by Tversky's insight, Doumbouya et al. (2025) has introduced architectures that incorporate asymmetric similarity.
From set form,
to differentiable vector form.
Install
$ pip install tversky-neural-network-pytorch
Usage
Tversky Projection Layer
import torch
from tversky_neural_network import TverskyProjectionLayer
model = TverskyProjectionLayer(
in_features = 32,
out_features = 16,
num_features = 8,
alpha = 0.5,
beta = 0.5,
theta = 1.0,
eps = 1e-8,
psi = "softmin",
softmin_tau = 0.8,
match_type = "subtract",
)
x = torch.randn(10, 32)
out = model(x)
loss = out.sum()
loss.backward()
Develop in Docker
-
Start the development environment:
$ docker compose up -d
-
Access docker container terminal with:
$ docker exec -it dev /bin/bash
Exit terminal with
CTRL + D. -
Stop docker container with:
$ docker compose down
-
In container terminal, execute scripts with:
$ uv run python your_script.py # test $ uv run pytest -v
Citations
@article{doumbouya2025tversky,
title={Tversky Neural Networks: Psychologically Plausible Deep Learning with Differentiable Tversky Similarity},
author={Doumbouya, Moussa Koulako Bala and Jurafsky, Dan and Manning, Christopher D},
journal={arXiv preprint arXiv:2506.11035},
year={2025}
}
@article{tversky1977features,
title={Features of similarity.},
author={Tversky, Amos},
journal={Psychological review},
volume={84},
number={4},
pages={327},
year={1977},
publisher={American Psychological Association}
}
Metadata
Release files for tversky-neural-network-pytorch 0.0.2
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| tversky_neural_network_pytorch-0.0.2.tar.gz | 4.8 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| tversky_neural_network_pytorch-0.0.2-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 10.2 kB
Release files / tversky_neural_network_pytorch-0.0.2.tar.gz
| Download URL | tversky_neural_network_pytorch-0.0.2.tar.gz |
|---|---|
| Size | 4.8 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
d8d41feda95d318f980a74aeb85945e20cb0a5c057146b2921a7bc340e0b9855
|
|
BLAKE2b-256 checksum How to use checksums |
9248c751bea4233fa4d8c83addb501fc217a4cced04ca29da76b7be75390cbd1
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.9.23
|
Release files / tversky_neural_network_pytorch-0.0.2-py3-none-any.whl
| Download URL | tversky_neural_network_pytorch-0.0.2-py3-none-any.whl |
|---|---|
| Size | 5.5 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
00e9fc711ee9a4498fe27ba5d0e847633e0d87e0e22f9b199be639077e238dc8
|
|
BLAKE2b-256 checksum How to use checksums |
149329193818c7467379831f24f6caee73cfa66718099af3bb7d90eceddb5bca
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.9.23
|