Skip to content

IamHuijben/SOM-CPC

Repository files navigation

SOM-CPC

This repository contains all code to reproduce the SOM-CPC paper.

Dependencies:

Download the anaconda package (https://www.anaconda.com/) and the somperf library (https://github.com/FlorentF9/SOMperf).

In the anaconda prompt run:

conda create -n SOM_CPC_env python==3.7.10 pip install torch==1.9.1+cu111 -f https://download.pytorch.org/whl/torch_stable.html pip install -r SOM_CPC_requirements.txt

Go to the folder where you stored the somperf library folders and run: python setup.py install Then activate the environment with: conda activate SOM_CPC_env

Running an experiment

Data processing

The physiological and audio experiments start with running preprocessing/physiological_data_main.py or preprocessing/audio_main.py scripts to acquire the data in the right format. Both datasets first need to be downloaded locally to run these scripts. The toy experiments do not need preprocessing anymore, as we published the generated dataset in the data/random_walk_freq_sinusoids_processed folder. However, to rerun or change preprocessing, you can use preprocessing/synthetic_data_main.py

Running a model

After having the data in place, you can train one of the different models from the experiments/<model_type>/<experiment_type>/main.py files for the different models and experiments. The trained model will automatically be saved in your working directory. Note that training the SOM, supervised classifier, or running the fit_pca_kmeans.py script require an already trained CPC model to run on top of.

All model folders contain experiment_specific.yml files that specify all the settings as used in the paper.

Running inference

To run inference on any of the models that include a SOM, you can run the scripts in the inference/ folder. To evaluate performance with K-means (and PCA), you can use the fit_pca_kmeans.py script in the experiment folder directly, as it fits PCA/K-means on the training set and directly performs inference on the test set.

Citation

Please cite the following paper if you find this code useful in your work:

@inproceedings{huijben2023,
  title={Som-cpc: Unsupervised Contrastive Learning with Self-Organizing Maps for Structured Representations of High-Rate Time Series},
  author={Huijben, Iris AM and Nijdam, Arthur Andreas and Overeem, Sebastiaan and Van Gilst, Merel M and Van Sloun, Ruud},
  booktitle={International Conference on Machine Learning},
  pages={14132--14152},
  year={2023},
  organization={PMLR}
}

About

This repository contains all code to reproduce the SOM-CPC paper published at ICML 2023

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages