Git Product home page Git Product logo

hgcn's Introduction

Hyperbolic Graph Convolutional Networks in PyTorch

1. Overview

This repository is a graph representation learning library, containing an implementation of Hyperbolic Graph Convolutions [1] in PyTorch, as well as multiple embedding approaches including:

Shallow methods (Shallow)

  • Shallow Euclidean
  • Shallow Hyperbolic [2]
  • Shallow Euclidean + Features (see [1])
  • Shallow Hyperbolic + Features (see [1])

Neural Network (NN) methods

  • Multi-Layer Perceptron (MLP)
  • Hyperbolic Neural Networks (HNN) [3]

Graph Neural Network (GNN) methods

  • Graph Convolutional Neural Networks (GCN) [4]
  • Graph Attention Networks (GAT) [5]
  • Hyperbolic Graph Convolutions (HGCN) [1]

All models can be trained for

  • Link prediction (lp)
  • Node classification (nc)

2. Setup

2.1 Installation with conda

If you don't have conda installed, please install it following the instructions here.

git clone https://github.com/HazyResearch/hgcn

cd hgcn

conda env create -f environment.yml

2.2 Installation with pip

Alternatively, if you prefer to install dependencies with pip, please follow the instructions below:

virtualenv -p [PATH to python3.7 binary] hgcn

source hgcn/bin/activate

pip install -r requirements.txt

2.3 Datasets

The data/ folder contains source files for:

  • Cora
  • Pubmed
  • Disease
  • Airport

To run this code on new datasets, please add corresponding data processing and loading in load_data_nc and load_data_lp functions in utils/data_utils.py.

3. Usage

3.1 set_env.sh

Before training, run

source set_env.sh

This will create environment variables that are used in the code.

3.2 train.py

This script trains models for link prediction and node classification tasks. Metrics are printed at the end of training or can be saved in a directory by adding the command line argument --save=1.

optional arguments:
  -h, --help            show this help message and exit
  --lr LR               learning rate
  --dropout DROPOUT     dropout probability
  --cuda CUDA           which cuda device to use (-1 for cpu training)
  --epochs EPOCHS       maximum number of epochs to train for
  --weight-decay WEIGHT_DECAY
                        l2 regularization strength
  --optimizer OPTIMIZER
                        which optimizer to use, can be any of [Adam,
                        RiemannianAdam]
  --momentum MOMENTUM   momentum in optimizer
  --patience PATIENCE   patience for early stopping
  --seed SEED           seed for training
  --log-freq LOG_FREQ   how often to compute print train/val metrics (in
                        epochs)
  --eval-freq EVAL_FREQ
                        how often to compute val metrics (in epochs)
  --save SAVE           1 to save model and logs and 0 otherwise
  --save-dir SAVE_DIR   path to save training logs and model weights (defaults
                        to logs/task/date/run/)
  --sweep-c SWEEP_C
  --lr-reduce-freq LR_REDUCE_FREQ
                        reduce lr every lr-reduce-freq or None to keep lr
                        constant
  --gamma GAMMA         gamma for lr scheduler
  --print-epoch PRINT_EPOCH
  --grad-clip GRAD_CLIP
                        max norm for gradient clipping, or None for no
                        gradient clipping
  --min-epochs MIN_EPOCHS
                        do not early stop before min-epochs
  --task TASK           which tasks to train on, can be any of [lp, nc]
  --model MODEL         which encoder to use, can be any of [Shallow, MLP,
                        HNN, GCN, GAT, HGCN]
  --dim DIM             embedding dimension
  --manifold MANIFOLD   which manifold to use, can be any of [Euclidean,
                        Hyperboloid, PoincareBall]
  --c C                 hyperbolic radius, set to None for trainable curvature
  --r R                 fermi-dirac decoder parameter for lp
  --t T                 fermi-dirac decoder parameter for lp
  --pretrained-embeddings PRETRAINED_EMBEDDINGS
                        path to pretrained embeddings (.npy file) for Shallow
                        node classification
  --pos-weight POS_WEIGHT
                        whether to upweight positive class in node
                        classification tasks
  --num-layers NUM_LAYERS
                        number of hidden layers in encoder
  --bias BIAS           whether to use bias (1) or not (0)
  --act ACT             which activation function to use (or None for no
                        activation)
  --n-heads N_HEADS     number of attention heads for graph attention
                        networks, must be a divisor dim
  --alpha ALPHA         alpha for leakyrelu in graph attention networks
  --use-att USE_ATT     whether to use hyperbolic attention in HGCN model
  --double-precision DOUBLE_PRECISION
                        whether to use double precision
  --dataset DATASET     which dataset to use
  --val-prop VAL_PROP   proportion of validation edges for link prediction
  --test-prop TEST_PROP
                        proportion of test edges for link prediction
  --use-feats USE_FEATS
                        whether to use node features or not
  --normalize-feats NORMALIZE_FEATS
                        whether to normalize input node features
  --normalize-adj NORMALIZE_ADJ
                        whether to row-normalize the adjacency matrix
  --split-seed SPLIT_SEED
                        seed for data splits (train/test/val)

