Code for recreating the results in our ICLR 2020 paper.
Please visit my Homepage for more information.
This code contains two parts which are corresponding to two tasks in our paper:
spacegraph/
folder contains codes for recreating the evaluation results of POI type classification task: both location modeling and context modeling.
- Python 2.7+
- Torch 1.0.1+
- Other required packages are summarized in
spacegraph/requirements.txt
.
To set up the code for space2vec for POI Type classfication, run python spacegraph/setup.py
.
You can find the POI type classification dataset in spacegraph/data_collection/Place2Vec_center/
.
spacegraph/data_collection/Place2Vec_center/poi_type.json
: the POI type ID to POI type name;spacegraph/data_collection/Place2Vec_center/pointset.pkl
: the total list of POI beng considered in the form:(id, (X, Y), (Type1, Type2,...TypeM), training/validation/test)
where (X,Y) are projected coordinates of this POI;spacegraph/data_collection/Place2Vec_center/neighborgraphs_train.pkl
(neighborgraphs_validation.pkl or neighborgraphs_test.pkl): the neighboring POI graph structure for training/validation/test in the form:[CenterPT, [ContextPT1, ContextPT2, ..., ContextPTN], training/validation/test]
. CenterPT is the center POI id while ContextPTs are its nearby POI id. Note that for validation and test dataset, the center point corresponds to the POI withvalidation/test
inpointset.pkl
.
This code is implemented in Python 2.7
All codes about the POI type classification task are in spacegraph/spacegraph_codebase/
.
Location Modeling (See Section 5.1.1 and 5.1.2 in our ICLR 2020 paper)
You can train different models from different bash files in spacegraph/
(See Appendix A.1 in our ICLR 2020 paper):
direct
: runbash Place2Vec_2_enc_dec_global_naive.sh
.tile
: runbash Place2Vec_2_enc_dec_global_gridlookup.sh
.wrap
: runbash Place2Vec_2_enc_dec_global_aodha.sh
.rbf
: runbash Place2Vec_2_enc_dec_global_rbf.sh
.gird
: runbash Place2Vec_2_enc_dec_global_grid.sh
.theory
: runbash Place2Vec_2_enc_dec_global_theory.sh
.
Results:
- The trained model will be available in the directory you specified for
--model_dir
. - The log including the evaluation results will be available in the directory you specified for
--log_dir
.
Spatial Context Modeling (See Section 5.1.3 in our ICLR 2020 paper)
You can train different models from different bash files in spacegraph/
(See Appendix A.1 in our ICLR 2020 paper):
none
: runbash Place2Vec_2_enc_dec_none.sh
.direct
: runbash Place2Vec_2_enc_dec_naive.sh
.polar
: runbash Place2Vec_2_enc_dec_polar.sh
.tile
: runbash Place2Vec_2_enc_dec_gridlookup.sh
.polar_tile
: runbash Place2Vec_2_enc_dec_polargridlookup.sh
.wrap
: runbash Place2Vec_2_enc_dec_aodha.sh
.rbf
: runbash Place2Vec_2_enc_dec_rbf.sh
.scaled_rbf
: runbash Place2Vec_2_enc_dec_scaledrbf.sh
.gird
: runbash Place2Vec_2_enc_dec_grid.sh
.theory
: runbash Place2Vec_2_enc_dec_theory.sh
.
Results:
- The trained model will be available in the directory you specified for
--model_dir
. - The log including the evaluation results will be available in the directory you specified for
--log_dir
.
geo_prior/
folder contains codes for recreating the evaluation results of the geo-aware fine-grained image classification task in our ICLR 2020 paper.
These codes are modified from Mac Aodha et al.'s GitHub codebase in which we add multiple Space2Vec location encoder modules to capture the geographic priors information about images.
- Python 3.6+
- Torch 1.3.0+
- Other required packages are summarized in
geo_prior/requirements.txt
.
In order to obtain the data, please go to Mac Aodha et al.'s project website.
This code is implemented in Python 3.
geo_prior/geo_prior/
contains the main code for training and evaluating models (We use BirdSnap†dataset as an example):
geo_prior/geo_prior/train_geo_net.py
is used to train the location encoder model. Runpython3 train_geo_net.py
.geo_prior/geo_prior/run_evaluation.py
is used to evaluate the location encoder model by combining the pre-trained CNN features. Runpython3 run_evaluation.py
.
If you find our work useful in your research please consider citing our paper.
@inproceedings{space2vec_iclr2020,
title={Multi-Scale Representation Learning for Spatial Feature Distributions using Grid Cells},
author={Mai, Gengchen and Janowicz, Krzysztof and Yan, Bo and Zhu, Rui and Cai, Ling and Lao, Ni},
booktitle={The Eighth International Conference on Learning Representations},
year={2020},
organization={openreview}
}
If you want to use our code for image classification, please cite both our ICLR 2020 paper and Mac Aodha et al's ICCV paper:
@inproceedings{geo_priors_iccv19,
title = {{Presence-Only Geographical Priors for Fine-Grained Image Classification}},
author = {Mac Aodha, Oisin and Cole, Elijah and Perona, Pietro},
booktitle = {ICCV},
year = {2019}
}