snap-stanford / neural-subgraph-learning-GNN

329 stars 64 forks source link

Augment dim error #12

Closed WxxShirley closed 3 years ago

WxxShirley commented 3 years ago

Hi, thanks for your work on neural subgraph match. It runs quite well on my dataset.

However, I wanted to fix the augmentation step in ./common/feature_preprocess.py . In detail, add features such as degree, clustering_coefficient, etc. How to correctly implement the FEATURE_AUGMENT and FEATURE_AUGMENT_DIMS?

Auctally, I set FEATURE_AUGMENT as ['degree','betweenness_centrality'] and set FEATURE_AUGMENT_DIMS as [1,1], it encounters error ......

qema commented 3 years ago

So sorry for the late response. Great to hear the method works on your dataset!

The FEATURE_AUGMENT and FEATURE_AUGMENT_DIMS look good to me (although to be sure, degree should instead be node_degree? Also, it may be necessary to use higher values for the degree feature, as the degree is encoded via a one-hot encoding).

Additionally, to add new features, it is necessary to register the features: see the line at https://github.com/snap-stanford/neural-subgraph-learning-GNN/blob/d6ad4da188b52c97ff5f798996cd5e22e1c5f093/common/feature_preprocess.py#L136. The functions above that line give examples for other features, where each function actually creates the feature by creating a new property graph.[feature_name] which is a tensor of features, one row per node in the graph.

WxxShirley commented 3 years ago

oh, that's just a spelling error😅

If I set:

FEATURE_AUGMENT = ["node_degree", "node_clustering_coefficient"]
FEATURE_AUGMENT_DIMS = [1, 1]

there will be error like this:

Training:   0%|          | 0/100 [00:00<?, ?it/s]Process Process-3:
Process Process-1:
Process Process-2:
Traceback (most recent call last):
Traceback (most recent call last):
·······
  File "/Users/xxwu/Downloads/subgraph/common/models.py", line 170, in forward
    x = self.pre_mp(x)
  File "/opt/anaconda3/lib/python3.8/site-packages/torch/nn/modules/module.py", line 727, in _call_impl
    result = self.forward(*input, **kwargs)
  File "/opt/anaconda3/lib/python3.8/site-packages/torch/nn/modules/container.py", line 117, in forward
    input = module(input)
  File "/opt/anaconda3/lib/python3.8/site-packages/torch/nn/modules/module.py", line 727, in _call_impl
    result = self.forward(*input, **kwargs)
  File "/opt/anaconda3/lib/python3.8/site-packages/torch/nn/modules/linear.py", line 93, in forward
    return F.linear(input, self.weight, self.bias)
  File "/opt/anaconda3/lib/python3.8/site-packages/torch/nn/functional.py", line 1690, in linear
    ret = torch.addmm(bias, input, weight.t())
RuntimeError: mat1 and mat2 shapes cannot be multiplied (527x2 and 3x64)
qema commented 3 years ago

Hmm interesting. It's possible there's an edge case with degree=1, does it work if you set the corresponding dimension to a higher value? Does it work with just one feature but not the other? Also how are you creating the data (which data source class are you using)? Will run some tests on my end tomorrow. Thanks!

On Mar 23, 2021, at 04:16, Xixi Wu @.***> wrote:  oh, that's just a spelling error😅

If I set:

FEATURE_AUGMENT = ["node_degree", "node_clustering_coefficient"] FEATURE_AUGMENT_DIMS = [1, 1] there will be error like this:

Training: 0%| | 0/100 [00:00<?, ?it/s]Process Process-3: Process Process-1: Process Process-2: Traceback (most recent call last): Traceback (most recent call last): ······· File "/Users/xxwu/Downloads/subgraph/common/models.py", line 170, in forward x = self.pre_mp(x) File "/opt/anaconda3/lib/python3.8/site-packages/torch/nn/modules/module.py", line 727, in _call_impl result = self.forward(*input, *kwargs) File "/opt/anaconda3/lib/python3.8/site-packages/torch/nn/modules/container.py", line 117, in forward input = module(input) File "/opt/anaconda3/lib/python3.8/site-packages/torch/nn/modules/module.py", line 727, in _call_impl result = self.forward(input, **kwargs) File "/opt/anaconda3/lib/python3.8/site-packages/torch/nn/modules/linear.py", line 93, in forward return F.linear(input, self.weight, self.bias) File "/opt/anaconda3/lib/python3.8/site-packages/torch/nn/functional.py", line 1690, in linear ret = torch.addmm(bias, input, weight.t()) RuntimeError: mat1 and mat2 shapes cannot be multiplied (527x2 and 3x64) — You are receiving this because you commented. Reply to this email directly, view it on GitHub, or unsubscribe.

WxxShirley commented 3 years ago