4. Examples

We provide examples of training commands used to train HGCN and other graph embedding models for link prediction and node classification. In the examples below, we used a fixed random seed set to 1234 for reproducibility purposes. Note that results might slightly vary based on the machine used. To reproduce results in the paper, run each commad for 10 random seeds and average the results.

4.1 Training HGCN

Link prediction

  • Cora (Test ROC-AUC=93.79):

python train.py --task lp --dataset cora --model HGCN --lr 0.01 --dim 16 --num-layers 2 --act relu --bias 1 --dropout 0.5 --weight-decay 0.001 --manifold PoincareBall --log-freq 5 --cuda 0 --c None

  • Pubmed (Test ROC-AUC: 95.17):

python train.py --task lp --dataset pubmed --model HGCN --lr 0.01 --dim 16 --num-layers 2 --act relu --bias 1 --dropout 0.4 --weight-decay 0.0001 --manifold PoincareBall --log-freq 5 --cuda 0

  • Disease (Test ROC-AUC: 87.14):

python train.py --task lp --dataset disease_lp --model HGCN --lr 0.01 --dim 16 --num-layers 2 --num-layers 2 --act relu --bias 1 --dropout 0 --weight-decay 0 --manifold PoincareBall --normalize-feats 0 --log-freq 5

  • Airport (Test ROC-AUC=97.43):

python train.py --task lp --dataset airport --model HGCN --lr 0.01 --dim 16 --num-layers 2 --act relu --bias 1 --dropout 0.0 --weight-decay 0 --manifold PoincareBall --log-freq 5 --cuda 0 --c None

Node classification

  • Cora and Pubmed:

To train train a HGCN node classification model on Cora and Pubmed datasets, pre-train embeddings for link prediction as decribed in the previous section. Then train a MLP classifier using the pre-trained embeddings (embeddings.npy file saved in the save-dir directory). For instance for the Pubmed dataset:

python train.py --task nc --dataset pubmed --model Shallow --lr 0.01 --dim 16 --num-layers 2 --act relu --bias 1 --dropout 0.2 --weight-decay 0.0005 --manifold Euclidean --log-freq 5 --cuda 0 --use-feats 0 --pretrained-embeddings [PATH_TO_EMBEDDINGS]

  • Disease (Test accuracy: 76.77):

python train.py --task nc --dataset disease_nc --model HGCN --dim 16 --lr 0.01 --dim 16 --num-layers 2 --act relu --bias 1 --dropout 0 --weight-decay 0 --manifold PoincareBall --log-freq 5 --cuda 0

4.2 Train other graph embedding models

Link prediction on the Cora dataset

  • Shallow Euclidean (Test ROC-AUC=86.40):

python train.py --task lp --dataset cora --model Shallow --manifold Euclidean --lr 0.01 --weight-decay 0.0005 --dim 16 --num-layers 0 --use-feats 0 --dropout 0.2 --act None --bias 0 --optimizer Adam --cuda 0

  • Shallow Hyperbolic (Test ROC-AUC=85.97):

