{"id":19839806,"url":"https://github.com/qdata/lamp","last_synced_at":"2025-04-13T17:50:45.840Z","repository":{"id":50521569,"uuid":"179750080","full_name":"QData/LaMP","owner":"QData","description":"ECML 2019: Graph Neural Networks for Multi-Label Classification","archived":false,"fork":false,"pushed_at":"2024-07-21T20:28:01.000Z","size":452,"stargazers_count":90,"open_issues_count":3,"forks_count":18,"subscribers_count":5,"default_branch":"master","last_synced_at":"2025-03-27T08:45:19.114Z","etag":null,"topics":["computer-vision","graph-attention-networks","graph-neural-networks","multi-label-classification","nlp","transformers"],"latest_commit_sha":null,"homepage":"https://arxiv.org/pdf/1904.08049.pdf","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/QData.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","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":"2019-04-05T20:28:37.000Z","updated_at":"2024-12-30T03:34:33.000Z","dependencies_parsed_at":"2024-11-12T12:38:32.474Z","dependency_job_id":null,"html_url":"https://github.com/QData/LaMP","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/QData%2FLaMP","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/QData%2FLaMP/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/QData%2FLaMP/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/QData%2FLaMP/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/QData","download_url":"https://codeload.github.com/QData/LaMP/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248758131,"owners_count":21156956,"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":["computer-vision","graph-attention-networks","graph-neural-networks","multi-label-classification","nlp","transformers"],"created_at":"2024-11-12T12:24:25.480Z","updated_at":"2025-04-13T17:50:45.814Z","avatar_url":"https://github.com/QData.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"\u003cimg src=\"LaMP.png\" width=\"47%\" height=\"47%\"\u003e\n\n**Graph Neural Networks for Multi-Label Classification**\u003cbr/\u003e\nJack Lanchantin, Arshdeep Sekhon, Yanjun Qi\u003cbr/\u003e\nECML-PKDD 2019\u003cbr/\u003e\n[[paper]](https://arxiv.org/abs/1904.08049)\n[[slides]](https://jacklanchantin.github.io/documents/LaMP_slides.pdf)\n[[poster]](https://jacklanchantin.github.io/documents/LaMP_poster.pdf)\n\nThis repository contains a PyTorch implementation of LaMP from [Neural Message Passing for Multi-Label Classification\n](https://arxiv.org/abs/1904.08049) (Lanchantin, Sekhon, and Qi 2019)\n\n**Note**: see our updated model (C-Tran) for multi-label image classification at: [github.com/QData/C-Tran](https://github.com/QData/C-Tran)\n\n## Overview\nIn this paper, we propose Label Message Passing (LaMP) Networks to model the joint\nprediction of multiple labels by treating labels as nodes on a graph. \nWe use message passing neural networks (a generalization of graph neural networks) to implicitly model\nthe dependencies between labels conditioned on an input. \n\n## Requirement\n- python 3.4+\n- pytorch 0.2.0\n- tqdm\n- numpy\n\n\n## Usage\n\n### Process The Data\nDownload the data from: [https://www.cs.virginia.edu/yanjun/jack/lamp_datasets.tar.gz](https://www.cs.virginia.edu/yanjun/jack/lamp_datasets.tar.gz) (745M)\n```bash\nwget https://www.cs.virginia.edu/yanjun/jack/lamp_datasets.tar.gz\n```\n\nUntar into the current directory\n```bash\ntar -xvf lamp_datasets.tar.gz -C ./\n```\n\n\u003c!--\n### 1) Preprocess the data for a specific dataset\n```bash\npython preprocess.py -train_src data/reuters/train_inputs.txt -train_tgt data/reuters/train_labels.txt -valid_src data/reuters/valid_inputs.txt -valid_tgt data/reuters/valid_labels.txt -test_src data/reuters/test_inputs.txt -test_tgt data/reuters/test_labels.txt -save_data data/reuters/train_valid_test.pt -max_seq_len 300\n```\n--\u003e\n\nNote: the data directory provided includes preprocessed data. To use your own data, see utils/preprocess.py which includes an example how to run in the comments at the top.\n\n### Train and Test the model (training script contains the validation and testing code)\n```bash\npython main.py -dataset reuters -batch_size 32 -d_model 512 -d_inner_hid 512 -n_layers_enc 2 -n_layers_dec 2 -n_head 4 -epoch 50 -dropout 0.2 -dec_dropout 0.2 -lr 0.0002 -encoder 'graph' -decoder 'graph' -label_mask 'prior'\n```\n\nAll datasets allow for the usage of the graph encoder (`-encoder 'graph'`) except for nuswide_vector, which requires the encoder argument to be set to 'mlp' (`-encoder 'mlp'`), since this is a vector input (see Appendix Table 5 of the paper for all data types). \n\nTo use the fully connected label graph, use `-label_mask none`, and to use the edgeless label graph, use `-label_mask inv_eye`.\n\nThe main.py file evaluates each epoch for all metrics using the default threshold. However, in order to get the final results, you need to find the optimal threshold for each metric on the validation set. We selected from the following thresholds:\n[0.01,0.02,0.03,0.04,0.05,0.06,0.07,0.08,0.09,0.10,0.15,0.20,0.25,0.30,0.35,0.40,0.45,0.50,0.55,0.60,0.65,0.70,0.75,0.8,0.85,0.9,0.95]\n\nFeel free to open an issue with any questions.\n\n## Acknowledgement\nMuch of this code was adapted from https://github.com/jadore801120/attention-is-all-you-need-pytorch\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fqdata%2Flamp","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fqdata%2Flamp","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fqdata%2Flamp/lists"}