EDRep
Efficient distributed representations with linear-time SoftMax normalization
EDRep is a Python package to learn distributed representations (embeddings) of any entity described by a probability matrix $P$, such as the nodes of a graph, users and items, or words. Embeddings are obtained by minimizing the cross-entropy between $P$ and a SoftMax of the scalar products of the embedding vectors:
Computing the SoftMax normalization constants exactly takes quadratic time. EDRep estimates them in linear time with a mixture-of-Gaussians approximation, making the method fast, interpretable and easy to adapt to arbitrary embedding problems. The method is described in our TMLR paper.
Installation
Install the package from PyPI:
pip install EDRep
We also share the Anaconda environment in which all the code was run and tested (EDRep_env.yml in the repository):
conda env create -f EDRep_env.yml
conda activate EDRep
Quick start
from scipy.sparse import csr_matrix
from EDRep import CreateEmbedding, NodeEmbedding
# embed a (sparse) row-stochastic matrix P
res = CreateEmbedding([P], dim = 32)
X = res.X # n x dim embedding matrix
# or embed the nodes of a graph from its adjacency matrix A
res = NodeEmbedding(A, dim = 32)
The pages below are rendered from Jupyter notebooks, which you can download from each page and run yourself, together with the helper scripts they import from src/. The datasets are not included: each page explains where to find them.
Contents
Citation
If you use this package, please cite:
@article{dallamico2025learning,
title = {Learning distributed representations with efficient SoftMax normalization},
author = {Dall'Amico, Lorenzo and Belliardo, Enrico Maria},
journal = {Transactions on Machine Learning Research},
issn = {2835-8856},
year = {2025},
url = {https://openreview.net/forum?id=9M4NKMZOPu}
}