{"id":19382856,"url":"https://github.com/locuslab/lml","last_synced_at":"2025-05-08T04:19:45.119Z","repository":{"id":96318680,"uuid":"165112034","full_name":"locuslab/lml","owner":"locuslab","description":"The Limited Multi-Label Projection Layer","archived":false,"fork":false,"pushed_at":"2024-07-25T10:12:35.000Z","size":761,"stargazers_count":58,"open_issues_count":1,"forks_count":6,"subscribers_count":7,"default_branch":"master","last_synced_at":"2025-03-31T17:07:10.830Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"https://arxiv.org/abs/1906.08707","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/locuslab.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.mit","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-01-10T18:39:45.000Z","updated_at":"2024-12-26T06:18:16.000Z","dependencies_parsed_at":"2023-03-30T20:48:06.023Z","dependency_job_id":null,"html_url":"https://github.com/locuslab/lml","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/locuslab%2Flml","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/locuslab%2Flml/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/locuslab%2Flml/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/locuslab%2Flml/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/locuslab","download_url":"https://codeload.github.com/locuslab/lml/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":252996991,"owners_count":21837746,"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":"2024-11-10T09:23:37.014Z","updated_at":"2025-05-08T04:19:45.093Z","avatar_url":"https://github.com/locuslab.png","language":"Python","readme":"# The Limited Multi-Label Projection Layer\n\nThis repository is by\n[Brandon Amos](http://bamos.github.io),\n[Vladlen Koltun](http://vladlen.info/),\nand\n[J. Zico Kolter](http://zicokolter.com/) and\ncontains the PyTorch library and source code to reproduce the\nexperiments in our tech report on\n[The Limited Multi-Label Projection Layer](https://arxiv.org/abs/1906.08707).\n\n![](./images/polytope.png)\n![](./images/lml.png)\n\n---\n\nWe provide the LML layer as a PyTorch module in `lml.py`.\nYou can install it with:\n\n```\npip install git+git://github.com/locuslab/lml.git\n```\n\nA simple usage example to project a 5-dimensional vector\nonto the LML polytope with two active elements is:\n\n```python\nimport torch\nfrom lml import LML\n\nx = 10.*torch.randn(5) # tensor([ -4.0695,  10.8666,  13.0867,  -7.1431, -14.7220])\ny = LML(N=2)(x) # tensor([5.8745e-04, 9.9945e-01, 9.9994e-01, 2.7187e-05, 1.3897e-08]))\n```\n\n# Top-k Image Classification\nIn the `smooth-topk` directory, we have connected the LML layer to the\nPyTorch experiments in the\n[oval-group/smooth-topk](https://github.com/oval-group/smooth-topk)\nrepository.\nWe ran these experiments with PyTorch 1.0.\n\nA single LML training run can be done from the `smooth-topk/src` directory with\n\n```\n./main.py --dataset cifar100 --model densenet40-40 --out-name /tmp/lml-cifar --loss lml --noise 0.0 --seed 0 --no-visdom\n```\n\nCoordinating all of the CIFAR-100 experiments can be done with\nthe `./scripts/cifar100_noise_*.sh` scripts.\n\nWe have also added an option to use the \n[NVIDIA/DALI](https://github.com/NVIDIA/DALI)\nlibrary for pre-processing ImageNet images on the GPU,\nbut [DALI currently has known memory leaks](https://github.com/NVIDIA/DALI/issues/344)\nthat currently cause the experiments to crash and\nrun out of memory.\n\n# Neural Motifs: Scene Graph Generation\n\nIn the `neural-motifs` directory, we have connected the LML layer to the\nPyTorch experiments in the\n[rowanz/neural-motifs](https://github.com/rowanz/neural-motifs)\nrepository.\nThe `README` in this directory provides more details about\nsetting up and running the experiments.\nThe original code has not been updated to the latest version of\nPyTorch and these experiments should be run with PyTorch 0.3.\n\nA single LML training run can be done from the `neural-motifs` directory with\n\n```\npython3 models/train_rels.py -m predcls -model motifnet -order leftright -nl_obj 2 -nl_edge 4 -b 6 -clip 5 -p 10 -hidden_dim 512 -pooling_dim 4096 -lr 1e-3 -ngpu 1 -ckpt checkpoints/vg-faster-rcnn.tar -save_dir /tmp/lml-nm -nepoch 50 -use_bias --lml_topk 20\n```\n\nCoordinating all of the experiments can be done with\n`/scripts/train_predcls.sh`.\n\n# Licensing and Citations\n\nOur LML layer in `lml.py` is licensed under the MIT license.\nAll other code in this repository remains under the\noriginal licensing.\n\nIf you find this repository helpful in your publications,\nplease consider citing our paper.\n\n```\n@article{amos2019limited,\n  title={{The Limited Multi-Label Projection Layer}},\n  author={Brandon Amos and Vladlen Koltun and J. Zico Kolter},\n  journal={arXiv preprint arXiv:1906.08707},\n  year={2019}\n}\n```\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flocuslab%2Flml","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Flocuslab%2Flml","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flocuslab%2Flml/lists"}