For a paper summary, please click on the youtube video below or click this link.
You can find the paper on ArXiv and OpenReview
if you want to cite our work, use:
@inproceedings{russwurm2024locationencoding,
title={Geographic Location Encoding with Spherical Harmonics and Sinusoidal Representation Networks},
author={Marc Rußwurm and Konstantin Klemmer and Esther Rolf and Robin Zbinden and Devis Tuia},
year={2024},
booktitle = {Proceedings of the International Conference on Learning Representations (ICLR)},
year = {2024},
url = {https://iclr.cc/virtual/2024/poster/18690}
}
Check this Colab Notebook to get started.
It
- clones the current repository
- installs the required packages
- trains Siren(SH) on the landocean dataset
- predicts the following map:
To use Spherical Harmonic embedding function with SirenNet, i.e., Siren(SH(lon,lat)), in your code, instantiate the LocationEncoder
class in locationencoder/locationencoder.py with Siren and Spherical Harmonics and a hyperparameter dict hparams
as follows:
from locationencoder import LocationEncoder
hparams = dict(
legendre_polys=10,
dim_hidden=64,
num_layers=2,
optimizer=dict(lr=1e-4, wd=1e-3),
num_classes=1
)
# Pytorch Lightning Model
model = LocationEncoder("sphericalharmonics", "siren", hparams)
# input longitude latitude in degrees
import torch
lonlat = torch.tensor([[51.9,5.6]], dtype=torch.float32)
# forward pass
output = model(lonlat)
We provide the analytically calculated Spherical Harmonic Basis Functions in locationencoder/pe/spherical_harmonics_ylm.py up to L=100 (! 40k lines, 7.7MB source code file). This file was generated with SymPy using locationencoder/pe/spherical_harmonics_generate_ylms.py.
To instantiate only the Spherical Harmonic positional encoder (no trainable weights) run
from locationencoder.pe import SphericalHarmonics
sh = SphericalHarmonics(legendre_polys=20)
# use lonlat coordinates, as above
embedded_lonlat = sh(lonlat)
Run the following lines to reproduce results from the paper. The hyperparameter are configured in hparams.yaml
.
Tables 1a (--dataset checkerboard
) and 1b (--dataset landoceandataset
) with
python experiments/exp_quantitative.py \
--dataset landoceandataset \
--nn linear fcnet siren \
--pe sphericalharmonics theory grid spherec spherecplus spherem spheremplus direct cartesian3d wrap
For Fig 4b) run
python experiments/exp_longitudinal_accuracy.py
For Fig 4a) run
python experiments/exp_resolution.py
This repository uses and relies on
- SymPy for the analytic calculation of spherical harmonic basis functions
- Pytorch Lightning for smooth model fitting
- the SirenNet implementation (Sitzmann et al., 2020) by Phil Wang/lucidrains