{"about":{"site":"https://codewithpapers.app","non_affiliation":"Code with Papers and Syntology are not affiliated with, endorsed by, or sponsored by Papers with Code, Meta, or the pwc-archive mirror.","licence":"CC BY-SA 4.0","licence_url":"https://creativecommons.org/licenses/by-sa/4.0/legalcode","attribution":"https://codewithpapers.app/attribution","modified":"archive material modified by Syntology; see the attribution page"},"url":"/paper/sizeshiftreg-a-regularization-method-for","title":"SizeShiftReg: a Regularization Method for Improving Size-Generalization in Graph Neural Networks","arxiv_id":"2207.07888","date":"2022-07-16","proceeding":null,"authors":["Davide Buffelli","Pietro Liò","Fabio Vandin"],"abstract":"In the past few years, graph neural networks (GNNs) have become the de facto model of choice for graph classification. While, from the theoretical viewpoint, most GNNs can operate on graphs of any size, it is empirically observed that their classification performance degrades when they are applied on graphs with sizes that differ from those in the training data. Previous works have tried to tackle this issue in graph classification by providing the model with inductive biases derived from assumptions on the generative process of the graphs, or by requiring access to graphs from the test domain. The first strategy is tied to the quality of the assumptions made for the generative process, and requires the use of specific models designed after the explicit definition of the generative process of the data, leaving open the question of how to improve the performance of generic GNN models in general settings. On the other hand, the second strategy can be applied to any GNN, but requires access to information that is not always easy to obtain. In this work we consider the scenario in which we only have access to the training data, and we propose a regularization strategy that can be applied to any GNN to improve its generalization capabilities from smaller to larger graphs without requiring access to the test data. Our regularization is based on the idea of simulating a shift in the size of the training graphs using coarsening techniques, and enforcing the model to be robust to such a shift. Experimental results on standard datasets show that popular GNN models, trained on the 50% smallest graphs in the dataset and tested on the 10% largest graphs, obtain performance improvements of up to 30% when trained with our regularization strategy.","url_abs":"https://arxiv.org/abs/2207.07888v2","url_pdf":"https://arxiv.org/pdf/2207.07888v2.pdf","source":{"archive":"pwc-archive (Hugging Face), CC BY-SA 4.0","snapshot":"2025-07-28","licence_url":"https://creativecommons.org/licenses/by-sa/4.0/legalcode","row_kind":"abstracts"},"code_links":[{"paper_slug":"sizeshiftreg-a-regularization-method-for","repo_url":"https://github.com/DavideBuffelli/SizeShiftReg","is_official":1,"mentioned_in_paper":1,"mentioned_in_github":0,"framework":"pytorch","reach":{"status":"ok","spdx":"MIT"}}],"tasks":[{"task_slug":"graph-classification","task_name":"Graph Classification"}],"methods":[{"method_slug":"test","method_name":"Test"}],"datasets_introduced":[],"methods_introduced":[],"results":[],"syntology":{"atlas_url":"https://app.syntology.ai/?focus=2207.07888","mcp":{"get_harvested_code_for_paper":{"arxiv_id":"2207.07888"}},"developers":"https://syntology.ai/developers","read_at":"2026-09-24T18:15:14+00:00","read_at_is":"when the build read Syntology's graph, not when any sample ran","claim":"Per-sample execution status on synthesized fixtures; not a correctness claim about the paper. Samples come from repositories linked to the paper, official or community; repo_kind says which.","repos":[{"provenance":"external:paperswithcode_snapshot_2025-07-28","url":"https://github.com/DavideBuffelli/SizeShiftReg","reach":{"status":"ok","spdx":"MIT"}}],"summary":{"unverified":14},"by_repo_kind":{"official":{"samples":14,"ran":0,"repositories":1}},"repo_kind_vocabulary":{"official":"The archive marks this repository official for the paper","named_in_paper":"The archive records that the paper mentions this repository; it is not marked official","listed":"In the archive's code links for this paper, not marked official and not recorded as mentioned in the paper","found_in_text":"Syntology found this repository in the paper's own text; whether it is the authors' implementation is not asserted","community":"Not in the archive's code links for this paper; a community repository Syntology harvested"},"n_pointer_only_for_licence":0,"samples":[{"code_sha256_prefix":"d1969d403abd4c25","entry":"NMI","repo":"DavideBuffelli/SizeShiftReg","repo_kind":"official","path":"lib/spectralcoarsening/measure.py","file_url":"https://github.com/DavideBuffelli/SizeShiftReg/blob/HEAD/lib/spectralcoarsening/measure.py","link_basis":"harvester_set","language":"python","status":"unverified","verification_level":0,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"MIT","inline_ok":true,"mcp_get_code":{"code_sha256":"d1969d403abd4c25"}},{"code_sha256_prefix":"c58bcdcfacb955cf","entry":"build_mlp","repo":"DavideBuffelli/SizeShiftReg","repo_kind":"official","path":"lib/models.py","file_url":"https://github.com/DavideBuffelli/SizeShiftReg/blob/HEAD/lib/models.py","link_basis":"harvester_set","language":"python","status":"unverified","verification_level":0,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"MIT","inline_ok":true,"mcp_get_code":{"code_sha256":"c58bcdcfacb955cf"}},{"code_sha256_prefix":"397dd927942e5077","entry":"compute_deg_hist","repo":"DavideBuffelli/SizeShiftReg","repo_kind":"official","path":"lightning_modules.py","file_url":"https://github.com/DavideBuffelli/SizeShiftReg/blob/HEAD/lightning_modules.py","link_basis":"harvester_set","language":"python","status":"unverified","verification_level":0,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"MIT","inline_ok":true,"mcp_get_code":{"code_sha256":"397dd927942e5077"}},{"code_sha256_prefix":"bc4f109b9a9d0897","entry":"cosine_distance","repo":"DavideBuffelli/SizeShiftReg","repo_kind":"official","path":"lib/spectralcoarsening/measure.py","file_url":"https://github.com/DavideBuffelli/SizeShiftReg/blob/HEAD/lib/spectralcoarsening/measure.py","link_basis":"harvester_set","language":"python","status":"unverified","verification_level":0,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"MIT","inline_ok":true,"mcp_get_code":{"code_sha256":"bc4f109b9a9d0897"}},{"code_sha256_prefix":"0d99791d10f56d2a","entry":"get_batch_coarse_ratios","repo":"DavideBuffelli/SizeShiftReg","repo_kind":"official","path":"lib/coarsening_utils.py","file_url":"https://github.com/DavideBuffelli/SizeShiftReg/blob/HEAD/lib/coarsening_utils.py","link_basis":"harvester_set","language":"python","status":"unverified","verification_level":0,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"MIT","inline_ok":true,"mcp_get_code":{"code_sha256":"0d99791d10f56d2a"}},{"code_sha256_prefix":"a549b167e11bdf64","entry":"get_batch_num_coarse_nodes","repo":"DavideBuffelli/SizeShiftReg","repo_kind":"official","path":"lib/coarsening_utils.py","file_url":"https://github.com/DavideBuffelli/SizeShiftReg/blob/HEAD/lib/coarsening_utils.py","link_basis":"harvester_set","language":"python","status":"unverified","verification_level":0,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"MIT","inline_ok":true,"mcp_get_code":{"code_sha256":"a549b167e11bdf64"}},{"code_sha256_prefix":"9d9def7109076311","entry":"get_induced","repo":"DavideBuffelli/SizeShiftReg","repo_kind":"official","path":"lib/run_escape.py","file_url":"https://github.com/DavideBuffelli/SizeShiftReg/blob/HEAD/lib/run_escape.py","link_basis":"harvester_set","language":"python","status":"unverified","verification_level":0,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"MIT","inline_ok":true,"mcp_get_code":{"code_sha256":"9d9def7109076311"}},{"code_sha256_prefix":"5cd8693437b867bc","entry":"l2diff","repo":"DavideBuffelli/SizeShiftReg","repo_kind":"official","path":"losses.py","file_url":"https://github.com/DavideBuffelli/SizeShiftReg/blob/HEAD/losses.py","link_basis":"harvester_set","language":"python","status":"unverified","verification_level":0,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"MIT","inline_ok":true,"mcp_get_code":{"code_sha256":"5cd8693437b867bc"}},{"code_sha256_prefix":"d524f08b3c8216c1","entry":"normalizeLaplacian","repo":"DavideBuffelli/SizeShiftReg","repo_kind":"official","path":"lib/spectralcoarsening/laplacian.py","file_url":"https://github.com/DavideBuffelli/SizeShiftReg/blob/HEAD/lib/spectralcoarsening/laplacian.py","link_basis":"harvester_set","language":"python","status":"unverified","verification_level":0,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"MIT","inline_ok":true,"mcp_get_code":{"code_sha256":"d524f08b3c8216c1"}},{"code_sha256_prefix":"4194a9ca7b6a070a","entry":"normalized_L1","repo":"DavideBuffelli/SizeShiftReg","repo_kind":"official","path":"lib/spectralcoarsening/measure.py","file_url":"https://github.com/DavideBuffelli/SizeShiftReg/blob/HEAD/lib/spectralcoarsening/measure.py","link_basis":"harvester_set","language":"python","status":"unverified","verification_level":0,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"MIT","inline_ok":true,"mcp_get_code":{"code_sha256":"4194a9ca7b6a070a"}},{"code_sha256_prefix":"dbba509e5ffbbcc0","entry":"regular_partition","repo":"DavideBuffelli/SizeShiftReg","repo_kind":"official","path":"lib/spectralcoarsening/coarsening.py","file_url":"https://github.com/DavideBuffelli/SizeShiftReg/blob/HEAD/lib/spectralcoarsening/coarsening.py","link_basis":"harvester_set","language":"python","status":"unverified","verification_level":0,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"MIT","inline_ok":true,"mcp_get_code":{"code_sha256":"dbba509e5ffbbcc0"}},{"code_sha256_prefix":"8e93224440d8475a","entry":"spectraLaplacian","repo":"DavideBuffelli/SizeShiftReg","repo_kind":"official","path":"lib/spectralcoarsening/laplacian.py","file_url":"https://github.com/DavideBuffelli/SizeShiftReg/blob/HEAD/lib/spectralcoarsening/laplacian.py","link_basis":"harvester_set","language":"python","status":"unverified","verification_level":0,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"MIT","inline_ok":true,"mcp_get_code":{"code_sha256":"8e93224440d8475a"}},{"code_sha256_prefix":"2e4e27a20ff75a66","entry":"spectraLaplacian_two_end_n","repo":"DavideBuffelli/SizeShiftReg","repo_kind":"official","path":"lib/spectralcoarsening/laplacian.py","file_url":"https://github.com/DavideBuffelli/SizeShiftReg/blob/HEAD/lib/spectralcoarsening/laplacian.py","link_basis":"harvester_set","language":"python","status":"unverified","verification_level":0,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"MIT","inline_ok":true,"mcp_get_code":{"code_sha256":"2e4e27a20ff75a66"}},{"code_sha256_prefix":"32c5157cc6e049fe","entry":"stratified_ksplit","repo":"DavideBuffelli/SizeShiftReg","repo_kind":"official","path":"lib/data.py","file_url":"https://github.com/DavideBuffelli/SizeShiftReg/blob/HEAD/lib/data.py","link_basis":"harvester_set","language":"python","status":"unverified","verification_level":0,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"MIT","inline_ok":true,"mcp_get_code":{"code_sha256":"32c5157cc6e049fe"}}]},"arxiv_metadata":null,"syntology_extracted_results":null}