python train.py --task lp --dataset cora --model Shallow --manifold PoincareBall --lr 0.01 --weight-decay 0.0005 --dim 16 --num-layers 0 --use-feats 0 --dropout 0.2 --act None --bias 0 --optimizer RiemannianAdam --cuda 0

  • GCN (Test ROC-AUC=89.22):

python train.py --task lp --dataset cora --model GCN --lr 0.01 --dim 16 --num-layers 2 --act relu --bias 1 --dropout 0.2 --weight-decay 0 --manifold Euclidean --log-freq 5 --cuda 0

  • HNN (Test ROC-AUC=90.79):

python train.py --task lp --dataset cora --model HNN --lr 0.01 --dim 16 --num-layers 2 --act None --bias 1 --dropout 0.2 --weight-decay 0.001 --manifold PoincareBall --log-freq 5 --cuda 0 --c 1

Node classification on the Pubmed dataset

  • HNN (Test accuracy=68.20):

python train.py --task nc --dataset pubmed --model HNN --lr 0.01 --dim 16 --num-layers 2 --act None --bias 1 --dropout 0.5 --weight-decay 0 --manifold PoincareBall --log-freq 5 --cuda 0

  • MLP (Test accuracy=73.00):

python train.py --task nc --dataset pubmed --model MLP --lr 0.01 --dim 16 --num-layers 2 --act None --bias 0 --dropout 0.2 --weight-decay 0.001 --manifold Euclidean --log-freq 5 --cuda 0

  • GCN (Test accuracy=78.30):

python train.py --task nc --dataset pubmed --model GCN --lr 0.01 --dim 16 --num-layers 2 --act relu --bias 1 --dropout 0.7 --weight-decay 0.0005 --manifold Euclidean --log-freq 5 --cuda 0

  • GAT (Test accuracy=78.50):

python train.py --task nc --dataset pubmed --model GAT --lr 0.01 --dim 16 --num-layers 2 --act elu --bias 1 --dropout 0.5 --weight-decay 0.0005 --alpha 0.2 --n-heads 4 --manifold Euclidean --log-freq 5 --cuda 0

Citation

If you find this code useful, please cite the following paper:

