Code for the papers "Symmetric Spaces for Graph Embeddings: A Finsler-Riemannian Approach" published at ICML 2021, and the paper "Hermitian Symmetric Spaces for Graph Embeddings" published at DiffGeo4DL @ NeurIPS 2020.
Vector models:
euclidean
poincare
lorentz
sphere
prod-hysph
: Product of hyperbolic x sphereprod-hyhy
: Product of hyperbolic x hyperbolicprod-hyeu
: Product of hyperbolic x euclideanMatrix models:
spd
: Symmetric positive definite matrices spaceupper
: Upper half space model of the Siegel spacebounded
: Bounded domain model of the Siegel spacedual
: Compact dualThe last three allow different metrics
riem
: Riemannian metricfone
: Finsler Onefinf
: Finsler Infinityfmin
: Finsler metric of minimum entropywsum
: Learns weights for a weighted sum of the vector-valued distanceconda install pytorch==1.5.1 torchvision==0.6.1 [cpuonly | cudatoolkit=10.2] -c pytorch
.
In CPU environments, data parallel is not stable with pytorch >= 1.6 pip install git+https://github.com/geoopt/geoopt.git
In all preprocessing cases, the option --run_id=RUN_ID
is required. The data will be saved in data/RUN_ID
.
If --plot_graph
is passed, a plot will be generated, but the plotting can take a long time if the graph is large.
Grids:
python preprocess.py --graph=grid --grid_dims=DIMS --nodes=NODES --run_id=RUN_ID
It will create a grid of DIMS
dimensions with int(NODES^(1/DIMS))
nodes.
Ex: python preprocess.py --graph=grid --grid_dims=3 --nodes=27
will create a 3x3x3 cube graph
Trees
python preprocess.py --graph=tree --tree_branching=BRANCHING --tree_height=HEIGHT --run_id=RUN_ID
It will create a tree with branching factor BRANCHING
and height HEIGHT
.
Cartesian or Rooted products
By default it will create a cartesian/rooted product of a tree and a grid, but it can be modified by changing the order in the code
python preprocess.py --graph=product-cartesian --grid_dims=DIMS --nodes=NODES --tree_branching=BRANCHING --tree_height=HEIGHT --run_id=RUN_ID
It will create a cartesian (rooted with --graph=product-rooted
) product of the specified tree and grid.
Social Networks
python preprocess.py --graph=TYPE --run_id=RUN_ID
Current available options are social-karate
, social-davis
, social-florentine
, social-miserables
.
See NetworkX doc
Expanders
python preprocess.py --graph=TYPE --nodes=NODES --run_id=RUN_ID
Current available options are expander-margulis
, expander-chordal
, expander-paley
.
See NetworkX expanders doc
Custom
python preprocess.py --graph=NAME --run_id=RUN_ID
It will look for a file in data/NAME/NAME.edges
where the graph should be represented as:
src_node1 dst_node1 [weight1]
src_node2 dst_node2 [weight2]
...
where src_node
and dst_node
are int
values and weight
is an optional float
value.
python -m torch.distributed.launch --nproc_per_node=N_CPUS --master_port=2055 train.py \\
--n_procs=N_CPUS \\
--data=PREP \\
--run_id=RUN_ID \\
--results_file=out/results.csv \\
--model=MODEL \\
--metric=riem \\
--dims=4 \\
--learning_rate=1e-2 \\
--val_every=25 \\
--patience=50 \\
--max_grad_norm=100 \\
--batch_size=2048 \\
--epochs=1000
Experiments can be run distributed over multiple CPUs/GPUs with N_CPUS
.
PREP
must be the name of the graph to embed (what in step 1 was called RUN_ID
).
Results will be reported in results_file
with run_id
as the name.
For model
and metric
see Available Models
The method inner
is implemented for both the Upper Half space and the Bounded domain model.
With this, experiments can be run with RiemannianAdam
.
However, we found them to be very unstable, therefore all experiments reported in the paper were run with RiemannianSGD
The source code and data in this repository aims at facilitating the study of graph embeddings in symmetric spaces. If you use the code/data, please cite it as follows:
@InProceedings{lopez2021symmetric,
title = {Symmetric Spaces for Graph Embeddings: A Finsler-Riemannian Approach},
author = {L\'opez, Federico and Pozzetti, Beatrice and Trettel, Steve and Strube, Michael and Wienhard, Anna},
booktitle = {Proceedings of the 38th International Conference on Machine Learning},
pages = {7090--7101},
year = {2021},
editor = {Meila, Marina and Zhang, Tong},
volume = {139},
series = {Proceedings of Machine Learning Research},
month = {18--24 Jul},
publisher = {PMLR},
pdf = {http://proceedings.mlr.press/v139/lopez21a/lopez21a.pdf},
url = {http://proceedings.mlr.press/v139/lopez21a.html}
}