Official repository for the paper "Learning Latent Graph Structures and Their Uncertainty" (ICML 2025)
Official repository for the paper "Learning Latent Graph Structures and Their Uncertainty" (ICML 2025) by Alessandro Manenti, Daniele Zambon and Cesare Alippi. Please cite as:
@inproceedings{manenti2025learning,
title={Learning latent graph structures and their uncertainty},
author={Manenti, Alessandro and Zambon, Daniele and Alippi, Cesare},
booktitle={Forty-second International Conference on Machine Learning},
year={2025}
}This repository contains a refactoring of the code used in the paper "Learning Latent Graph Structures and Their Uncertainty" (ICML 2025). The code is designed to be modular and easy to use, allowing for quick experimentation with different GNNs and Datasets.
The code has been tested with the following versions of Python and libraries:
Python 3.11.11torch 2.7.0torch-geometric 2.6.1
A fast installation of the required packages can be done using the following commands:
conda create LLGS python=3.11
conda activate LLGS
pip install torch
pip install torch-geometric
pip install einops
pip install hydra-core --upgrade
pip install hydra-joblib-launcher --upgrade
pip install matplotlibInside the conda environment, run the following command to start the training
python experiments/run_experiment.pyThis will start the training of the model with the parameters defined in config/base.yaml. You can modify the parameters in this file, in the config/ subfolders files or in the command line. For example, to change the number of epochs to 5, you can run the following command:
python experiments/run_experiment.py optimization.hparams.epochs=5We recommend using the ENG_DIST loss instead of the MMD as no additional hyperparameters are needed.
The code uses the hydra library for configuration management. If you are not familiar with hydra, you can check the documentation for more information.
To run different GNNs, you can modify model.gnn.name parameter in model_base.yaml with any of the torch-geometric Models.
You should also modify the model.gnn.kwargs parameters accordingly. Since the dataset is build using another GNN, you should also modify the dataset.params in dataset_base.yaml accordingly or disable the sanity check performed by the sanity_check_gnn_kwargs(cfg) function.
To use the code with new datasets, you need to
- Comment lines 30-31 in
experiments/run_experiment.pyto avoid loading the true graph as comparison and uncomment line 32. - Modify the
get_dataloadersfunction inutils/data_utils.pyto load your dataset. The function should return the train, val and test dataloaders. A batch element in the loader should have the following structure:
for batch in loader:
break
x = batch.input['x'] # has shape [batch_size, input_features, num_nodes, 1]
y = batch.target['y'] # has shape [batch_size, output_features, num_nodes, 1]