{"id":28098867,"url":"https://github.com/rmanluo/gsim","last_synced_at":"2025-09-10T16:45:01.021Z","repository":{"id":241013472,"uuid":"637404233","full_name":"RManLuo/GSim","owner":"RManLuo","description":"Official code implementation of \"GSim: A Graph Neural Network Based Relevance Measure for Heterogeneous Graphs\"","archived":false,"fork":false,"pushed_at":"2023-07-08T09:47:26.000Z","size":27165,"stargazers_count":4,"open_issues_count":0,"forks_count":0,"subscribers_count":3,"default_branch":"master","last_synced_at":"2024-05-22T00:06:30.262Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/RManLuo.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2023-05-07T13:06:54.000Z","updated_at":"2024-05-22T00:06:31.409Z","dependencies_parsed_at":"2024-05-22T00:16:47.381Z","dependency_job_id":null,"html_url":"https://github.com/RManLuo/GSim","commit_stats":null,"previous_names":["rmanluo/gsim"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/RManLuo%2FGSim","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/RManLuo%2FGSim/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/RManLuo%2FGSim/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/RManLuo%2FGSim/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/RManLuo","download_url":"https://codeload.github.com/RManLuo/GSim/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254000046,"owners_count":21997377,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2025-05-13T17:59:03.443Z","updated_at":"2025-05-13T17:59:04.117Z","avatar_url":"https://github.com/RManLuo.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Gsim\n\n----\n\nOfficial code implementation for TKDE paper GSim: A Graph Neural Network Based Relevance Measure for Heterogeneous Graphs\n\n\u003e L. Luo, Y. Fang, M. Lu, X. Cao, X. Zhang and W. Zhang, \"GSim: A Graph Neural Network Based Relevance Measure for Heterogeneous Graphs,\" in IEEE Transactions on Knowledge and Data Engineering, doi: https://doi.org/10.1109/TKDE.2023.3271425.\n\n## Environments\n\npython == 3.6\n\nCPU: I7-8700K \n\nRAM: 64GB\n\nGPU: RTX 3080 \n\nCUDA: 10.1\n\n## Requirements\n\n```bash\ntorch==1.6.0\ntorch-cluster==1.5.7\ntorch-scatter==2.0.5\ntorch-sparse==0.6.7\ntorch-spline-conv==1.2.0\ntorch_geometric==1.6.1\nmatplotlib==2.2.3\nnetworkx==2.4\ndgl==0.4.3.post2\nnumpy==1.16.6\nscipy==1.4.1\nscikit-learn==0.24.2\npyclustering == 0.10.1.2\n```\n\n## Config\n\n```\nvi config.py\n```\nconfig.py example\n\n```python\nimport os\n\nconfig_path = os.path.dirname(__file__)\ndata_config = {\n    'data_path': os.path.join(config_path, 'data'),\n    'dataset': 'DBLP',\n    'data_name': 'DBLP.mat',\n    'primary_type': 'a',\n    'query_type': 'a', # for recall evaluation\n    'return_type': 'a', # for recall evaluation\n    'query_name': '', # for recall evaluation\n    'task': ['CL'],\n    'K_length': 2,\n    'resample': False,\n    'random_seed': 123,\n    'train_val_test_ratio': [0.25, 0.25, 0.5]\n}\n\nmodel_config = {\n    'primary_type': data_config['primary_type'],\n    'auxiliary_embedding': 'linear',  # auxiliary embedding generating method: non_linear, linear, embedding\n    'K_length': data_config['K_length'],\n    'embedding_dim': 128,\n    'in_dim': 128,\n    'out_dim': 128,\n    'num_heads': 2,\n    'merge': 'mean',  # Multi head Attention merge method: linear, mean, stack\n    'g_agg_type': 'mean',  # Graph representation encoder: mean, sum\n    'drop_out': 0.3,\n    'cgnn_non_linear': True,  # Enable non linear activation function for CGNN\n    'multi_attn_linear': False,  # Enable atten K/Q-linear for each type\n    'graph_attention': True,\n    'kq_linear_out_dim': 128,\n    'path_attention': False,  # Enable Context path attention\n    'c_linear_out_dim': 8,\n    'enable_bilinear': False,  # Enable Bilinear for context attention\n    'enable_relational_passing': True,  # Enable Relational Message Passing\n    'gru': True,\n    'add_init': False,\n    'max_norm': 2,  # Renorm, 0 for disable.\n}\n\ntrain_config = {\n    'continue': False,\n    'evaluate_every': -1,\n    'beta': 1,\n    'sup_weight': 1,\n    'unsup_weight': 1,\n    'lr': 0.001,\n    'l2': 0.1,\n    'factor': 0.2,\n    'total_epoch': 10000000,\n    'batch_size': 1024 * 20,\n    'pos_num_for_each_hop': [20, 20, 20, 20, 20, 20, 20, 20, 20],\n    'neg_num_for_each_hop': -1,\n    'sample_workers': 8,\n    'patience': 100,\n    'checkpoint_path': os.path.join(config_path, 'checkpoint', data_config['dataset'])\n}\n\nevaluate_config = {\n    'method': 'SpectralClustering',  # 'kmeans', 'kmedoids', 'AgglomerativeClustering', 'SpectralClustering'\n    'use_sim_matrix': True,\n    'save_heat_map': False,\n    'result_path': os.path.join('result', data_config['dataset']),\n    'random_state': 123,\n    'max_iter': 500,\n    'n_jobs': 1,\n    'n_time': 100,\n    'eval_time': 50,\n    'K': 10 # number of results for recall exp.\n}\n```\n\n## Train and Evaluate\n``` bash\npython3 main.py\n```\n\n## BibTex\n```tex\n@ARTICLE{10111040,\n  author={Luo, Linhao and Fang, Yixiang and Lu, Moli and Cao, Xin and Zhang, Xiaofeng and Zhang, Wenjie},\n  journal={IEEE Transactions on Knowledge and Data Engineering}, \n  title={GSim: A Graph Neural Network Based Relevance Measure for Heterogeneous Graphs}, \n  year={2023},\n  volume={},\n  number={},\n  pages={1-14},\n  doi={10.1109/TKDE.2023.3271425}}\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frmanluo%2Fgsim","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Frmanluo%2Fgsim","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frmanluo%2Fgsim/lists"}