2019-11-02 23:30:46 +08:00
2019-11-02 15:10:22 +08:00
2019-11-02 23:30:46 +08:00
2019-11-02 11:50:46 +08:00
2019-11-02 23:30:46 +08:00
2019-11-02 23:30:46 +08:00
2019-11-02 16:24:37 +08:00
2019-11-02 23:30:46 +08:00

Using attentive neural processes for forecasting power usage

This project uses Attentive Neural Process (ANP) on kaggle smart meter data.

This repository also includes a pytorch implementation that has been tweaked to be more flexible and stable. It may be usefull if you are looking for a ANP model in pytorch, and seems more stable than others available now (as of 2019-11-01).

Usage

  • clone this repository
  • see requirements.txt for requirements and version
  • Start and run the notebook smartmeters.ipynb

Data

Example outputs

Here the black dots are input data, the dotted line is the true data. The blue line is the prediction, and the blue shadow is the uncertainty.

Code

This is based on the code listed in the next section, with some changes. The most notable ones add stability, others are to make sure it can handle predicting into the future:

Changes for stability:

  • in eval mode, take mean of latent space, and mean of output isntead of sampling
  • use log_variance where possible (there is a flag to try without this)
    • and add a minimum bound to std (in log domain) to avoid mode collapse
  • use pytorch attention (which has dropout) instead of custom attention
  • use batchnorm and dropout on channel dimensions
  • use log_prob loss (no mseloss or BCELoss)
  • check and skip nonfinite values because for extreme inputs we can still get nan's

Changes for a predictive use case:

  • target points are always in the future, context is in the past
  • context and and targets are still sampled randomly during training

See also:

A list of projects I used as reference, is modified to make this one:

S
Description
implementing "recurrent attentive neural processes" to forecast power usage (w. LSTM baseline, MCDropout)
Readme
415 MiB
Languages
Jupyter Notebook 98.7%
Python 1.3%