Implementation of

Our goal is to generate samples which are both realistic and extreme, based on any user-specified extremeness criteria
(in this case, high total rainfall). Left: Existing GAN-based approaches generate typical rainfall patterns, which have low (green)
to moderate (red) rainfall. Right: Extreme samples generated by our approach have extreme (violet) rainfall, and realistic spatial
patterns resembling that of real floods.

Getting Started


This code has been tested on Debian GNU/Linux 9 with a 12GB Nvidia GeForce RTX 2080 Ti GPU, CUDA Version 10.2 and PyTorch 1.5.

Reproducing the Experiments

The first step is to get the data. We have prepared a script to download precipitation data from The data downloaded is for the duration 2010 to 2016 as mentioned in the paper.


Now, we can train a DCGAN Baseline on this data.


Distribution Shifting on this DCGAN can be performed using


Finally, we can train ExGAN on the distribution shifted dataset.


The training of ExGAN and DCGAN can be monitored using TensorBoard.

tensorboard --logdir [DCGANEXGAN]

Evaluation and Visualizing the Results

Generate samples from DCGAN of different extremeness probabilities, and mark the time taken in sampling.


Similarly, Generate samples from ExGAN of different extremeness probabilities, and mark the time taken in sampling.


We provide to calculate the FID score, as described in the paper, on the trained models.
We also provide, and to evaluate DCGAN and ExGAN on their Reconstruction Loss
Note that, both of these metrics are calculated on a test set. can be used to curate the test set for the duration described in the paper.

The python file,, contains the code for plotting rainfall maps like the figures included in the paper. Note that this requires the Basemap library from matplotlib.

We also provide an IPython notebook, EVT_Analysis.ipynb to play with and visualize the effect of different thresholds for the Peaks over
Threshold approach.


If you use this code for your research, please consider citing our arXiv preprint

    title={ExGAN: Adversarial Generation of Extreme Samples},
    author={Siddharth Bhatia and Arjit Jain and Bryan Hooi},

Read More

ترك الرد

من فضلك ادخل تعليقك
من فضلك ادخل اسمك هنا