@inproceedings{chami2019hyperbolic,
  title={Hyperbolic graph convolutional neural networks},
  author={Chami, Ines and Ying, Zhitao and R{\'e}, Christopher and Leskovec, Jure},
  booktitle={Advances in Neural Information Processing Systems},
  pages={4869--4880},
  year={2019}
}

Some of the code was forked from the following repositories

References

[1] Chami, I., Ying, R., Ré, C. and Leskovec, J. Hyperbolic Graph Convolutional Neural Networks. NIPS 2019.

[2] Nickel, M. and Kiela, D. Poincaré embeddings for learning hierarchical representations. NIPS 2017.

[3] Ganea, O., Bécigneul, G. and Hofmann, T. Hyperbolic neural networks. NIPS 2017.

[4] Kipf, T.N. and Welling, M. Semi-supervised classification with graph convolutional networks. ICLR 2017.

[5] Veličković, P., Cucurull, G., Casanova, A., Romero, A., Lio, P. and Bengio, Y. Graph attention networks. ICLR 2018.

hgcn's People

Contributors

ines-chami avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

hgcn's Issues

How is the value of curvature set?

Thank you for the code and its an excellent paper. My query is - how is the value of curvature set? Like the paper talks about trainable curvature, in the code, is curvature = number of layers? If yes, then the curvature value is set heuristically?

Thank you in advance!

Screenshot 2020-05-09 at 6 54 12 PM

experiments with GAT

Hello and thank you for your work.

Can you specify the hyperparameters for the experiments with GAT ?

Thanks !

A request for DISEASE-M and HUMAN PPI datasets

Hi,

  Thanks for your great work first. Will you share the DISEASE-M and HUMAN PPI datasets? 

  I notice there was the same request in issue lise and you provide Rex Ying's email address. I have emailed  him but have not got a reply. Hope everything is well with him. And is there any other wey to get these two datasets? 

  Thanks a lot.

Best Regards.

  Dai.

Graph Classification

Is there any variant of this available for graph classification? It would be quite useful. Or if there is any resource that can be useful in tweaking the arch, it would be really appreciated.

A link prediction regularization objective in node classification tasks

Thanks for releasing the detailed code!
However, I am confused about the sentence in paper. According to my understanding, the meaning of the sentence is that a link prediction regularization is added to the objective function (cross entropy) for node classification tasks. But I don't find the corresponding objective function. For node classification tasks, the loss function is still the cross entropy.
image
Or the link prediction regularization is completed in link prediction tasks. And node classification is the downstream of link prediction tasks. When I modify my code in the way, the accuracy of Cora is very low. The accuracy is OK if I comment the part.
image
By the way, the model I use is HGAT.

what does the projection do?

Hi.
I appreciate this wonderful repository.

What role does the projection in hyperboloid.py? I understand that exp and log act as projections, but I wonder why projections are used separately. Interestingly, even if I don't use projection in hyperboloid.py of exp and log maps, I get the same performance as using projection.

Could you please tell me what the role of projection is?

Hyperbolicity of Cora

Hi, thanks for your great work.

I use "hyperbolicity.py" to calculate the hyperbolicity of Cora. In your paper, it is 11 but I got 2.5. I am not sure if it is because I set 'num_samples' too small.

Could please share how you got 11 ? Thanks!

Best.

Mistake in Hyperboloid.py

When I tried to apply the HGCN on the hyperboloid manifold, the HypAGG module raises an error:

File "...\test\hyp_layers2.py", line 176, in forward
h = self.agg.forward(h, adj)

File "...\hyp_layers2.py", line 102, in forward
x_local_tangent.append(self.manifold.logmap(x[i], x, c=self.c))

File "...\manifolds\hyperboloid.py", line 99, in logmap
return self.proj_tan(result, x, c)

File "...\manifolds\hyperboloid.py", line 57, in proj_tan
d = x.size(1) - 1

IndexError: Dimension out of range (expected to be in range of [-1, 0], but got 1)

I changed it to d = x.size(-1) - 1, and it works right. So is this a mistake?

Theoretical/Motivation for why changing curvature works?

Hi, In your paper, you demonstrated the effect of curvature and the improvement of link prediction results when the curvature is decreased. I was wondering if there are any theoretical explanation for this behavior? To quantify the behavior wrt to decreasing curvature?

Thanks in advance!

Hyperbolicity

Hi, Thanks for your great work. I got a problem while calculating 'Hyperbolicity' of Cora. The value you reported is $\delta$ = 11.
However, I use the code you released (./utils/hyperbolicity.py) to calculate the 'Hyperbolicity' of Cora. I got $\delta$ = 2.5. I am confused and did i do something wrong?

Thanks.

Mistake in "hyperboloid.py"

When I ran the model with the following command:
python train.py --task nc --dataset disease_nc --model HGCN --dim 16 --lr 0.01 --dim 16 --num-layers 2 --act relu --bias 1 --dropout 0 --weight-decay 0 --manifold Hyperboloid --log-freq 5 --cuda 0 --use-att 1 --local-agg 1

I got the following error:
image
IndexError: too many indices for tensor of dimension 1

I felt confused about this problem. Please help me.

How to reproduce the visualization part of the paper?

Hi, I read your paper and I esperciall like the visualization of embedding in your job, I expected to reproduce the result on cora, where different classes in cora can be separated well. Could you please show me how to achieve that?

When I use my dataset to train hgcn and hnn models, the curvature is 'nan' and raise error.

/opt/conda/conda-bld/pytorch_1544174967633/work/aten/src/THCUNN/BCECriterion.cu:42: Acctype bce_functor<Dtype, Acctype>::operator()(Tuple) [with Tuple = thrust::detail::tuple_of_iterator_references<thrust::device_reference, thrust::device_reference, thrust::null_type, thrust::null_type, thrust::null_type, thrust::null_type, thrust::null_type, thrust::null_type, thrust::null_type, thrust::null_type>, Dtype = float, Acctype = float]: block: [11,0,0], thread: [209,0,0] Assertion input >= 0. && input <= 1. failed.
/opt/conda/conda-bld/pytorch_1544174967633/work/aten/src/THCUNN/BCECriterion.cu:42: Acctype bce_functor<Dtype, Acctype>::operator()(Tuple) [with Tuple = thrust::detail::tuple_of_iterator_references<thrust::device_reference, thrust::device_reference, thrust::null_type, thrust::null_type, thrust::null_type, thrust::null_type, thrust::null_type, thrust::null_type, thrust::null_type, thrust::null_type>, Dtype = float, Acctype = float]: block: [11,0,0], thread: [210,0,0] Assertion input >= 0. && input <= 1. failed.
/opt/conda/conda-bld/pytorch_1544174967633/work/aten/src/THCUNN/BCECriterion.cu:42: Acctype bce_functor<Dtype, Acctype>::operator()(Tuple) [with Tuple = thrust::detail::tuple_of_iterator_references<thrust::device_reference, thrust::device_reference, thrust::null_type, thrust::null_type, thrust::null_type, thrust::null_type, thrust::null_type, thrust::null_type, thrust::null_type, thrust::null_type>, Dtype = float, Acctype = float]: block: [11,0,0], thread: [211,0,0] Assertion input >= 0. && input <= 1. failed.
/opt/conda/conda-bld/pytorch_1544174967633/work/aten/src/THCUNN/BCECriterion.cu:42: Acctype bce_functor<Dtype, Acctype>::operator()(Tuple) [with Tuple = thrust::detail::tuple_of_iterator_references<thrust::device_reference, thrust::device_reference, thrust::null_type, thrust::null_type, thrust::null_type, thrust::null_type, thrust::null_type, thrust::null_type, thrust::null_type, thrust::null_type>, Dtype = float, Acctype = float]: block: [11,0,0], thread: [212,0,0] Assertion input >= 0. && input <= 1. failed.

torch.Size([80362])
THCudaCheck FAIL file=/opt/conda/conda-bld/pytorch_1544174967633/work/aten/src/THC/THCCachingHostAllocator.cpp line=265 error=59 : device-side assert triggered
Traceback (most recent call last):
File "/data1/home/ideatmp/sigir21/hgcn/models/base_models.py", line 124, in compute_metrics
loss = F.binary_cross_entropy(pos_scores, torch.ones_like(pos_scores))
File "/data1/home/ideatmp/miniconda3/envs/HGN/lib/python3.6/site-packages/torch/nn/functional.py", line 2027, in > > binary_cross_entropy
input, target, weight, reduction_enum)
RuntimeError: reduce failed to synchronize: device-side assert triggered

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "/data1/home/ideatmp/.pycharm_helpers/pydev/pydevd.py", line 1668, in
main()
File "/data1/home/ideatmp/.pycharm_helpers/pydev/pydevd.py", line 1662, in main
globals = debugger.run(setup['file'], None, None, is_module)
File "/data1/home/ideatmp/.pycharm_helpers/pydev/pydevd.py", line 1072, in run
pydev_imports.execfile(file, globals, locals) # execute the script
File "/data1/home/ideatmp/.pycharm_helpers/pydev/_pydev_imps/_pydev_execfile.py", line 18, in execfile
exec(compile(contents+"\n", file, 'exec'), glob, loc)
File "/data1/home/ideatmp/sigir21/hgcn/train.py", line 213, in
train(args, feature)
File "/data1/home/ideatmp/sigir21/hgcn/train.py", line 129, in train
train_metrics = model.compute_metrics(embeddings, data, 'train')
File "/data1/home/ideatmp/sigir21/hgcn/models/base_models.py", line 127, in compute_metrics
print(pos_scores)
File "/data1/home/ideatmp/miniconda3/envs/HGN/lib/python3.6/site-packages/torch/tensor.py", line 66, in repr
return torch._tensor_str._str(self)
File "/data1/home/ideatmp/miniconda3/envs/HGN/lib/python3.6/site-packages/torch/_tensor_str.py", line 277, in _str
tensor_str = _tensor_str(self, indent)
File "/data1/home/ideatmp/miniconda3/envs/HGN/lib/python3.6/site-packages/torch/_tensor_str.py", line 195, in _tensor_str
formatter = _Formatter(get_summarized_data(self) if summarize else self)
File "/data1/home/ideatmp/miniconda3/envs/HGN/lib/python3.6/site-packages/torch/_tensor_str.py", line 221, in > get_summarized_data
return torch.cat((self[:PRINT_OPTS.edgeitems], self[-PRINT_OPTS.edgeitems:]))
RuntimeError: cuda runtime error (59) : device-side assert triggered at /opt/conda/conda-> > bld/pytorch_1544174967633/work/aten/src/THC/THCCachingHostAllocator.cpp:265

I debug the error, it shows when training, the curvature is nan. How to solve this problem?

How to compute Gromov's delta-hyperbolicity?

Hi!
Thank you for your amazing paper.
I am curious about Gromov's delta-hyperbolicity to measure how tree-like a graph is in your paper.
I expected to find an explanation or an implementation of it but I failed.
Could you please show me how to compute it?

Running error

Traceback (most recent call last):
File "C:\Users\86178\hgcn\train.py", line 16, in
from utils.data_utils import load_data
File "C:\Users\86178\hgcn\utils\data_utils.py", line 6, in
import networkx as nx
File "C:\Users\86178\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\LocalCache\local-packages\Python310\site-packages\networkx_init_.py", line 100, in
import networkx.classes.filters
File "C:\Users\86178\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\LocalCache\local-packages\Python310\site-packages\networkx\classes_init_.py", line 1, in
from .graph import Graph
File "C:\Users\86178\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\LocalCache\local-packages\Python310\site-packages\networkx\classes\graph.py", line 23, in
from collections import Mapping
ImportError: cannot import name 'Mapping' from 'collections' (C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.10_3.10.1776.0_x64__qbz5n2kfra8p0\lib\collections_init_.py)

Possible mistake in local aggregation

Hi!

First of all I wanted to thank you for you code, I know it is a bit older but it is still the most legible resource on hyperbolic GNNs that I could find. I am currently dissecting the mechanisms and re-implementing them for pytorch geometric so I would be very happy if you could take a minute of your time.

I encountered what I think is a mistake in the exponential mapping of the locally aggregated feature matrix (hyp_layers.py, line 145):

output = self.manifold.proj(self.manifold.expmap(x, support_t, c=self.c), c=self.c)

where x is the intransformed input features in hyperbolic space and support_t is the result of the neighborhood aggregation in euclidean space.

according to you implementation of expmap(), the first argument is the tensor that should be mapped and the second is the reference point. The way line 145 is written, the input features which are already in hyperbolic space are mapped into hyperbolic space again w.r.t the euclidean aggregated neighborhoods. Did you mean this the other way round? Then it would also line up with equation 9 in the paper.

A short confirmation would be very nice, Thanks in advance!

reference point

Hello,

I have a question related to the reference point of the log and exp mapping in HGCN layer.

Based on eq.9 in the paper, the reference point for log and exp map is the central node x_i. However, in the released code, the reference points are always zero, from line 134 and line 140 in hyp_layer.py.

Thanks!

whether is correct for equation 10 when using Poincare model?

Thanks for your work, I notice that the equation 10 is correct for hyperboloid manifolds, because the tangent spaces of the north pole are shared across hyperboloid manifolds of the same dimension that have different curvatures.

However, whether is the conclusion correct in Poincare model?

Inconsistent with the paper? HypAgg class without attention?

Thanks for releasing the detailed code!
However, I did not manage to find the attention mechanism mentioned in the paper. I do apologize if I missed something here.
Meanwhile, it is hard to reproduce the results with the Hyperboloid model as all configurations listed are for Poincare only.
Really appreciate it if the detailed configuration on the Hyperboloid model could be released as that is the major discussion conducted in the paper.
Regards,

class HypAgg(Module):
"""
Hyperbolic aggregation layer.
"""

def __init__(self, manifold, c, in_features, dropout):
    super(HypAgg, self).__init__()
    self.manifold = manifold
    self.c = c

    self.in_features = in_features
    self.dropout = dropout

def forward(self, x, adj):
    x_tangent = self.manifold.logmap0(x, c=self.c)
    support_t = torch.spmm(adj, x_tangent)
    output = self.manifold.proj(self.manifold.expmap0(support_t, c=self.c), c=self.c)
    return output

def extra_repr(self):
    return 'c={}'.format(self.c)

issue of <(0,X^0,E),o> = 0

The dimension of $ X^{0,E} $ is d, therefor $ (0,X^{0,E}) $ has the d+1 dimension. However, the dimension of o is d. I wonder whether the operation of Minkowski inner product between them is correct.

Reproducibility on Airport (node classification)

Hi, I am running HGCN on Airport (with the command below) in the node classification task. Sadly, I received ~77.86 accuracy on test set, far below ~90.6 reported in the paper.

"python train.py --task nc --dataset airport --model HGCN --lr 0.01 --dim 16 --num-layers 2 --act relu --bias 1 --dropout 0.0 --weight-decay 0 --manifold PoincareBall --log-freq 5 --cuda 0 --c None" -- adapted from the Airport command in README provided for link prediction.

I believe I made mistakes. Any hints are very appreciated!

How to parallelize across multiple graphs?

For the moment, I see that the code allows one to parallelize the computation of node embedding for all nodes in a graph. However, if I want to parallelize the computation across multiple graphs (perhaps by passing multiple graphs per batch), there is an error during the computation for hyperbolic layer because torch.spmm does not support 3D Tensor.

File "~/hgcn/layers/hyp_layers.py", line 133, in forward
support_t = torch.spmm(adj, x_tangent)
RuntimeError: 2D tensors expected, got 3D, 3D tensors at /pytorch/aten/src/THC/generic/THCTensorMathBlas.cu:260

Is there any way for me to perform graph parallelization?

Can it work on Directed Acyclic Graph(DAG)?

Hi,thank you for your wonderful work.

I found that all these data had been processed as undirected graph. I wonder how can process it as directed graph. If not, is that because DAGs are not necessarily Gromov hyperbolic?

Some questions about HypAgg

Hello, my name is Nikita and I'm a second year MSc student at Skolkovo Institute of Science and Technology, Moscow, Russia. I am kinda new to the area of Hyperbolic Deep Learning and I have some questions regarding your paper. I have noticed that in the forward pass of the HypAgg module there is a loop over the 0-th dimension in the case of local aggregation. I wonder if this loop can be avoided in any way and why is there no such loop in the case of aggregation at T_0? The second question is why is there (in the same forward pass) a manifold.proj after manifold.exp? Doesn't manifold.exp guarantee that the result is on the manifold? Or is there some kind of an approximation in the computation of manifold.exp?

Thank you in advance!

PPI

Thank you so much for sharing the repo. Could you also upload the human PPI dataset you used in the paper?

Where does the proj(x, c) function in "hyperboloid" come from?

Hi,

Thanks for sharing the code for your paper. I have read your paper and code, but the implementation of proj(x, c) function in "hyperboloid" confuses me. As far as I understanding from your paper of Eq. 5, the point is already being projected to the Hyperboloid space when you do the "expmap0" operation. But why do you need to do twice "proj" operations after the operation of Eq. 5? And Where does this "proj" operation come from? I can find a similar equation in your appendix, which is Eq. 16, but this is from Euclidean space to Hyperboloid space, right?

Kind Regards,
Jilin

a minor error in class DenseAtt(nn.Module)

Thank for the excellent work and the well written code! But it seems that there is a minor error in class DenseAtt(nn.Module), which is used in the attention based aggregation part.

If we set "--use-att 1 --local-agg 1", which means that the algorithm will use the attention mechanism to update the embedding of the node, we will use class DenseAtt(nn.Module) .
However, there seems something wrong in line 26 here here

According to the formula (8) in sec 4.3 of the original paper, we should use the softmax function to compute the attention weight, but the code here here seems use the sigmoid function and multiplies with the adjacent matrix.

map the output of model back to Euclidean space

Hi!

I had seen your 'HGCN' on github. I'd like to reimplement it, but I'm confused that why you map the output of model back to Euclidean space when computing loss. Could you please explain it?

Thanks!

hyperboloid.py is missing.

Hi.
I appreciate this wonderful repository.

When I clone this and tried to operate, I found the "hyperboloid.py" is missing in HEAD, since it has been removed at the previous commit.

Could you please add the latest hyperboloid manifold into this repo?

Raise OOM error when train 15000 items

I use hnn and delete most of the train_neg (only ten times of train_pos) to train link prediction task. But my GPU is out of memory. How to solve it?

issues of "def split_data()"

I notice that "split_data()" in the script of "hgcn/utils/data_utils.py" sperates dataset into "pos" and "neg" for sampling trn-val-tst uniformly. It is ok for the dataset: "DISEASE" containing only 2 classes but not ok for dataset: "AIRPORT" containing 4 classes. But I notice that in the function of "load_data_nc()" wrote in "hgcn/utils/data_utils.py" use "split_data()" to create splits for both "DISEASE" and "AIRPORT" which may results in 1) repeated samlples in each split and 2) overlapping between splits.

reproducing Disease LP visualization

Hi, I am trying to reproduce Figure 3 (b) in your paper, and what I did was first train Disease_lp data with the hyperboloid manifold for 3 dimension,
python train.py --task lp --dataset disease_lp --model HGCN --lr 0.01 --dim 3 --num-layers 2 --num-layers 2 --act relu --bias 1 --dropout 0 --weight-decay 0 --manifold Hyperboloid --normalize-feats 0 --log-freq 5
And then use your function in the manifold module to convert it to the 2 dimension poincare embedding.
But when I plot the 2d embedding, the points are distributed only in one quarter of the disk and does not look like figure 3 (b) at all. Could you please tell me if I am doing it the way you did it? Thanks!

Query in the distance function

Hi! Excellent paper!

Pardon, if this seems like a silly question. Im having a hard time understanding why is there a square of the distance function?

Screenshot 2020-03-22 at 2 17 39 PM

Batching

Hello, where can I find HGCN model with batching support?

DATAPATH Key Error

Hello,

Thanks for the well written code. I cloned the repository to my local machine, and the example on link prediction with cora dataset, but got the error below. I will appreciate your assistance in fixing this. Thank you

INFO:root:Using: cpu
INFO:root:Using seed 1234.
Traceback (most recent call last):
File "train.py", line 153, in
train(args)
File "train.py", line 48, in train
data = load_data(args, os.path.join(os.environ['DATAPATH'], args.dataset))
File "/home/samuel/Desktop/hgcn/hgcn/lib/python3.6/os.py", line 669, in getitem
raise KeyError(key) from None
KeyError: 'DATAPATH'

