Git Product home page Git Product logo

himp-gnn's Introduction

Hierarchical Inter-Message Passing for Learning on Molecular Graphs


This is a PyTorch implementation of Hierarchical Inter-Message Passing for Learning on Molecular Graphs, as described in our paper:

Matthias Fey, Jan-Gin Yuen, Frank Weichert: Hierarchical Inter-Message Passing for Learning on Molecular Graphs (GRL+ 2020)

Requirements

Experiments

Experiments can be run via:

$ python train_zinc_subset.py
$ python train_zinc_full.py
$ python train_hiv.py
$ python train_muv.py
$ python train_tox21.py
$ python train_ogbhiv.py
$ python train_ogbpcba.py

Cite

Please cite our paper if you use this code in your own work:

@inproceedings{Fey/etal/2020,
  title={Hierarchical Inter-Message Passing for Learning on Molecular Graphs},
  author={Fey, M. and Yuen, J. G. and Weichert, F.},
  booktitle={ICML Graph Representation Learning and Beyond (GRL+) Workhop},
  year={2020},
}

himp-gnn's People

Contributors

rusty1s 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

Watchers

 avatar  avatar  avatar  avatar  avatar

himp-gnn's Issues

multitask issue

Using PyG 1.5.0 or 1.6.1

got this error during python run:

Traceback (most recent call last):
File "train_tox21.py", line 113, in
if val_perf > best_val_perf:
TypeError: '>' not supported between instances of 'dict' and 'int'

same for Hiv:

Traceback (most recent call last):
File "train_hiv.py", line 113, in
if val_perf > best_val_perf:
TypeError: '>' not supported between instances of 'dict' and 'int'

RuntimeError: Expected object of scalar type long int but got scalar type float for sequence element 55970.

Hi,

Thanks for the awesome work! When I ran python train_ogbpcba.py

I got the following error:

Namespace(device=0, dropout=0.25, epochs=150, hidden_channels=300, no_inter_message_passing=False, num_layers=3)
Downloading https://snap.stanford.edu/ogb/data/graphproppred/csv_mol_download/pcba.zip
Downloaded 0.04 GB: 100%|███████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████| 39/39 [00:02<00:00, 14.08it/s]
Extracting data/pcba.zip
Processing...
Loading necessary files...
This might take a while.
Processing graphs...
100%|███████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████| 437929/437929 [00:02<00:00, 148731.74it/s]
Converting graphs into PyG objects...
100%|███████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████| 437929/437929 [00:02<00:00, 148342.39it/s]
Traceback (most recent call last):
File "train_ogbpcba.py", line 36, in
dataset = PygGraphPropPredDataset(name, 'data', pre_transform=transform)
File "/home/muhan/anaconda3/envs/seal/lib/python3.8/site-packages/ogb/graphproppred/dataset_pyg.py", line 43, in init
super(PygGraphPropPredDataset, self).init(self.root, transform, pre_transform)
File "/home/muhan/anaconda3/envs/seal/lib/python3.8/site-packages/torch_geometric/data/in_memory_dataset.py", line 53, in init
super(InMemoryDataset, self).init(root, transform, pre_transform,
File "/home/muhan/anaconda3/envs/seal/lib/python3.8/site-packages/torch_geometric/data/dataset.py", line 93, in init
self._process()
File "/home/muhan/anaconda3/envs/seal/lib/python3.8/site-packages/torch_geometric/data/dataset.py", line 166, in _process
self.process()
File "/home/muhan/anaconda3/envs/seal/lib/python3.8/site-packages/ogb/graphproppred/dataset_pyg.py", line 130, in process
data, slices = self.collate(data_list)
File "/home/muhan/anaconda3/envs/seal/lib/python3.8/site-packages/torch_geometric/data/in_memory_dataset.py", line 115, in collate
data[key] = torch.cat(data[key],
RuntimeError: Expected object of scalar type long int but got scalar type float for sequence element 55970.

Could you have a look? I am using torch-geometric 1.5.0, pytorch 1.5.1 and ogb 1.2.1.

TypeError: __inc__() takes 3 positional arguments but 4 were given

Hi,

When I am running train_tox21.py, it shows TypeError: inc() takes 3 positional arguments but 4 were given.
Could you help me with this?

Traceback (most recent call last):
File "/home/znyu/projects/Explainer/train_himp.py", line 109, in
loss = train(epoch)
File "/home/znyu/projects/Explainer/train_himp.py", line 60, in train
for data in train_loader:
File "/home/znyu/anaconda3/envs/pyg202/lib/python3.9/site-packages/torch/utils/data/dataloader.py", line 521, in next
data = self._next_data()
File "/home/znyu/anaconda3/envs/pyg202/lib/python3.9/site-packages/torch/utils/data/dataloader.py", line 561, in _next_data
data = self._dataset_fetcher.fetch(index) # may raise StopIteration
File "/home/znyu/anaconda3/envs/pyg202/lib/python3.9/site-packages/torch/utils/data/_utils/fetch.py", line 52, in fetch
return self.collate_fn(data)
File "/home/znyu/anaconda3/envs/pyg202/lib/python3.9/site-packages/torch_geometric/loader/dataloader.py", line 39, in call
return self.collate(batch)
File "/home/znyu/anaconda3/envs/pyg202/lib/python3.9/site-packages/torch_geometric/loader/dataloader.py", line 19, in collate
return Batch.from_data_list(batch, self.follow_batch,
File "/home/znyu/anaconda3/envs/pyg202/lib/python3.9/site-packages/torch_geometric/data/batch.py", line 69, in from_data_list
batch, slice_dict, inc_dict = collate(
File "/home/znyu/anaconda3/envs/pyg202/lib/python3.9/site-packages/torch_geometric/data/collate.py", line 85, in collate
value, slices, incs = _collate(attr, values, data_list, stores,
File "/home/znyu/anaconda3/envs/pyg202/lib/python3.9/site-packages/torch_geometric/data/collate.py", line 156, in _collate
incs = get_incs(key, values, data_list, stores)
File "/home/znyu/anaconda3/envs/pyg202/lib/python3.9/site-packages/torch_geometric/data/collate.py", line 207, in get_incs
repeats = [
File "/home/znyu/anaconda3/envs/pyg202/lib/python3.9/site-packages/torch_geometric/data/collate.py", line 208, in
data.inc(key, value, store)
TypeError: inc() takes 3 positional arguments but 4 were given

Linear activation function interaction with ROC_AUC metric

I see in the tox21 example , the evaluation metric is the roc_auc_score on the multilabel binary classification task. However, the final activation function in the model is linear. Does this output interact well with the roc_auc_score? I believe the sklearn implementation of the metric expects an array of shape (n_samples, n_classes) where the values in the array correspond to probability estimates for the labels in each class. As I understand, the current output of the model does not correspond to a probability estimate (linear activation), so does this pose an issue for getting the correct roc_auc value? Would a better implementation be with a sigmoid activation function at the output layer?
Thanks

Not really an issue, but a question about your GINEConv

himp-gnn/model.py

Lines 138 to 141 in 0a506bb

x = self.atom_convs[i](x, data.edge_index, edge_attr)
x = self.atom_batch_norms[i](x)
x = F.relu(x)
x = F.dropout(x, self.dropout, training=self.training)

Is there a reason why your last three lines haven't just been added to your nn in self.atom_convs[i]? It seems like it's basically continuing a sequence that we could have wrapped up in the original nn. Please let me know if I'm missing something.

train_muv.py has a TypeError

Hi,
Here is the output:
Traceback (most recent call last):
File "train_muv.py", line 113, in
if val_perf > best_val_perf:
TypeError: '>' not supported between instances of 'dict' and 'int'

and the bug looks like from this line:

return {"rocauc": sum(rocauc_list) / len(rocauc_list)}

Getting RuntimeError

When I try to reproduce experiments as stated, I invariably get an error:

RuntimeError: received 0 items of ancdata

The error is somewhat erratic, e.g. in train_zinc_subset.py I get it after 15 to 50 epoch in the first run. It seems to have to do with some kind of memory of other saturation I cannot detect.
Other examples in Python Geometric work just fine, so I think it is something specific to the code in himp-gnn.
I am using Python 3.6.9 under WSL2 Ubuntu 18.04.

AttributeError: 'Batch' object has no attribute 'x_clique'

Hello Matthias,

I was trying to run the command python train_ogbhiv.py, but yield the error below.

Traceback (most recent call last):
  File "himp-molhiv.py", line 96, in <module>
    loss = train(epoch)
  File "himp-molhiv.py", line 61, in train
    out = model(data)
  File "/cmlscratch/kong/anaconda3/envs/graph/lib/python3.8/site-packages/torch/nn/modules/module.py", line 550, in __call__
    result = self.forward(*input, **kwargs)
  File "/nfshomes/kong/projects/ogb/examples/graphproppred/mol/himp-molhiv/model.py", line 134, in forward
    x_clique = self.clique_encoder(data.x_clique.squeeze())
AttributeError: 'Batch' object has no attribute 'x_clique'

Would you please have a look?

BTW I'm using PyG==1.6.1, OGB==1.2.3

Order of Inter-Message Passing?

What are the order of the coarse-to-fine information flow and the fine-to-coarse information flow?
Which information flow is put ahead of another ?

RunetimeError: Boolean value of Tensor with more than one value is ambiguous

I am on recent pytorch, so this is kind of to be expected, but just a heads up.

Versions:

dependencies:
  - pytorch=1.6.0=py3.7_cuda10.1.243_cudnn7.6.3_0
pip:
    - torch-cluster==1.5.6
    - torch-geometric==1.6.0
    - torch-scatter==2.0.5
    - torch-sparse==0.6.6
    - torch-spline-conv==1.2.0

Error:

Traceback (most recent call last):
  File "train_ogbhiv.py", line 96, in <module>
    loss = train(epoch)
  File "train_ogbhiv.py", line 58, in train
    for data in train_loader:
  File "/home/sooheon_k_gmail_com/anaconda3/envs/dl/lib/python3.7/site-packages/torch/utils/data/dataloader.py", line 363, in __next__
    data = self._next_data()
  File "/home/sooheon_k_gmail_com/anaconda3/envs/dl/lib/python3.7/site-packages/torch/utils/data/dataloader.py", line 989, in _next_data
    return self._process_data(data)
  File "/home/sooheon_k_gmail_com/anaconda3/envs/dl/lib/python3.7/site-packages/torch/utils/data/dataloader.py", line 1014, in _process_data
    data.reraise()
  File "/home/sooheon_k_gmail_com/anaconda3/envs/dl/lib/python3.7/site-packages/torch/_utils.py", line 395, in reraise
    raise self.exc_type(msg)
RuntimeError: Caught RuntimeError in DataLoader worker process 0.
Original Traceback (most recent call last):
  File "/home/sooheon_k_gmail_com/anaconda3/envs/dl/lib/python3.7/site-packages/torch/utils/data/_utils/worker.py", line 185, in _worker_loop
    data = fetcher.fetch(index)
  File "/home/sooheon_k_gmail_com/anaconda3/envs/dl/lib/python3.7/site-packages/torch/utils/data/_utils/fetch.py", line 47, in fetch
    return self.collate_fn(data)
  File "/home/sooheon_k_gmail_com/anaconda3/envs/dl/lib/python3.7/site-packages/torch_geometric/data/dataloader.py", line 34, in __call__
    return self.collate(batch)
  File "/home/sooheon_k_gmail_com/anaconda3/envs/dl/lib/python3.7/site-packages/torch_geometric/data/dataloader.py", line 15, in collate
    return Batch.from_data_list(batch, self.follow_batch)
  File "/home/sooheon_k_gmail_com/anaconda3/envs/dl/lib/python3.7/site-packages/torch_geometric/data/batch.py", line 53, in from_data_list
    item = item + cum if cum != 0 else item
RuntimeError: Boolean value of Tensor with more than one value is ambiguous

DataLoader error

Hi Matthias,

Thanks for providing the implementation to your interesting paper. I've tried running the train_ogbhiv.py script but I'm encountering an error.

This is the output of python train_ogbhiv.py:

Namespace(device=0, dropout=0.5, epochs=50, hidden_channels=64, no_inter_message_passing=False, num_layers=2)

Run 1:

Traceback (most recent call last):
  File "train_ogbhiv.py", line 96, in <module>
    loss = train(epoch)
  File "train_ogbhiv.py", line 58, in train
    for data in train_loader:
  File "/nfs/staff-ssd/zuegnerd/miniconda3/envs/torch/lib/python3.8/site-packages/torch/utils/data/dataloader.py", line 345, in __next__
    data = self._next_data()
  File "/nfs/staff-ssd/zuegnerd/miniconda3/envs/torch/lib/python3.8/site-packages/torch/utils/data/dataloader.py", line 856, in _next_data
    return self._process_data(data)
  File "/nfs/staff-ssd/zuegnerd/miniconda3/envs/torch/lib/python3.8/site-packages/torch/utils/data/dataloader.py", line 881, in _process_data
    data.reraise()
  File "/nfs/staff-ssd/zuegnerd/miniconda3/envs/torch/lib/python3.8/site-packages/torch/_utils.py", line 394, in reraise
    raise self.exc_type(msg)
RuntimeError: Caught RuntimeError in DataLoader worker process 0.
Original Traceback (most recent call last):
  File "/nfs/staff-ssd/zuegnerd/miniconda3/envs/torch/lib/python3.8/site-packages/torch/utils/data/_utils/worker.py", line 178, in _worker_loop
    data = fetcher.fetch(index)
  File "/nfs/staff-ssd/zuegnerd/miniconda3/envs/torch/lib/python3.8/site-packages/torch/utils/data/_utils/fetch.py", line 47, in fetch
    return self.collate_fn(data)
  File "/nfs/staff-ssd/zuegnerd/miniconda3/envs/torch/lib/python3.8/site-packages/torch_geometric/data/dataloader.py", line 34, in __call__
    return self.collate(batch)
  File "/nfs/staff-ssd/zuegnerd/miniconda3/envs/torch/lib/python3.8/site-packages/torch_geometric/data/dataloader.py", line 15, in collate
    return Batch.from_data_list(batch, self.follow_batch)
  File "/nfs/staff-ssd/zuegnerd/miniconda3/envs/torch/lib/python3.8/site-packages/torch_geometric/data/batch.py", line 53, in from_data_list
    item = item + cum if cum != 0 else item
RuntimeError: bool value of Tensor with more than one value is ambiguous

Versions installed:
torch_geometric==1.6.0
torch==1.4.0
ogb==1.2.1

Do you have an idea what's going on and how to fix it?

Thanks again!

Daniel

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.