The github repository (https://github.com/AMDonati/backward-IS) provides the source code for the section 5.1 (Recurrent Neural Networks) of the paper "Backward importance sampling for online estimation of state space models".
The packages required to run the code are provided in the file requirements.txt
.
You can install them (preferably in a virtual environment or in a conda environment) using the command: pip install -r requirements.txt
├── output
|
├── data
|
└── src
└── models # package for stochastic RNNs (LSTM not fully implemented.)
└── smc: # package for SMC algorithms
└── BootstrapFilter.py # class implementing a bootstrap filter. Main attributes:
└── BackwardIS_smoother.py # script implementing the Backward Importance Sampling Smoother and the Poor Man's Smoother.
└── train: # scripts to train the deterministic RNN
└── preprocessing # preprocess weather dataset
└── data_provider # class dataset with all dataset components
└── train.py: main script launching the training of the deterministic RNN and the generation of a sequence observations
└── estimate.py: main script launching the state estimation process for a given sequence of (states, observations).
python src/preprocessing/preprocess_weather_dataset.py
This saves the preprocessed data by default in the
data/weather
folder.
python src/train.py -output_path "output/RNN_weather" -max_samples 20000 -hidden_size 64 -ep 15 -bs 64 -seq_len 201 -sigma_init 0.1 -sigma_y 0.1 -sigma_h 0.1
3.Launching the state estimation process for a given sequence of (states, observations) (backward IS and PMS smoothers)
python src/estimate.py -data_path $DATA_PATH -model_path $MODEL_PATH$ -sigma_init 0.1 -sigma_h 0.1 -sigma_y 0.1
src/train.py
contening the sequence (states, observations) under 2 files observations.npy
and states.npy
(ex: "output/RNN_weather/RNN_h64_ep15_bs64_maxsamples20000/20210416-225828/observations_samples1_seqlen201_sigmainit0.1_sigmah0.1_sigmay0.1").
src/train.py
(ex: "output/RNN_weather/RNN_h64_ep15_bs64_maxsamples20000/20210416-225828/model.pt").
Examples of slurm scripts lauching in parallel multiple runs of src/estimate.py
are included in the src/sh
folder.
python src/preprocessing/post_treatment.py -folder_path $FOLDER_PATH
$FOLDER_PATH is a folder path containing multiple runs of a same src/estimate.py
configuration.
See 'src/sh' folder for example of post-treatment scripts.