{"id":32929173,"url":"https://github.com/pranta-barua007/learning-without-forgetting-pytorch","last_synced_at":"2026-05-14T01:39:43.300Z","repository":{"id":323021831,"uuid":"1091830521","full_name":"pranta-barua007/learning-without-forgetting-pytorch","owner":"pranta-barua007","description":"🧠 Incremental learning experiment using Learning without Forgetting (LwF) in PyTorch - training model new classes (like horse) without forgetting old ones (cow, donkey, sheep).","archived":false,"fork":false,"pushed_at":"2025-11-07T15:37:29.000Z","size":4567,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2025-11-07T17:28:00.834Z","etag":null,"topics":["learning-without-forgetting","pytorch","transfer-learning"],"latest_commit_sha":null,"homepage":"","language":"Jupyter Notebook","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/pranta-barua007.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,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2025-11-07T15:27:39.000Z","updated_at":"2025-11-07T15:40:09.000Z","dependencies_parsed_at":null,"dependency_job_id":null,"html_url":"https://github.com/pranta-barua007/learning-without-forgetting-pytorch","commit_stats":null,"previous_names":["pranta-barua007/learning-without-forgetting-pytorch"],"tags_count":null,"template":false,"template_full_name":null,"purl":"pkg:github/pranta-barua007/learning-without-forgetting-pytorch","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pranta-barua007%2Flearning-without-forgetting-pytorch","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pranta-barua007%2Flearning-without-forgetting-pytorch/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pranta-barua007%2Flearning-without-forgetting-pytorch/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pranta-barua007%2Flearning-without-forgetting-pytorch/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/pranta-barua007","download_url":"https://codeload.github.com/pranta-barua007/learning-without-forgetting-pytorch/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pranta-barua007%2Flearning-without-forgetting-pytorch/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":33006725,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-13T13:14:54.681Z","status":"ssl_error","status_checked_at":"2026-05-13T13:14:51.610Z","response_time":115,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"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":["learning-without-forgetting","pytorch","transfer-learning"],"created_at":"2025-11-11T11:12:20.897Z","updated_at":"2026-05-14T01:39:43.291Z","avatar_url":"https://github.com/pranta-barua007.png","language":"Jupyter Notebook","funding_links":[],"categories":[],"sub_categories":[],"readme":"# 🧠 Incremental Learning with Learning without Forgetting (LwF)\n\n\u003e *An educational PyTorch experiment demonstrating how a neural network can learn new classes without forgetting previously learned ones.*\n\n---\n\n## 🌟 Overview\n\nThis project explores **Incremental Learning** using the **Learning without Forgetting (LwF)** approach.  \nInstead of retraining from scratch when new classes arrive, we retain knowledge from the old model while adapting to new data — reducing *catastrophic forgetting*.\n\nThe experiment is implemented in **PyTorch** and applied to a subset of the [Animal Image Dataset (Kaggle)](https://www.kaggle.com/datasets/iamsouravbanerjee/animal-image-dataset-90-different-animals).\n\n---\n\n## 🧩 What’s Inside\n\n- **Stage 1 – Initial Training:**  \n  Train a ResNet-18 model on 3 animal classes: `cow`, `donkey`, and `sheep`.\n\n- **Stage 2 – Incremental Learning:**  \n  Introduce a new class `horse` and fine-tune the model using **LwF** to preserve old knowledge.\n\n- **Knowledge Distillation:**  \n  Combine standard classification loss with a distillation loss that aligns new model outputs with those of the frozen old model.\n\n\n## ⚙️ Implementation Details\n\n| Component | Description |\n|------------|-------------|\n| **Backbone** | Pretrained ResNet-18 (ImageNet weights) |\n| **Optimizer** | Adam |\n| **Initial Learning Rate** | 0.001 |\n| **Incremental Learning Rate** | 0.0001 |\n| **Initial Epochs** | 20 |\n| **Incremental Epochs** | 10 |\n\n---\n\n## 📈 Results Summary\n\n* The model successfully learns the **new class (horse)** without completely forgetting the original classes.\n* Knowledge distillation stabilizes logits for old classes, achieving balanced performance across all four categories.\n\n| Stage       | Classes            | Accuracy (approx.) | Observation                     |\n| ----------- | ------------------ | ------------------ | ------------------------------- |\n| Initial     | cow, donkey, sheep | ~95%               | Good base performance           |\n| Incremental | +horse             | ~90–92%            | Slight drop, minimal forgetting |\n\n\n## 🚀 Future Work\n\n* Extend to multi-step incremental learning (add more classes sequentially)\n* Add visualization for logits drift and forgetting metrics\n\n\n## 👤 Author\n\n**[Pranta Barua](https://github.com/pranta-barua007)**\nEducational experiment on continual learning (2025)\n\n---\n\n\u003e ⭐ *If you found this useful or educational, consider starring the repository!*\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpranta-barua007%2Flearning-without-forgetting-pytorch","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fpranta-barua007%2Flearning-without-forgetting-pytorch","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpranta-barua007%2Flearning-without-forgetting-pytorch/lists"}