Availability of PPI dataset

Thank you very for making the code public. Is it possible to share the PPI dataset used in the experiments?
It seems this PPI dataset is different from the PPI graphs used in previous node classification paper (e.g., GraphSAGE, GAT).

Aggregation & node classification task

Thanks for your paper. I have two questions about this paper.

  1. The code implementation of aggregation is all based on the tangent space of the origin. Could you provide the version conducted on the tangent space of each center node?
  2. I'm not sure how to set the hyperparameters for the node classification task. Could you please tell me how to set them to achieve the results in the paper (especially for the Pubmed dataset).

Why do you consider the positive validation edges and positive test edges as negative training edges?

val_edges, test_edges, train_edges = pos_edges[:n_val], pos_edges[n_val:n_test + n_val], pos_edges[n_test + n_val:]
val_edges_false, test_edges_false = neg_edges[:n_val], neg_edges[n_val:n_test + n_val]
train_edges_false = np.concatenate([neg_edges, val_edges, test_edges], axis=0)

As shown the code in the above mask_edges function, why do you consider the positive validation edges and positive test edges as the negative training edges? I think it may misunderstand the model training.

ValueError: row index 1708 out of bounds

Hi, I was faced with the problem by running the command "python train.py --task lp --dataset cora --model HGCN --lr 0.01 --dim 16 --num-layers 2 --act relu --bias 1 --dropout 0.5 --weight-decay 0.001 --manifold PoincareBall --log-freq 5 --cuda 0 --c None"

about δ

May I ask how to calculate the structure of a graph δ value?
请问如何计算一个图结构的δ值

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.