URT
ICLR 2021: A Universal Representation Transformer Layer for Few-Shot Image Classification
Install / Use
/learn @liulu112601/URTREADME
[ICLR 2021] A Universal Representation Transformer Layer for Few-Shot Image Classification
Dependencies
This code requires the following:
- Python 3.6 or greater
- PyTorch 1.0 or greater
- TensorFlow 1.14 or greater
Data Preparation
-
Meta-Dataset:
Follow the the "User instructions" in the Meta-Dataset repository for "Installation" and "Downloading and converting datasets".
-
Additional Test Datasets:
If you want to test on additional datasets, i.e., MNIST, CIFAR10, CIFAR100, follow the installation instructions in the CNAPs repository to get these datasets.
Getting the Feature Extractors
URT can be built on top of backbones pretrained in any ways.
The easiest way is to download SUR's pre-trained models and use them to obtain a universal set of features directly. If that is what you want, execute the following command in the root directory of this project:wget http://thoth.inrialpes.fr/research/SUR/all_weights.zip && unzip all_weights.zip && rm all_weights.zip
It will donwnload all the weights and place them in the ./weights directory.
Or pretrain the backbone by yourself on the training sets of Meta-Dataset and put the model weights under the directory of ./weights.
Train and evaluate URT
Dumping features (for efficient training and evaluation)
We found that the bottleneck of training URT is extracting features from CNN. Since we freeze the CNN when training the URT, we found dumping the extracted feature episodes can significantly speed up the training procedure from days to ~2 hours. The easiest way is to download all the extracted features from HERE and put it in the ${cache_dir}.
Or you can extract by your own via bash ./scripts/pre-extract-feature.sh resnet18 ${cache_dir}
Train and evaluate
run command from the dir of this repo: bash ./fast-scripts/urt-avg-head.sh ${log_dir} ${num_head} ${penalty_coef} ${cache_dir}, where the ${num_head}=2 and ${penalty_coef}=0.1 in our paper.
Related Skills
node-connect
351.8kDiagnose OpenClaw node connection and pairing failures for Android, iOS, and macOS companion apps
frontend-design
110.9kCreate distinctive, production-grade frontend interfaces with high design quality. Use this skill when the user asks to build web components, pages, or applications. Generates creative, polished code that avoids generic AI aesthetics.
openai-whisper-api
351.8kTranscribe audio via OpenAI Audio Transcriptions API (Whisper).
qqbot-media
351.8kQQBot 富媒体收发能力。使用 <qqmedia> 标签,系统根据文件扩展名自动识别类型(图片/语音/视频/文件)。
