This is the experimental code for our paper "Clustered Task-Aware Meta-Learning by Learning from Learning Paths".
python 2.*
pillow
numpy
pandas
scipy
tensorflow 1.10+
Navigate to few_shot_image
directory for few-shot image classification experiments:
cd few_shot_image
- Download the pre-processed datasets of CUB-200-2011, FGVC-Aircraft, FGVCx-Fungi, and Describable Textures here released by the authors of HSML. Extract under
data
directory, which will create ameta-dataset
folder containing the four sub-datasets. - Download images and labels from VGG Flower official website. Move under
data
directory. - Download GTSRB_Final_Training_Images.zip from GTSRB official website. Extract under
data
directory. - Preprocess VGG Flower and GTSRB datasets (resize image + split data) by running:
cd data_preproc
python preproc_flower.py
python preproc_tsign.py
- Convert image file to numpy array and store in dict (for faster I/O at training time) by running:
python convert_dict_meta_dataset.py
- Download Mini-Imagenet here. Extract under
data/miniimagenet
directory. - Preprocess Mini-Imagenet dataset (resize image + split data) by running:
cd data_preproc
python preproc_miniimagenet.py
- Convert image file to numpy array and store in dict (for faster I/O at training time) by running:
python convert_dict_miniimagenet.py
After pre-processing, few_shot_image/data
directory should have the following structure.
few_shot_image/data
├── meta-dataset
│ ├── CUB_Bird
│ │ ├── train_dict.pkl
│ │ ├── val_dict.pkl
│ │ └── test_dict.pkl
│ ├── DTD_Texture
│ │ ├── train_dict.pkl
│ │ ├── val_dict.pkl
│ │ └── test_dict.pkl
│ ├── FGVC_Aircraft
│ │ ├── train_dict.pkl
│ │ ├── val_dict.pkl
│ │ └── test_dict.pkl
│ ├── FGVCx_Fungi
│ │ ├── train_dict.pkl
│ │ ├── val_dict.pkl
│ │ └── test_dict.pkl
│ ├── GTSRB_Tsign
│ │ ├── train_dict.pkl
│ │ ├── val_dict.pkl
│ │ └── test_dict.pkl
│ └── VGG_Flower
│ │ ├── train_dict.pkl
│ │ ├── val_dict.pkl
│ │ └── test_dict.pkl
└── miniimagenet
├── train_dict.pkl
├── val_dict.pkl
└── test_dict.pkl
To train the proposed model and variants on Meta-Dataset under different settings, run the following:
Setting | Method | Command |
---|---|---|
5-way 1-shot | CTML | python main.py --data meta_dataset --support_size 1 --path_or_feat both |
5-way 1-shot | CTML-path | python main.py --data meta_dataset --support_size 1 --path_or_feat only_path |
5-way 1-shot | CTML-feat (ARML) | python main.py --data meta_dataset --support_size 1 --path_or_feat only_feat |
5-way 5-shot | CTML | python main.py --data meta_dataset --support_size 5 --path_or_feat both |
5-way 5-shot | CTML-path | python main.py --data meta_dataset --support_size 5 --path_or_feat only_path |
5-way 5-shot | CTML-feat (ARML) | python main.py --data meta_dataset --support_size 1 --path_or_feat only_feat |
To evaluate the proposed model and variants on Meta-Dataset under different settings, run the following:
Setting | Method | Command |
---|---|---|
5-way 1-shot | CTML | python main.py --data meta_dataset --support_size 1 --path_or_feat both --eval --test_iters 59000 58000 57000 |
5-way 1-shot | CTML-path | python main.py --data meta_dataset --support_size 1 --path_or_feat only_path --eval --test_iters 59000 58000 57000 |
5-way 1-shot | CTML-feat | python main.py --data meta_dataset --support_size 1 --path_or_feat only_feat --eval --test_iters 59000 58000 57000 |
5-way 5-shot | CTML | python main.py --data meta_dataset --support_size 5 --path_or_feat both --eval --test_iters 59000 58000 57000 |
5-way 5-shot | CTML-path | python main.py --data meta_dataset --support_size 5 --path_or_feat only_path --eval --test_iters 59000 58000 57000 |
5-way 5-shot | CTML-feat | python main.py --data meta_dataset --support_size 1 --path_or_feat only_feat --eval --test_iters 59000 58000 57000 |
Navigate to cold_start_recsys
directory for cold-start recommendation experiments:
cd cold_start_recsys
- Download ml-1m.zip from MovieLens datasets official website. Extract under
data/movielens_1m
directory. - Preprocess MovieLens-1M dataset (construct samples with side information + split data) by running:
cd data_preproc
python preproc_ml.py
- Download Yelp dataset from the official website. Extract under
data
directory, which will create ayelp_dataset
folder. - Extract only useful information from the raw JSON files (for faster preprocessing later) by running:
cd data_preproc
python convert_json_yelp.py
- Preprocess Yelp dataset (construct samples with side information + split data) by running:
python preproc_yelp.py
- Download ratings and metadata of Amazon CDs and Vinyl category from the official website. Move under
data/amazon_cds
directory. - Extract only useful information from the item metadata JSON file (for faster preprocessing later) by running:
cd data_preproc
python convert_json_amzcd.py
- Preprocess Amazon-CDs dataset (construct samples with side information + split data) by running:
python preproc_amzcd.py
After pre-processing, cold_start_recsys/data
directory should have the following structure.
cold_start_recsys/data
├── movielens_1m
│ ├── train_df.csv
│ ├── val_df.csv
│ ├── test_df.csv
│ ├── user_dict.pkl // user info in one-hot/multi-hot
│ ├── item_dict.pkl // item info in one-hot/multi-hot
│ └── user_set_dict.pkl // record warm and cold user set
├── yelp_dataset
│ ├── train_df.csv
│ ├── val_df.csv
│ ├── test_df.csv
│ ├── user_dict.pkl
│ ├── item_dict.pkl
│ └── user_set_dict.pkl
└── amazon_cds
├── train_df.csv
├── val_df.csv
├── test_df.csv
├── user_dict.pkl
├── item_dict.pkl
└── user_set_dict.pkl
To train the proposed model and variants on MovieLens-1M under different settings, run the following:
Method | Command |
---|---|
CTML | python main.py --data movielens_1m --path_or_feat both |
CTML-path | python main.py --data movielens_1m --path_or_feat only_path |
CTML-feat | python main.py --data movielens_1m --path_or_feat only_feat |
Meta-testing will be automatically performed after every epoch of meta-training.
This code is modified based on ARML and MeLU. We thank the authors for their contributions.
If you find this repo useful in your research, please cite the following:
@article{peng2023clustered,
title={Clustered Task-Aware Meta-Learning by Learning From Learning Paths},
author={Peng, Danni and Pan, Sinno Jialin},
journal={IEEE Transactions on Pattern Analysis and Machine Intelligence},
year={2023},
publisher={IEEE}
}