{"id":13738094,"url":"https://github.com/VICO-UoE/URL","last_synced_at":"2025-05-08T15:32:26.306Z","repository":{"id":41126375,"uuid":"351421139","full_name":"VICO-UoE/URL","owner":"VICO-UoE","description":"Universal Representation Learning from Multiple Domains for Few-shot Classification - ICCV 2021, Cross-domain Few-shot Learning with Task-specific Adapters - CVPR 2022","archived":false,"fork":false,"pushed_at":"2024-02-23T02:20:20.000Z","size":582,"stargazers_count":128,"open_issues_count":4,"forks_count":18,"subscribers_count":8,"default_branch":"master","last_synced_at":"2024-12-28T11:15:11.423Z","etag":null,"topics":["few-shot-learning","knowledge-distillation","multi-domain-learning","multi-domain-meta-training"],"latest_commit_sha":null,"homepage":"","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/VICO-UoE.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}},"created_at":"2021-03-25T12:03:10.000Z","updated_at":"2024-12-28T09:55:33.000Z","dependencies_parsed_at":"2024-02-23T03:37:18.867Z","dependency_job_id":null,"html_url":"https://github.com/VICO-UoE/URL","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/VICO-UoE%2FURL","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/VICO-UoE%2FURL/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/VICO-UoE%2FURL/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/VICO-UoE%2FURL/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/VICO-UoE","download_url":"https://codeload.github.com/VICO-UoE/URL/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":253096400,"owners_count":21853596,"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":["few-shot-learning","knowledge-distillation","multi-domain-learning","multi-domain-meta-training"],"created_at":"2024-08-03T03:02:11.067Z","updated_at":"2025-05-08T15:32:23.469Z","avatar_url":"https://github.com/VICO-UoE.png","language":"Python","funding_links":[],"categories":["Python"],"sub_categories":[],"readme":"# Universal Representation Learning and Task-specific Adaptation for Few-shot Learning \nA universal representation learning algorithm that learns a set of well-generalized representations via a single universal network from multiple diverse visual datasets and task-specific adaptation techniques for few-shot learning.\n\n\u003cp align=\"center\"\u003e\n  \u003cimg src=\"./figures/fsl.png\" style=\"width:60%\"\u003e\n\u003c/p\u003e\n\n\u003e [**Universal Representation Learning from Multiple Domains for Few-shot Classification**](https://arxiv.org/abs/2103.13841),            \n\u003e Wei-Hong Li, Xialei Liu, Hakan Bilen,        \n\u003e *ICCV 2021 ([arXiv 2103.13841](https://arxiv.org/abs/2103.13841))*  \n\u003e\n\u003e [**Cross-domain Few-shot Learning with Task-specific Adapters**](https://arxiv.org/abs/2107.00358),            \n\u003e Wei-Hong Li, Xialei Liu, Hakan Bilen,        \n\u003e *CVPR 2022 ([arXiv 2107.00358](https://arxiv.org/abs/2107.00358))*  \n\u003e\n\u003e [**Universal Representations: A Unified Look at Multiple Task and Domain Learning**](https://arxiv.org/abs/2204.02744),            \n\u003e Wei-Hong Li, Xialei Liu, Hakan Bilen,        \n\u003e *IJCV 2023 ([arXiv 2204.02744](https://arxiv.org/abs/2204.02744))* \n\n## Updates\n* November'22, Code of different options for task-specific adapters is released! See [TSA](#cross-domain-few-shot-learning-with-task-specific-adapters).\n* March'22, Code for [Cross-domain Few-shot Learning with Task-specific Adapters](https://arxiv.org/pdf/2107.00358.pdf) (CVPR'22) is now available! See [TSA](#cross-domain-few-shot-learning-with-task-specific-adapters).\n* Oct'21, Code and models for [Universal Representation Learning from Multiple Domains for Few-shot Classification](https://arxiv.org/pdf/2103.13841.pdf) (ICCV'21) are now available!\n\n## Features at a glance\n- We train a single universal (task-agnostic) network on 8 visual (training) datasets on Meta-dataset: ImageNet, Omniglot, Aircraft, Birds, Textures, Quick Draw, Fungi, VGG Flower, with state-of-the-art performances on all (13) testing datasets for few-shot learning.\n\n- During meta-testing, the universal representations can be efficiently adapted by our proposed pre-classifier alignment (a linear transformation) learned on the support set to transform the representations to a more discriminative space.\n\n- We propose to attach a set of light weight task-specific adapters to the universal network (the universal network can be learned from multiple datasets or one single diverse dataset, e.g. ImageNet) and learn task-specific adapters on the support set from scratch for adapting the few-shot model to the tasks from unseen domains.\n\n- Our method also allows Low Rank Adaptation (LoRA), i.e. learning the attached adapters can be treating as learning two decomposed matrices, which is more efficient while maintains good performance.\n\n- We systematically study various combinations of several design choices for task-specific adaptation, which have not been explored before, including adapter connection types (serial or residual), parameterizations (matrix and its decomposed variations, channelwise operations) and estimation of task-specific parameters.\n\n- Attaching parameteric adapters in matrix form to convolutional layers with residual connections significantly boosts the state-of-the-art performance in most domains, especially resulting in superior performance in unseen domains on Meta-Dataset\n\n- In this repo, we provide code of the URL, the best task adaptation strategy in TSA, and other baselines like SDL, vanilla MDL and other evaluation settings. \n\n## Main results on [Meta-dataset](https://github.com/google-research/meta-dataset)\n- Multi-domain setting (meta-train on 8 datasets and meta-test on 13 datasets).\n\nTest Datasets              |TSA (Ours)                 |URL (Ours)                 |MDL                        |Best SDL                   |tri-M [8]                  |FLUTE [7]                  |URT [6]                    |SUR [5]                    |Transductive CNAPS [4]     |Simple CNAPS [3]           |CNAPS [2]                  \n---------------------------|---------------------------|---------------------------|---------------------------|---------------------------|---------------------------|---------------------------|---------------------------|---------------------------|---------------------------|---------------------------|---------------------------\nAvg rank                   |**1.5**                    |2.7                        |7.1                        |6.7                        |5.5                        |5.1                        |6.7                        |6.9                        |5.7                        |7.2                        |-                        \nAvg Seen                   |**80.2**                   |80.0                       |76.9                       |76.3                       |74.5                       |76.2                       |76.7                       |75.2                       |75.1                       |74.6                       |71.6                       \nAvg Unseen                 |**77.2**                   |69.3                       |61.7                       |61.9                       |69.9                       |69.9                       |62.4                       |63.1                       |66.5                       |65.8                       |-                        \nAvg All                    |**79.0**                   |75.9                       |71.1                       |70.8                       |72.7                       |73.8                       |71.2                       |70.5                       |71.8                       |71.2                       |-                        \n\n\n- Single-domain setting (Meta-train on ImageNet and meta-test on 13 datasets).\n\nTest Datasets              |TSA-ResNet34 (Ours)        |TSA-ResNet18 (Ours)        |CTX-ResNet34 [10]          |ProtoNet-ResNet34 [10]     |FLUTE [7]                  |BOHB [9]                   |ALFA+fo-Proto-MAML [1]     |fo-Proto-MAML [1]          |ProtoNet [1]               |Finetune [1]               \n---------------------------|---------------------------|---------------------------|---------------------------|---------------------------|---------------------------|---------------------------|---------------------------|---------------------------|---------------------------|---------------------------\nAvg rank                   |**1.5**                    |2.8                        |1.8                        |5.5                        |8.9                        |6.0                        |5.3                        |7.0                        |8.3                        |7.9                        \nAvg Seen                   |**63.7**                   |59.5                       |62.8                       |53.7                       |46.9                       |51.9                       |52.8                       |49.5                       |50.5                       |45.8                       \nAvg Unseen                 |**76.2**                   |71.9                       |75.6                       |61.1                       |53.2                       |60.0                       |62.4                       |58.4                       |56.7                       |58.2                       \nAvg All                    |**74.9**                   |70.7                       |74.3                       |60.4                       |52.6                       |59.2                       |61.4                       |57.5                       |56.1                       |57.0                       \n\n## Model Zoo\n- [Single-domain networks (one for each dataset)](https://drive.google.com/file/d/1MvUcvQ8OQtoOk1MIiJmK6_G8p4h8cbY9/view?usp=sharing)\n\n- [A single universal network (URL) learned from 8 training datasets](https://drive.google.com/file/d/1Dv8TX6iQ-BE2NMpfd0sQmH2q4mShmo1A/view?usp=sharing)\n\n- ImageNet model learned with ResNet34 and higher resolution images (224x224) like CTX [10], coming soon!\n\n## Dependencies\nThis code requires the following:\n* Python 3.6 or greater\n* PyTorch 1.0 or greater\n* TensorFlow 1.14 or greater\n\n## Installation\n* Clone or download this repository.\n* Configure Meta-Dataset:\n    * Follow the \"User instructions\" in the [Meta-Dataset repository](https://github.com/google-research/meta-dataset) for \"Installation\" and \"Downloading and converting datasets\".\n    * Edit ```./meta-dataset/data/reader.py``` in the meta-dataset repository to change ```dataset = dataset.batch(batch_size, drop_remainder=False)``` to ```dataset = dataset.batch(batch_size, drop_remainder=True)```. (The code can run with ```drop_remainder=False```, but in our work, we drop the remainder such that we will not use very small batch for some domains and we recommend to drop the remainder for reproducing our methods.)\n    * To test unseen domain (out-of-domain) performance on additional datasets, i.e. MNIST, CIFAR-10 and CIFAR-100, follow the installation instruction in the [CNAPs repository](https://github.com/cambridge-mlg/cnaps) to get these datasets.\n\n## Initialization\n1. Before doing anything, first run the following commands.\n    ```\n    ulimit -n 50000\n    export META_DATASET_ROOT=\u003croot directory of the cloned or downloaded Meta-Dataset repository\u003e\n    export RECORDS=\u003cthe directory where tf-records of MetaDataset are stored\u003e\n    ```\n    \n    Note the above commands need to be run every time you open a new command shell.\n\n2. Enter the root directory of this project, i.e. the directory where this project was cloned or downloaded.\n\n\n## Universal Representation Learning from Multiple Domains for Few-shot Classification\n\u003cp align=\"center\"\u003e\n  \u003cimg src=\"./figures/universal.png\" style=\"width:60%\"\u003e\n\u003c/p\u003e\n\u003cp align=\"center\"\u003e\n    Figure 1. \u003cb\u003eURL - Universal Representation Learning\u003c/b\u003e.\n\u003c/p\u003e\n\n\n### Train the Universal Representation Learning Network\n1. The easiest way is to download our [pre-trained URL model](https://drive.google.com/file/d/1Dv8TX6iQ-BE2NMpfd0sQmH2q4mShmo1A/view?usp=sharing) and evaluate its feature using our Pre-classifier Alignment (PA). To download the pretrained URL model, one can use `gdown` (installed by ```pip install gdown```) and execute the following command in the root directory of this project:\n    ```\n    gdown https://drive.google.com/uc?id=1Dv8TX6iQ-BE2NMpfd0sQmH2q4mShmo1A \u0026\u0026 md5sum url.zip \u0026\u0026 unzip url.zip -d ./saved_results/ \u0026\u0026 rm url.zip\n    \n    ```\n    This will donwnload the URL model and place it in the ```./saved_results``` directory. One can evaluate this model by our PA (see the [Meta-Testing step](#meta-testing-with-pre-classifier-alignment-pa))\n\n2. Alternatively, one can train the model from scratch: 1) train 8 single domain learning networks; 2) train the universal feature extractor as follow. \n\n#### Train Single Domain Learning Networks\n1. The easiest way is to download our [pre-trained models](https://drive.google.com/file/d/1MvUcvQ8OQtoOk1MIiJmK6_G8p4h8cbY9/view?usp=sharing) and use them to obtain a universal set of features directly. To download single domain learning networks, execute the following command in the root directory of this project:\n    ```\n    gdown https://drive.google.com/uc?id=1MvUcvQ8OQtoOk1MIiJmK6_G8p4h8cbY9 \u0026\u0026 md5sum sdl.zip \u0026\u0026 unzip sdl.zip -d ./saved_results/ \u0026\u0026 rm sdl.zip\n    ```\n\n    This will download all single domain learning models and place them in the ```./saved_results``` directory of this project.\n\n\n2. Alternatively, instead of using the pretrained models, one can train the models from scratch.\n   To train 8 single domain learning networks, run:\n    ```\n    ./scripts/train_resnet18_sdl.sh\n    ```\n\n\n#### Train the Universal Feature Extractor\nTo learn the universal feature extractor by distilling the knowledge from pre-trained single domain learning networks, run: \n```\n./scripts/train_resnet18_url.sh\n```\n\n### Meta-Testing with Pre-classifier Alignment (PA)\n\u003cp align=\"center\"\u003e\n  \u003cimg src=\"./figures/pa.png\" style=\"width:80%\"\u003e\n\u003c/p\u003e\n\u003cp align=\"center\"\u003e\n    Figure 2. \u003cb\u003ePA - Pre-classifier Alignment\u003c/b\u003e for Adapting Features in Meta-test.\n\u003c/p\u003e\n\nThis step would run our Pre-classifier Alignment (PA) procedure per task to adapt the features to a discriminate space and build a Nearest Centroid Classifier (NCC) on the support set to classify query samples, run:\n\n```\n./scripts/test_resnet18_pa.sh\n```\n\n## Cross-domain Few-shot Learning with Task-specific Adapters\n\u003cp align=\"center\"\u003e\n  \u003cimg src=\"./figures/tsa.png\" style=\"width:100%\"\u003e\n\u003c/p\u003e\n\u003cp align=\"center\"\u003e\n    Figure 3. Cross-domain Few-shot Learning with \u003cb\u003eTask-specific Adapters (TSA)\u003c/b\u003e.\n\u003c/p\u003e\n\nWe provide code for attaching task-specific adapters (TSA) to a single universal network learned from meta-train and learn the task-specific adapters on the support set. One can download our [pre-trained URL model](https://drive.google.com/file/d/1Dv8TX6iQ-BE2NMpfd0sQmH2q4mShmo1A/view?usp=sharing) (see [here](#train-the-universal-representation-learning-network) to download the URL or SDL models or train them from scratch) and evaluate its feature adapted by residual adapters in matrix form and pre-classifier alignment, run:\n```\n./scripts/test_resnet18_tsa.sh\n```\n\nOne may want to train the model from scratch from the Meta-training step. For single-domain learning network, see [here](#train-single-domain-learning-networks) to learn a single network from ImageNet with ResNet-18. For multi-domain learning setting, one can learn a URL model (see [here](#train-the-universal-representation-learning-network)) or learn a vanilla MDL model (see [here](#train-a-vanilla-multi-domain-learning-network)). Note that, one may need to amend the input of `--model.name` and `--model.dir` in `./scripts/test_resnet18_tsa.sh` to the model learned from meta-training and amend `--test.mode` to `sdl` if the backbone is learned from ImageNet only in meta-training and then run the TSA.\n\nWe also provide implementation of different options for task-specific adapters, including connection topology (serial or residual), parameterizations (matrix or channel-wise), weight initializations (identity or random). See `./scripts/test_resnet18_tsa.sh` for more details. Note that, you would obtain slightly different results compared with the ones in in Table 3 in our TSA paper as mentioned in https://github.com/google-research/meta-dataset/issues/54. One can set `shuffle_buffer_size` to 0 in `./data/meta_dataset_reader.py` to obtain the same results as in Table 3 in our TSA paper, but I strongly suggest that one should re-run the experiments using our up-to-date code (the results with `shuffle_buffer_size=1000` would be slightly different from the ones with `shuffle_buffer_size=0` and the rankings will be the same).\n\n## Expected Results\nBelow are the results extracted from our papers. The results will vary from run to run by a percent or two up or down due to the fact that the Meta-Dataset reader generates different tasks each run, randomnes in training the networks and in TSA and PA optimization. Note, the results are updated with the up-to-date evaluation from Meta-Dataset. Make sure that you use the up-to-date code from the Meta-Dataset repository to convert the dataset and set ```shuffle_buffer_size=1000``` as mentioned in https://github.com/google-research/meta-dataset/issues/54.\n\n**Models trained on all datasets**\n\nTest Datasets              |TSA (Ours)                 |URL (Ours)                    |MDL                        |Best SDL                   |tri-M [8]                  |FLUTE [7]                  |URT [6]                    |SUR [5]                    |Transductive CNAPS [4]     |Simple CNAPS [3]           |CNAPS [2]                  \n---------------------------|---------------------------|---------------------------|---------------------------|---------------------------|---------------------------|---------------------------|---------------------------|---------------------------|---------------------------|---------------------------|---------------------------\nAvg rank                   |**1.5**                    |2.7                        |7.1                        |6.7                        |5.5                        |5.1                        |6.7                        |6.9                        |5.7                        |7.2                        |-                        \nImageNet                   |**57.4±1.1**\u0026nbsp;         |**57.5±1.1**\u0026nbsp;         |52.9±1.2\u0026nbsp;             |54.3±1.1\u0026nbsp;             |**58.6±1.0**\u0026nbsp;         |51.8±1.1\u0026nbsp;             |55.0±1.1\u0026nbsp;             |54.5±1.1\u0026nbsp;             |**57.9±1.1**\u0026nbsp;         |56.5±1.1\u0026nbsp;             |50.8±1.1\u0026nbsp;             \nOmniglot                   |**95.0±0.4**\u0026nbsp;         |**94.5±0.4**\u0026nbsp;         |93.7±0.5\u0026nbsp;             |93.8±0.5\u0026nbsp;             |92.0±0.6\u0026nbsp;             |93.2±0.5\u0026nbsp;             |93.3±0.5\u0026nbsp;             |93.0±0.5\u0026nbsp;             |94.3±0.4\u0026nbsp;             |91.9±0.6\u0026nbsp;             |91.7±0.5\u0026nbsp;             \nAircraft                   |**89.3±0.4**\u0026nbsp;         |88.6±0.5\u0026nbsp;             |84.9±0.5\u0026nbsp;             |84.5±0.5\u0026nbsp;             |82.8±0.7\u0026nbsp;             |87.2±0.5\u0026nbsp;             |84.5±0.6\u0026nbsp;             |84.3±0.5\u0026nbsp;             |84.7±0.5\u0026nbsp;             |83.8±0.6\u0026nbsp;             |83.7±0.6\u0026nbsp;             \nBirds                      |**81.4±0.7**\u0026nbsp;         |**80.5±0.7**\u0026nbsp;         |79.2±0.8\u0026nbsp;             |70.6±0.9\u0026nbsp;             |75.3±0.8\u0026nbsp;             |79.2±0.8\u0026nbsp;             |75.8±0.8\u0026nbsp;             |70.4±1.1\u0026nbsp;             |78.8±0.7\u0026nbsp;             |76.1±0.9\u0026nbsp;             |73.6±0.9\u0026nbsp;             \nTextures                   |**76.7±0.7**\u0026nbsp;         |**76.2±0.7**\u0026nbsp;         |70.9±0.8\u0026nbsp;             |72.1±0.7\u0026nbsp;             |71.2±0.8\u0026nbsp;             |68.8±0.8\u0026nbsp;             |70.6±0.7\u0026nbsp;             |70.5±0.7\u0026nbsp;             |66.2±0.8\u0026nbsp;             |70.0±0.8\u0026nbsp;             |59.5±0.7\u0026nbsp;             \nQuick Draw                 |**82.0±0.6**\u0026nbsp;         |**81.9±0.6**\u0026nbsp;         |81.7±0.6\u0026nbsp;             |**82.6±0.6**\u0026nbsp;         |77.3±0.7\u0026nbsp;             |79.5±0.7\u0026nbsp;             |**82.1±0.6**\u0026nbsp;         |81.6±0.6\u0026nbsp;             |77.9±0.6\u0026nbsp;             |78.3±0.7\u0026nbsp;             |74.7±0.8\u0026nbsp;             \nFungi                      |**67.4±1.0**\u0026nbsp;         |**68.8±0.9**\u0026nbsp;         |63.2±1.1\u0026nbsp;             |65.9±1.0\u0026nbsp;             |48.5±1.0\u0026nbsp;             |58.1±1.1\u0026nbsp;             |63.7±1.0\u0026nbsp;             |65.0±1.0\u0026nbsp;             |48.9±1.2\u0026nbsp;             |49.1±1.2\u0026nbsp;             |50.2±1.1\u0026nbsp;             \nVGG Flower                 |**92.2±0.5**\u0026nbsp;         |**92.1±0.5**\u0026nbsp;         |88.7±0.6\u0026nbsp;             |86.7±0.6\u0026nbsp;             |90.5±0.5\u0026nbsp;             |**91.6±0.6**\u0026nbsp;         |88.3±0.6\u0026nbsp;             |82.2±0.8\u0026nbsp;             |**92.3±0.4**\u0026nbsp;         |91.3±0.6\u0026nbsp;             |88.9±0.5\u0026nbsp;             \nTraffic Sign               |**83.5±0.9**\u0026nbsp;         |63.3±1.2\u0026nbsp;             |49.2±1.0\u0026nbsp;             |47.1±1.1\u0026nbsp;             |63.0±1.0\u0026nbsp;             |58.4±1.1\u0026nbsp;             |50.1±1.1\u0026nbsp;             |49.8±1.1\u0026nbsp;             |59.7±1.1\u0026nbsp;             |59.2±1.0\u0026nbsp;             |56.5±1.1\u0026nbsp;             \nMSCOCO                     |**55.8±1.1**\u0026nbsp;         |54.0±1.0\u0026nbsp;             |47.3±1.1\u0026nbsp;             |49.7±1.0\u0026nbsp;             |52.8±1.1\u0026nbsp;             |50.0±1.0\u0026nbsp;             |48.9±1.1\u0026nbsp;             |49.4±1.1\u0026nbsp;             |42.5±1.1\u0026nbsp;             |42.4±1.1\u0026nbsp;             |39.4±1.0\u0026nbsp;             \nMNIST                      |**96.7±0.4**\u0026nbsp;         |94.5±0.5\u0026nbsp;             |94.2±0.4\u0026nbsp;             |91.0±0.5\u0026nbsp;             |96.2±0.3\u0026nbsp;             |95.6±0.5\u0026nbsp;             |90.5±0.4\u0026nbsp;             |94.9±0.4\u0026nbsp;             |94.7±0.3\u0026nbsp;             |94.3±0.4\u0026nbsp;             |-         \nCIFAR-10                   |**80.6±0.8**\u0026nbsp;         |71.9±0.7\u0026nbsp;             |63.2±0.8\u0026nbsp;             |65.4±0.8\u0026nbsp;             |75.4±0.8\u0026nbsp;             |78.6±0.7\u0026nbsp;             |65.1±0.8\u0026nbsp;             |64.2±0.9\u0026nbsp;             |73.6±0.7\u0026nbsp;             |72.0±0.8\u0026nbsp;             |-         \nCIFAR-100                  |**69.6±1.0**\u0026nbsp;         |62.6±1.0\u0026nbsp;             |54.7±1.1\u0026nbsp;             |56.2±1.0\u0026nbsp;             |62.0±1.0\u0026nbsp;             |67.1±1.0\u0026nbsp;             |57.2±1.0\u0026nbsp;             |57.1±1.1\u0026nbsp;             |61.8±1.0\u0026nbsp;             |60.9±1.1\u0026nbsp;             |- \n\n**Models trained on ImageNet only**\nTODO\n\n\u003cdiv style=\"text-align:justify; font-size:80%\"\u003e\n    \u003cp\u003e\n        [1] Eleni Triantafillou, Tyler Zhu, Vincent Dumoulin, Pascal Lamblin, Utku Evci, Kelvin Xu, Ross Goroshin, Carles Gelada, Kevin Swersky, Pierre-Antoine Manzagol, Hugo Larochelle; \u003ca href=\"https://arxiv.org/abs/1903.03096\"\u003eMeta-Dataset: A Dataset of Datasets for Learning to Learn from Few Examples\u003c/a\u003e; ICLR 2020.\n    \u003c/p\u003e\n    \u003cp\u003e\n        [2] James Requeima, Jonathan Gordon, John Bronskill, Sebastian Nowozin, Richard E. Turner; \u003ca href=\"https://arxiv.org/abs/1906.07697\"\u003eFast and Flexible Multi-Task Classification Using Conditional Neural Adaptive Processes\u003c/a\u003e; NeurIPS 2019.\n    \u003c/p\u003e\n    \u003cp\u003e\n        [3] Peyman Bateni, Raghav Goyal, Vaden Masrani, Frank Wood, Leonid Sigal; \u003ca href=\"https://openaccess.thecvf.com/content_CVPR_2020/html/Bateni_Improved_Few-Shot_Visual_Classification_CVPR_2020_paper.html\"\u003eImproved Few-Shot Visual Classification\u003c/a\u003e; CVPR 2020.\n    \u003c/p\u003e\n    \u003cp\u003e\n        [4] Peyman Bateni, Jarred Barber, Jan-Willem van de Meent, Frank Wood; \u003ca href=\"https://openaccess.thecvf.com/content/WACV2022/papers/Bateni_Enhancing_Few-Shot_Image_Classification_With_Unlabelled_Examples_WACV_2022_paper.pdf\"\u003eEnhancing Few-Shot Image Classification with Unlabelled Examples\u003c/a\u003e; WACV 2022.\n    \u003c/p\u003e\n    \u003cp\u003e\n        [5] Nikita Dvornik, Cordelia Schmid, Julien Mairal; \u003ca href=\"ttps://arxiv.org/abs/2003.09338\"\u003eSelecting Relevant Features from a Multi-domain Representation for Few-shot Classification\u003c/a\u003e; ECCV 2020.\n    \u003c/p\u003e\n    \u003cp\u003e\n        [6] Lu Liu, William Hamilton, Guodong Long, Jing Jiang, Hugo Larochelle; \u003ca href=\"https://arxiv.org/abs/2006.11702\"\u003eUniversal Representation Transformer Layer for Few-Shot Image Classification\u003c/a\u003e; ICLR 2021.\n    \u003c/p\u003e\n    \u003cp\u003e\n        [7] Eleni Triantafillou, Hugo Larochelle, Richard Zemel, Vincent Dumoulin; \u003ca href=\"https://arxiv.org/pdf/2105.07029.pdf\"\u003eLearning a Universal Template for Few-shot Dataset Generalization\u003c/a\u003e; ICML 2021.\n    \u003c/p\u003e\n    \u003cp\u003e\n        [8] Yanbin Liu, Juho Lee, Linchao Zhu, Ling Chen, Humphrey Shi, Yi Yang; \u003ca href=\"https://openaccess.thecvf.com/content/ICCV2021/papers/Liu_A_Multi-Mode_Modulator_for_Multi-Domain_Few-Shot_Classification_ICCV_2021_paper.pdf\"\u003eA Multi-Mode Modulator for Multi-Domain Few-Shot Classification\u003c/a\u003e; ICCV 2021.\n    \u003c/p\u003e\n    \u003cp\u003e\n        [9] Tonmoy Saikia, Thomas Brox, Cordelia Schmid; \u003ca href=\"https://arxiv.org/abs/2001.07926\"\u003eOptimized Generic Feature Learning for Few-shot Classification across Domains\u003c/a\u003e; arXiv 2020.\n    \u003c/p\u003e\n    \u003cp\u003e\n        [10] Carl Doersch, Ankush Gupta, Andrew Zisserman; \u003ca href=\"https://arxiv.org/abs/2007.11498\"\u003eCrossTransformers: spatially-aware few-shot transfer\u003c/a\u003e; NeurIPS 2020.\n    \u003c/p\u003e\n\u003c/div\u003e\n\n\n## Other Usage\n\n### Train a Vanilla Multi-domain Learning Network\nTo train a vanilla multi-domain learning network (MDL) on Meta-Dataset, run:\n\n```\n./scripts/train_resnet18_mdl.sh\n```\n\n#### Other Classifiers for Meta-Testing (optional)\nOne can use other classifiers for meta-testing, e.g. use ```--test.loss-opt``` to select nearest centroid classifier (ncc, default), support vector machine (svm), logistic regression (lr), Mahalanobis distance from Simple CNAPS (scm), or k-nearest neighbor (knn); use ```--test.feature-norm``` to normalize feature (l2) or not for svm and lr; use ```--test.distance``` to specify the feature similarity function (l2 or cos) for NCC. \n\nTo evaluate the feature extractor with NCC and cosine similarity, run:\n\n```\npython test_extractor.py --test.loss-opt ncc --test.feature-norm none --test.distance cos --model.name=url --model.dir \u003cdirectory of url\u003e \n```\n\n### Five-shot and Five-way-one-shot Meta-test (optional)\nOne can evaluate the feature extractor in meta-testing for five-shot or five-way-one-shot setting by setting ```--test.type``` as '5shot' or '1shot', respectively.\n\nTo test the feature extractor for varying-way-five-shot on the test splits of all datasets, run:\n\n```\npython test_extractor.py --test.type 5shot --test.loss-opt ncc --test.feature-norm none --test.distance cos --model.name=url --model.dir \u003cdirectory of url\u003e\n```\n\nIf one wants to evaluate our proposed URL and TSA method in 5-shot or 5-way-1-shot settings, please use ```test_extractor_pa.py``` and ```test_extractor_tsa.py``` with setting ```--test.type``` as '5shot' or '1shot'.\n\n## Acknowledge\nWe thank authors of [Meta-Dataset](https://github.com/google-research/meta-dataset), [SUR](https://github.com/dvornikita/SUR), [Residual Adapter](https://github.com/srebuffi/residual_adapters) for their source code. \n\n## Contact\nFor any question, you can contact [Wei-Hong Li](https://weihonglee.github.io).\n\n## Citation\nIf you use this code, please cite our papers:\n```\n@article{li2023Universal,\n    author    = {Li, Wei-Hong and Liu, Xialei and Bilen, Hakan},\n    title     = {Universal Representations: A Unified Look at Multiple Task and Domain Learning},\n    journal   = {International Journal of Computer Vision},\n    pages     = {1--25},\n    year      = {2023},\n    publisher = {Springer}\n}\n\n@inproceedings{li2022TaskSpecificAdapter,\n    author    = {Li, Wei-Hong and Liu, Xialei and Bilen, Hakan},\n    title     = {Cross-domain Few-shot Learning with Task-specific Adapters},\n    booktitle = {IEEE/CVF International Conference on Computer Vision and Pattern Recognition (CVPR)},\n    month     = {June},\n    year      = {2022}\n}\n\n@inproceedings{li2021Universal,\n    author    = {Li, Wei-Hong and Liu, Xialei and Bilen, Hakan},\n    title     = {Universal Representation Learning From Multiple Domains for Few-Shot Classification},\n    booktitle = {IEEE/CVF International Conference on Computer Vision (ICCV)},\n    month     = {October},\n    year      = {2021},\n    pages     = {9526-9535}\n}\n\n@inproceedings{li2020knowledge,\n    author    = {Li, Wei-Hong and Bilen, Hakan},\n    title     = {Knowledge distillation for multi-task learning},\n    booktitle = {European Conference on Computer Vision (ECCV) Workshop},\n    year      = {2020}\n}\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FVICO-UoE%2FURL","html_url":"https://awesome.ecosyste.ms/projects/github.com%2FVICO-UoE%2FURL","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FVICO-UoE%2FURL/lists"}