This repository contains the code to replicate the experiments in the paper Sparse Covariance Neural Networks (link).
Sparse coVariance Neural Networks (SVNNs) are graph convolutional networks that operate on sparse estimates of the covariance matrix. Using sparse estimates improves their robustness to spurious correlations and their computational efficiency, resulting in better downstream performance and faster execution times.
- Python 3.10.18
pip install -r requirements.txt
The datasets are automatically preprocessed from the raw files the first time they are used (see data/data_loading.py for the details on the preprocessing steps). The following files should be downloaded and placed at the path data/datasets:
From the website https://ida.loni.usc.edu/, download the files ADSP_PHC_T1_FS_DATADIC and ADSP_PHC_T1_FS and place them in the folder data/datasets/adni
From the website https://archive.ics.uci.edu/dataset/319/mhealth+dataset, download the folder MHEALTHDATASET and place it at the path data/datasets/MHEALTHDATASET
From the website https://archive.ics.uci.edu/dataset/305/realdisp+activity+recognition+dataset, download the folder realdisp+activity+recognition+dataset and place it at the path data/datasets/realdisp+activity+recognition+dataset
The experiments in the paper can be replicated by using the files train.py (for S-VNNs and VNNs), train_neigh_sampling.py (for NeighSampl+GCN) and train_pca.py (for PCA and MLP baselines). The hyperparameters can be specified via command line. The file run_exp.py contains examples of commands for the various experiments. Below are the main arguments to be specified for an experiment.
dset: selects the dataset. Can beadni1,adni2,mhealth,realdisp.
cov_type: selects the covariance sparsification. Can bestandardfor VNNs (no sparsification) orhard_thr,soft_thr,ACV,RCVfor S-VNNs.p: parameter for RCV S-VNNs. If used with hard or soft thresholding, the threshold is set to achieve the desired sparsification level.hidden_sizes: comma-separated list with sizes of VNN hidden layers (e.g., 32,32 for 2 layers of hidden size 32).hidden_mlp_sizes: comma-separated list with sizes of readout MLP hidden layers (e.g., 32,32 for 2 layers of hidden size 32). The first dimension should correspond to the last dimension ofhidden_sizes.K: order of S-VNNs filtersuse_batch_norm: whether to implement batch normalization (TrueorFalse)use_layer_norm: whether to implement layer normalization (TrueorFalse)trace_norm: whether to normalize the covariance by its trace for numerical stability (TrueorFalse)sparse_tensor: whether to implement the covariance as a sparse tensor (TrueorFalse)
nEpochs: number of training epochspatience: number of epochs after which training is stopped if there is no improvement on validation setbatchSize: batch sizelr: learning ratedropout: dropout rate (0.0 for no dropout)iterations: number of iterations per experiment
pca_type: for MLP and PCA experiments:Nonefor MLP on raw data,standard,sparse,kernelfor PCA variantsn_components: number of PCA components