GithubHelp home page GithubHelp logo

Bugs of subgraph augmentation about graphcl HOT 4 CLOSED

shen-lab avatar shen-lab commented on July 24, 2024 1
Bugs of subgraph augmentation

from graphcl.

Comments (4)

hyp1231 avatar hyp1231 commented on July 24, 2024 1

Thanks, it's clear and makes sense. Feel free to close this issue. Thank you again.

from graphcl.

yyou1996 avatar yyou1996 commented on July 24, 2024

@hyp1231 Thank you for your carefulness! You are right that the current version only contrasting with small one-hop subgraphs (similar to InfoGraph, global-local contasting), due to my typo. In my later version of the my internal code (will be released in the future), I fixed this bug (simply let idx_neigh=idx_neigh.union...) and found that it did not have much influence on performance. Thus, for reproduce purpose it is suggested to stick to the current shape, but for development it is better to fix it.

A sample of the improved subgraph function:

import torch_geometric.utils as tg_utils

def subgraph(data, aug_ratio):
    G = tg_utils.to_networkx(data)

    node_num, _ = data.x.size()
    _, edge_num = data.edge_index.size()
    sub_num = int(node_num * (1-aug_ratio))

    idx_sub = [np.random.randint(node_num, size=1)[0]]
    idx_neigh = set([n for n in G.neighbors(idx_sub[-1])])

    while len(idx_sub) <= sub_num:
        if len(idx_neigh) == 0:
            idx_unsub = list(set([n for n in range(node_num)]).difference(set(idx_sub)))
            idx_neigh = set([np.random.choice(idx_unsub)])
        sample_node = np.random.choice(list(idx_neigh))

        idx_sub.append(sample_node)
        idx_neigh = idx_neigh.union(set([n for n in G.neighbors(idx_sub[-1])])).difference(set(idx_sub))

    idx_nondrop = idx_sub
    idx_nondrop.sort()

    edge_index, _ = tg_utils.subgraph(idx_nondrop, data.edge_index, relabel_nodes=True, num_nodes=node_num)

    data.x = data.x[idx_nondrop]
    data.edge_index = edge_index
    data.__num_nodes__, _ = data.x.shape
    return data

from graphcl.

hyp1231 avatar hyp1231 commented on July 24, 2024

@yyou1996 Thanks for your kind and quick response!

BTW, another concern is, whether controling the scale of subgraph has a slight influence to the performance. In the original version of the released code, we have sub_num = int(node_num * aug_ratio) (which is more similar to the original one-hop InfoGraph), while in the sample code just pasted, we have sub_num = int(node_num * (1-aug_ratio)) instead.

def subgraph(data, aug_ratio):
node_num, _ = data.x.size()
_, edge_num = data.edge_index.size()
sub_num = int(node_num * aug_ratio)

from graphcl.

yyou1996 avatar yyou1996 commented on July 24, 2024

According to my limited observation, I dont feel it affects too much on performance, compared with the augmentation type. Of course, we did not do explicit ablation on the augmentation strength. I feel type of aug represents more of the prior, rather than strength. Also, I am happy to hear some other opinions.

from graphcl.

Related Issues (20)

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.