Tversky Neural Network
Project description
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}
}
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file tversky_neural_network_pytorch-0.0.2.tar.gz.
File metadata
- Download URL: tversky_neural_network_pytorch-0.0.2.tar.gz
- Upload date:
- Size: 4.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.9.23
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d8d41feda95d318f980a74aeb85945e20cb0a5c057146b2921a7bc340e0b9855
|
|
| MD5 |
a8849afb7c7991c3a372f9d88dc824ac
|
|
| BLAKE2b-256 |
9248c751bea4233fa4d8c83addb501fc217a4cced04ca29da76b7be75390cbd1
|
File details
Details for the file tversky_neural_network_pytorch-0.0.2-py3-none-any.whl.
File metadata
- Download URL: tversky_neural_network_pytorch-0.0.2-py3-none-any.whl
- Upload date:
- Size: 5.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.9.23
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
00e9fc711ee9a4498fe27ba5d0e847633e0d87e0e22f9b199be639077e238dc8
|
|
| MD5 |
31deebe75ff0d70c11c20daa023ae8c4
|
|
| BLAKE2b-256 |
149329193818c7467379831f24f6caee73cfa66718099af3bb7d90eceddb5bca
|