{"id":22248756,"url":"https://github.com/linhaowei1/tpl","last_synced_at":"2025-10-12T05:10:44.624Z","repository":{"id":196531912,"uuid":"696309564","full_name":"linhaowei1/TPL","owner":"linhaowei1","description":"✌[ICLR 2024] Class Incremental Learning via Likelihood Ratio Based Task Prediction","archived":false,"fork":false,"pushed_at":"2024-10-29T05:56:18.000Z","size":2499,"stargazers_count":32,"open_issues_count":3,"forks_count":4,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-08-03T09:25:10.523Z","etag":null,"topics":["class-incremental-learning","continual-learning","likelihood-ratio-test","ood-detection"],"latest_commit_sha":null,"homepage":"https://arxiv.org/abs/2309.15048","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/linhaowei1.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,"zenodo":null}},"created_at":"2023-09-25T13:54:34.000Z","updated_at":"2025-07-24T06:11:29.000Z","dependencies_parsed_at":null,"dependency_job_id":"78336663-ecfb-4235-82b7-90d1eff681e7","html_url":"https://github.com/linhaowei1/TPL","commit_stats":null,"previous_names":["linhaowei1/tplr","linhaowei1/tpl"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/linhaowei1/TPL","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/linhaowei1%2FTPL","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/linhaowei1%2FTPL/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/linhaowei1%2FTPL/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/linhaowei1%2FTPL/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/linhaowei1","download_url":"https://codeload.github.com/linhaowei1/TPL/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/linhaowei1%2FTPL/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":279010342,"owners_count":26084738,"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","status":"online","status_checked_at":"2025-10-12T02:00:06.719Z","response_time":53,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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":["class-incremental-learning","continual-learning","likelihood-ratio-test","ood-detection"],"created_at":"2024-12-03T06:18:26.843Z","updated_at":"2025-10-12T05:10:44.602Z","avatar_url":"https://github.com/linhaowei1.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Class Incremental Learning via Likelihood Ratio Based Task Prediction\n\nThis repository contains the code for our ICLR2024 paper [Class Incremental Learning via Likelihood Ratio Based Task Prediction](https://arxiv.org/abs/2309.15048) by [Haowei Lin](https://linhaowei1.github.io/), [Yijia Shao](https://shaoyijia.github.io/), Weinan Qian, Ningxin Pan, Yiduo Guo, and [Bing Liu](https://www.cs.uic.edu/~liub/).\n\n**Update [2024.2.10]: Now we support DER++, Non-CL, and more pre-trained visual encoders!**\n\n## Quick Links\n\n- [Overview](#overview)\n- [Requirements](#requirements)\n- [Training](#training)\n- [Extension](#extension)\n- [Bugs or Questions?](#bugs-or-questions)\n- [Acknowledgements](acknowledgements#)\n- [Citation](#citation)\n\n## Overview\n\n![](figures/TPL.png)\n\n## Requirements\n\nFirst, install PyTorch by following the instructions from [the official website](https://pytorch.org/). We run the experiments on Pytorch 2.0.1, and PyTorch version higher than `1.6.0` should also work. For example, if you use Linux and **CUDA11** ([how to check CUDA version](https://varhowto.com/check-cuda-version/)), install PyTorch by the following command,\n\n```\npip install torch==1.6.0+cu110 -f https://download.pytorch.org/whl/torch_stable.html\n```\n\nIf you instead use **CUDA** `\u003c11` or **CPU**, install PyTorch by the following command,\n\n```\npip install torch==1.6.0\n```\n\nThen run the following script to install the remaining dependencies,\n\n```\npip install -r requirements.txt\n```\n\n**Attention**: Our model is based on `timm==0.4.12`. Using them from other versions may cause some unexpected bugs.\n\n## Training\n\nIn the following section, we describe how to train the TPL model by using our code.\n\n**Data**\n\nBefore training and evaluation, please download the datasets (CIFAR-10, CIFAR-100, TinyImageNet). The default working directory is set as ``~/data`` in our code. You can modify it according to your need.\n\n**Pre-train Model**\n\nWe use the pre-train DeiT model provided by [MORE](https://github.com/k-gyuhak/MORE). Please download it and save the file as ``./ckpt/pretrained/deit_small_patch16_224_in661.pth``. If you would like to test other pre-trained visual encoders, also download to the same place (you can find the pre-trained weights in timm or huggingface). We provide the scripts for Dino, MAE, CILP, ViT (small, tiny), DeiT (small, tiny).\n\n**Training scripts**\n\nWe provide the examplar training and evaluation script as `deit_small_in661.sh`. Just run the following command and you will get the results:\n\n```bash\nbash scripts/deit_small_in661.sh\n```\n\nThis script performs both training and testing. The default training will train TPL for 5 random seeds. In training, the results will be logged in `ckpt` and the training results are $HAT_{CIL}$ without using TPL inference techniques. After running evaluation, it will be replaced with new results. If you find you get a bad results, try to check if you run the `eval.py` accurately. The results for the first run with `seed=2023` will be saved in `./ckpt/seq0/seed2023/progressive_main_2023`.\n\nFor the results in the paper, we use Nvidia A100 GPUs with CUDA 11.7. Using different types of devices or different versions of CUDA/other software may lead to slightly different performance.\n\n## Extension\n\nOur repo also supports running baselines like DER++. If you are interested in other baselines, just follow the same way of DER++ to integrate your new code. Also, if you want to test TIL+OOD methods, you can just modify the inference code and include the OOD score computation in `baseline.py`. Our code base is vey extensible.\n\n## Bugs or questions?\n\nIf you have any questions related to the code or the paper, feel free to email [Haowei](mailto:linhaowei@pku.edu.cn). If you encounter any problems when using the code, or want to report a bug, you can open an issue. Please try to specify the problem with details so we can help you better and quicker!\n\n## Acknowledgements\n\nWe thank [PyContinual](https://github.com/ZixuanKe/PyContinual) for providing an extensible framework for continual learning. We use their code structure as a reference when developing this code base.\n\n## Citation\n\nPlease cite our paper if you use this code or part of it in your work:\n\n```bibtex\n@inproceedings{lin2024class,\n      title={Class Incremental Learning via Likelihood Ratio Based Task Prediction}, \n      author={Haowei Lin and Yijia Shao and Weinan Qian and Ningxin Pan and Yiduo Guo and Bing Liu},\n      year={2024},\n      booktitle={International Conference on Learning Representations}\n}\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flinhaowei1%2Ftpl","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Flinhaowei1%2Ftpl","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flinhaowei1%2Ftpl/lists"}