{"id":28440922,"url":"https://github.com/mic-dkfz/gpconvcnp","last_synced_at":"2025-06-29T00:31:14.243Z","repository":{"id":103284481,"uuid":"374694145","full_name":"MIC-DKFZ/gpconvcnp","owner":"MIC-DKFZ","description":"Code for \"GP-ConvCNP: Better Generalization for Convolutional Conditional Neural Processes on Time Series Data\"","archived":false,"fork":false,"pushed_at":"2021-06-11T13:27:36.000Z","size":37860,"stargazers_count":8,"open_issues_count":0,"forks_count":6,"subscribers_count":6,"default_branch":"master","last_synced_at":"2025-06-06T04:08:31.522Z","etag":null,"topics":["anp","attentive-neural-processes","convcnp","gaussian-processes","gp-convcnp","gpconvcnp","neural-processes","np","stochastic-processes","time-series"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/MIC-DKFZ.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null}},"created_at":"2021-06-07T14:24:16.000Z","updated_at":"2022-06-10T01:44:37.000Z","dependencies_parsed_at":null,"dependency_job_id":"1e11ed9e-005a-4e5b-96b5-471b3bec853c","html_url":"https://github.com/MIC-DKFZ/gpconvcnp","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/MIC-DKFZ/gpconvcnp","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MIC-DKFZ%2Fgpconvcnp","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MIC-DKFZ%2Fgpconvcnp/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MIC-DKFZ%2Fgpconvcnp/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MIC-DKFZ%2Fgpconvcnp/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/MIC-DKFZ","download_url":"https://codeload.github.com/MIC-DKFZ/gpconvcnp/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MIC-DKFZ%2Fgpconvcnp/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":262518035,"owners_count":23323298,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["anp","attentive-neural-processes","convcnp","gaussian-processes","gp-convcnp","gpconvcnp","neural-processes","np","stochastic-processes","time-series"],"created_at":"2025-06-06T04:08:11.842Z","updated_at":"2025-06-29T00:31:14.236Z","avatar_url":"https://github.com/MIC-DKFZ.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# GP-ConvCNP\n\nThis repository contains examples and pretrained models for our UAI 2021 paper called [\"GP-ConvCNP: Better Generalization for Convolutional Conditional Neural Processes on Time Series Data\"](https://arxiv.org/abs/2106.04967). You can explore examples interactively in the `examples.ipynb` (in the same folder as this README) Jupyter notebook and also re-run our experiments. Further instructions are below.\n\n## Installation\n\nIf you just want to look at the examples, it's enough to install the package in this repository via\n\n    pip install path/to/this/folder\n\nwhich will create a package called `neuralprocess` in your current Python environment. The package includes our GP-ConvCNP implementation, but also implementations of other major Neural Process variants (ConvCNP, NP, ANP), hence the name. We recommend you create a new virtualenv or conda environment before installing. If you also want to be able to run the experiments yourself, you need to install with the `experiment` option\n\n    pip install path/to/this/folder[experiment]\n\nAlternatively you can run\n\n    pip install -r requirements_experiment.txt\n\nafter the regular installation. You might receive an error that trixi requires a specific version of scikit-learn, which you can safely ignore.\n\n## Example Notebook\n\nThe notebook `examples.ipynb` allows you to create plots similar to the ones in the paper. Simply run\n\n    jupyter notebook\n\nfrom this folder (or above), open the notebook and follow the instructions inside.\n\n## Running the Experiments\n\nOur experiment script is part of the `neuralprocess` package and can be found at `neuralprocess/experiment/neuralprocessexperiment.py`. You will find that our experiment uses the PytochExperiment class from [trixi](https://trixi.readthedocs.io/en/develop/) for logging and configuration. This gives us a great deal of flexibility, but we will only list the relevant options to reproduce the experiments from the paper. You basically only need to run the following command\n\n    python neuralprocessexperiment.py LOG_DIR -m MODS\n\nThe modifications are defined at the top of the file. The default configuration will be a Neural Process, trained on samples from a GP with an RBF kernel. You can apply the following modifications:\n\n* `DETERMINISTICENCODER` adds a deterministic path to Neural Process. Required for Attentive Neural Processes.\n* `ATTENTION` will use an ANP instead of a NP. Requires the `DETERMINISTICENCODER` mod.\n* `CONVCNP` will use a ConvCNP instead of a NP.\n* `GPCONVCNP` will use a GP-ConvCNP instead of a NP. Requires the `CONVCNP` mod to be set.\n* `LEARNNOISE` makes sigma^2 in the GP learnable. This was used in the experiments in the paper.\n* `MATERNKERNEL` will train on functions from GP with a Matern-5/2 kernel.\n* `WEAKLYPERIODICKERNEL` will train on functions from a GP with a weakly periodic kernel as defined in the ConvCNP paper.\n* `STEP` will train on step functions\n* `FOURIER` will train on random Fourier series.\n* `LOTKAVOLTERRA` will train on population dynamics generated from Lotka-Volterra equations.\n* `TEMPERATURE` will train on temperature measurements taken from [here](https://www.kaggle.com/selfishgene/historical-hourly-weather-data).\n* `LONG` will double the number of training epochs.\n\nBeyond that you can modify any value in the configuration directly, including deeper levels. For example, if you have the `ATTENTION` option activated, but you only want to use 4 heads in the attention mechanism, you could add the flag `--modules_kwargs.attention.num_heads 4`. Other useful flags are\n\n* `-v` will log to Visdom. You need to start a Visdom server beforehand with `python -m visdom.server --port 8080`\n* `-ad` will generate a description for the experiment by looking at the difference to the default configuration. The description will be saved as part of the config in the logging directory you specify.\n\nTo give a more illustrative example, let's assume you want to run GP-ConvCNP on step functions with twice the default amount of epochs, but with a larger initial learning rate. You also want to run the tests at the end, but for some reason only those for prediction and reconstruction ability. The training should be logged to Visdom and you want an automatic description generated. Your command would look like this:\n\n    python neuralprocessexperiment.py LOG_DIR -v -ad -m STEP CONVCNP GPCONVCNP LONG --optimizer_kwargs.lr 1e-2 --test --test_diversity false\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmic-dkfz%2Fgpconvcnp","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmic-dkfz%2Fgpconvcnp","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmic-dkfz%2Fgpconvcnp/lists"}