{"id":18401711,"url":"https://github.com/borealisai/dynashare-mtl","last_synced_at":"2026-04-29T01:33:02.002Z","repository":{"id":229688404,"uuid":"768862325","full_name":"BorealisAI/DynaShare-MTL","owner":"BorealisAI","description":"PyTorch Implementation of DynaShare: Task and Instance Conditioned Parameter Sharing for Multi-Task Learning","archived":false,"fork":false,"pushed_at":"2024-03-21T06:25:12.000Z","size":6868,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-04-12T18:19:20.643Z","etag":null,"topics":["dynamic-neural-networks","multi-task-learning","pytorch"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/BorealisAI.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}},"created_at":"2024-03-07T21:48:36.000Z","updated_at":"2024-09-06T17:35:23.000Z","dependencies_parsed_at":"2024-03-25T20:02:44.334Z","dependency_job_id":"c9dc1035-eba0-4cbe-9a5a-a20f2e63f7a5","html_url":"https://github.com/BorealisAI/DynaShare-MTL","commit_stats":null,"previous_names":["borealisai/dynashare-mtl"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/BorealisAI/DynaShare-MTL","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/BorealisAI%2FDynaShare-MTL","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/BorealisAI%2FDynaShare-MTL/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/BorealisAI%2FDynaShare-MTL/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/BorealisAI%2FDynaShare-MTL/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/BorealisAI","download_url":"https://codeload.github.com/BorealisAI/DynaShare-MTL/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/BorealisAI%2FDynaShare-MTL/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":32407164,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-28T19:38:08.556Z","status":"ssl_error","status_checked_at":"2026-04-28T19:37:55.688Z","response_time":56,"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":["dynamic-neural-networks","multi-task-learning","pytorch"],"created_at":"2024-11-06T02:39:42.746Z","updated_at":"2026-04-29T01:33:01.976Z","avatar_url":"https://github.com/BorealisAI.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# DynaShare: Task and Instance Conditioned Parameter Sharing for Multi-Task Learning\n\n## Introduction\n![alt text](DynaShare/figures/workflow_v2.jpg)\n\nIn this paper (DynaShare), we extend the task-conditioned parameter sharing approach pioneered by AdaShare, and condition parameter sharing on both the task and the intermediate feature representations. **DynaShare** learns a hierarchical gating policy consisting of a task-specific policy for coarse layer selection and gating units for individual input instances, which work together to determine the execution path at inference time. Experiments on the **NYU v2**, **Cityscapes** and **MIMIC-III** datasets demonstrate the superiority and efficiency of the proposed approach across problem domains.\n\nHere is [the link](https://openaccess.thecvf.com/content/CVPR2023W/ECV/html/Rahimian_DynaShare_Task_and_Instance_Conditioned_Parameter_Sharing_for_Multi-Task_Learning_CVPRW_2023_paper.html) for our CVPR version. \n\nWelcome to cite our work if you find it is helpful to your research.\n```\n@InProceedings{Rahimian_2023_CVPR,\n    author    = {Rahimian, E. and Javadi, G. and Tung, F. and Oliveira, G.},\n    title     = {DynaShare: Task and Instance Conditioned Parameter Sharing for Multi-Task Learning},\n    booktitle = {Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition (CVPR) Workshops},\n    month     = {June},\n    year      = {2023},\n    pages     = {4535-4543}\n}\n```\n\n\n##  Experiment Environment\n\nOur implementation is in Pytorch. We train and test our model on 1 `Quadro RTX 5000` GPU for `NYU v2 2-task` and `CityScapes 2-task`. \n\nWe use `python3.6` and  please refer to [this link](https://docs.conda.io/projects/conda/en/latest/user-guide/tasks/manage-environments.html#creating-an-environment-with-commands) to create a `python3.6` conda environment.\n\nInstall the listed packages in the virual environment:\n```\nconda install pytorch torchvision cudatoolkit=10.2 -c pytorch\nconda install matplotlib\nconda install -c menpo opencv\nconda install pillow\nconda install -c conda-forge tqdm\nconda install -c anaconda pyyaml\nconda install scikit-learn\nconda install -c anaconda scipy\npip install tensorboardX\n```\n\n## Datasets\n\n### MIMIC3\n\nThis dataset is not public available, so you need to submit a request to work with this data\nat [https://mimic.mit.edu/iii/gettingstarted/](https://mimic.mit.edu/iii/gettingstarted/). We followed the\npre-processing steps available\nhere: [https://github.com/YerevaNN/mimic3-benchmarks](https://github.com/YerevaNN/mimic3-benchmarks) and saved the\nresults in a folder named `mimic_dataset`.\n\n## Training\n### Policy Learning Phase\n\nPlease execute train.py for policy learning, using the command:\n```\npython train.py --config yamls/adashare/mimic_iii_4tasks.yml --gpus 0\n```\n### Policy Learning Phase new policy learning \n```\npython train_policy_learning.py --config yamls/adashare/mimic_iii_4tasks_aig.yml --gpus 1\n```\n\n## Retrain Phase\nAfter Policy Learning Phase, we sample 8 different architectures and execute re-train.py for retraining. \n```\npython re-train.py --config \u003cyaml_file_name\u003e --gpus \u003cgpu ids\u003e --exp_ids \u003crandom seed id\u003e\n```\n### Retrain Phase AIG\n```\npython re-train.py --config yamls/adashare/mimic_iii_4tasks_aig.yml --gpus 1 --exp_ids 2\n```\n\n\u003crandom seed id\u003e, shows the seed index in the config file.\n\n## Test Phase\nAfter Retraining Phase, execute test.py for get the quantitative results on the test set.\n```\npython test.py --config \u003cyaml_file_name\u003e --gpus \u003cgpu ids\u003e --exp_ids \u003crandom seed id\u003e\n```\n\nand example of using different seed for mimic dataset:\n```\npython test.py --config yamls/adashare/mimic_iii_4tasks.yml --gpus 0 --exp_ids 2\n```\n\n\n## NYU v2 and CityScapes\n\n\nFor full training and testing access to DynaShare on NYU v2 and Cityscapes access DynaShare folder.\n\n```\ncd DynaShare/\n```\n\nPlease download the formatted datasets for `NYU v2` [here](https://drive.google.com/file/d/11pWuQXMFBNMIIB4VYMzi9RPE-nMOBU8g/view?usp=sharing) \n\nThe formatted `CityScapes` can be found [here](https://drive.google.com/file/d/1WrVMA_UZpoj7voajf60yIVaS_Ggl0jrH/view?usp=sharing).\n\n\u003c!--Download `Tiny-Taskonomy` as instructed by its [GitHub](https://github.com/StanfordVL/taskonomy/tree/master/data).\n\nThe formatted `DomainNet` can be found [here](https://drive.google.com/file/d/1qVtPnKX_iuNXcR3JoP4llxflIUEw880j/view?usp=sharing).--\u003e\n\nRemember to change the `dataroot` to your local dataset path in all `yaml` files in the `./yamls/`.\n\n## Training\n### Policy Learning Phase\nPlease execute `train.py` for policy learning in **Train_AdaShare** folder, using the command \n```\npython train.py --config \u003cyaml_file_name\u003e --gpus \u003cgpu ids\u003e\n```\nFor example, `python train.py --config yamls/adashare/nyu_v2_2task.yml --gpus 0`.\n\nSample `yaml` files are under `yamls/adashare`\n\n**Note:** The train phase is exactly the same as Adashare paper [the link](https://arxiv.org/pdf/1911.12423.pdf).\n\u003c!--**Note:** use `domainnet` branch for experiments on DomainNet, i.e. `python train_domainnet.py --config \u003cyaml_file_name\u003e --gpus \u003cgpu ids\u003e`--\u003e\n\n### Retrain Phase\nAfter Policy Learning Phase, we sample 8 different architectures and execute `re-train.py` for retraining.\n```\npython re-train.py --config \u003cyaml_file_name\u003e --gpus \u003cgpu ids\u003e --exp_ids \u003crandom seed id\u003e\n```\nwhere we use different `--exp_ids` to specify different random seeds and generate different architectures. The best performance of all 8 runs is reported in the paper.\n\nFor example, `python re-train.py --config yamls/adashare/nyu_v2_2task_aig.yml --gpus 0 --exp_ids 0`. \n\n\u003c!--**Note:** use `domainnet` branch for experiments on DomainNet, i.e. `python re-train_domainnet.py --config \u003cyaml_file_name\u003e --gpus \u003cgpu ids\u003e`--\u003e\n\n\n## Test/Inference\nAfter Retraining Phase, execute `test.py` for get the quantitative results on the test set. \n```\npython test.py --config \u003cyaml_file_name\u003e --gpus \u003cgpu ids\u003e --exp_ids \u003crandom seed id\u003e\n```\nFor example, `python test.py --config yamls/adashare/nyu_v2_2task_test.yml --gpus 0 --exp_ids 0`.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fborealisai%2Fdynashare-mtl","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fborealisai%2Fdynashare-mtl","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fborealisai%2Fdynashare-mtl/lists"}