{"id":20663747,"url":"https://github.com/vita-group/m-l2o","last_synced_at":"2025-07-17T16:37:52.214Z","repository":{"id":107046559,"uuid":"604950357","full_name":"VITA-Group/M-L2O","owner":"VITA-Group","description":"[ICLR 2023] \"M-L2O: Towards Generalizable Learning-to-Optimize by Test-Time Fast Self-Adaptation\" by Junjie Yang, Xuxi Chen, Tianlong Chen, Zhangyang Wang, Yingbin Liang","archived":false,"fork":false,"pushed_at":"2023-02-26T22:28:26.000Z","size":31,"stargazers_count":6,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-03-29T09:42:03.037Z","etag":null,"topics":["generalization","learning-to-optimize"],"latest_commit_sha":null,"homepage":"","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/VITA-Group.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}},"created_at":"2023-02-22T05:47:09.000Z","updated_at":"2023-06-27T14:43:25.000Z","dependencies_parsed_at":"2023-04-13T15:47:08.406Z","dependency_job_id":null,"html_url":"https://github.com/VITA-Group/M-L2O","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/VITA-Group%2FM-L2O","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/VITA-Group%2FM-L2O/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/VITA-Group%2FM-L2O/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/VITA-Group%2FM-L2O/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/VITA-Group","download_url":"https://codeload.github.com/VITA-Group/M-L2O/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":249731218,"owners_count":21317341,"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":["generalization","learning-to-optimize"],"created_at":"2024-11-16T19:19:39.375Z","updated_at":"2025-04-19T15:56:01.771Z","avatar_url":"https://github.com/VITA-Group.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# M-L2O: Towards Generalizable Learning-to-Optimize by Test-Time Fast Self-Adaptation\n\nThe official implementation of ICLR 2023 paper [M-L2O: Towards Generalizable Learning-to-Optimize by Test-Time Fast Self-Adaptation](https://openreview.net/forum?id=s7oOe6cNRT8).\n\n## Abstract\n\nLearning to Optimize (L2O) has drawn increasing attention as it often remarkably\naccelerates the optimization procedure of complex tasks by overfitting specific\ntask types, leading to enhanced performance compared to analytical optimizers.\nGenerally, L2O develops a parameterized optimization method (i.e., optimizer)\nby learning from solving sample problems. This data-driven procedure yields L2O\nthat can efficiently solve problems similar to those seen in training, that is, drawn\nfrom the same \"task distribution\". However, such learned optimizers often struggle\nwhen new test problems come with a substantial deviation from the training task\ndistribution. This paper investigates a potential solution to this open challenge,\nby meta-training an L2O optimizer that can perform fast test-time self-adaptation\nto an out-of-distribution task, in only a few steps. We theoretically characterize\nthe generalization of L2O, and further show that our proposed framework (termed\nas M-L2O) provably facilitates rapid task adaptation by locating well-adapted\ninitial points for the optimizer weight. Empirical observations on several classic\ntasks like LASSO, Quadratic and Rosenbrock demonstrate that M-L2O converges\nsignificantly faster than vanilla L2O with only 5 steps of adaptation, echoing our\ntheoretical results.\n\n## Usage\n\n### Enviroment\n\n```bash\nconda env create -f environment.yml\n```\n\n### Meta-Training\n\n#### Pretrained for Transfer Learning\n\n```bash\ncd Meta_Train\npython train_rnnprop.py --save_path normal_pretrained --problem lasso_train_mix --if_cl=True\n```\n\n#### M-L2O\n\n```bash\ncd Meta_Train\npython train_rnnprop.py --save_path ml2o_pretrained --if_cl=True\n```\n\n### (Meta-)Testing (Rosenbrock)\n\nFirstly, run the following commands to generate a few fixed optimizees.\n\n```bash\ncd Meta_Train\nfor i in $(seq 1 10); do CUDA_VISIBLE_DEVICES=0 python evaluate_rnnprop.py --output_path optimizee_${i}_ros --seed ${i} --problem rosenbrock; done\n```\n\n#### Vanilla L2O\n\n```bash\n# Use optimizee_0_ros for example. \ncd Meta_Adapt\npython train_rnnprop.py --save_path vanilla_rosenbrock --optimizee_path ../MAML_Train/optimizee_0_ros/initial_optimizee_params.pickle --num_epochs 10 --seed 1 --problem rosenbrock\ncd ../Meta_Train\npython evaluate_rnnprop.py --output_path vanilla_rosenbrock --optimizee_path optimizee_1_ros/initial_optimizee_params.pickle --path ../MAML_Adapt/vanilla_rosenbrock/rp.l2l-final --problem rosenbrock --seed 1 \n```\n\n#### Direct Transfer\n\n```bash\ncd Meta_Train\npython evaluate_rnnprop.py --output_path direct_transfer_rosenbrock --optimizee_path optimizee_0_ros/initial_optimizee_params.pickle --path ../MAML_Adapt/normal_pretrained/rp.l2l-0 --problem rosenbrock --seed 1\n```\n\n#### Transfer Learning\n\n```bash\ncd MAML_Adapt/\npython train_rnnprop.py --save_path transfer_learning_rosenbrock --optimizee_path ../MAML_Train/optimizee_0_ros/initial_optimizee_params.pickle --num_epochs 10 --seed 1 --optimizer_path normal_pretrained/rp.l2l-0 --problem rosenbrock \ncd ../MAML_Train/\npython evaluate_rnnprop.py --output_path transfer_learning_rosenbrock --optimizee_path optimizee_0_ros/initial_optimizee_params.pickle --path ../MAML_Adapt/transfer_learning_rosenbrock/rp.l2l-0 --problem rosenbrock --seed 1\n```\n\n#### M-L2O\n\n```bash\ncd MAML_Adapt/\npython train_rnnprop.py --save_path ml2o_rosenbrock --optimizee_path ../MAML_Train/optimizee_0_ros/initial_optimizee_params.pickle --num_epochs 10 --seed 1 --optimizer_path ml2o_pretrained/rp.l2l-0 --problem rosenbrock \ncd ../MAML_Train/\npython evaluate_rnnprop.py --output_path ml2o_rosenbrock --optimizee_path optimizee_0_ros/initial_optimizee_params.pickle --path ../MAML_Adapt/ml2o_rosenbrock/rp.l2l-0 --problem rosenbrock --seed 1\n```","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fvita-group%2Fm-l2o","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fvita-group%2Fm-l2o","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fvita-group%2Fm-l2o/lists"}