Skip to content

Code for the paper "Backward importance sampling for online estimation of state space models"

Notifications You must be signed in to change notification settings

AMDonati/backward-IS

Repository files navigation

backward-IS

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".

package requirements

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

Code Structure

├── 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). 

Scripts to launch

1. preprocessing the weather dataset

python src/preprocessing/preprocess_weather_dataset.py

This saves the preprocessed data by default in the data/weather folder.

2.Training the deterministic RNN and generating a sequence of (states, observations) post-training

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
$DATA_PATH$ is the folder generated by the script 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").
$MODEL_PATH$ is the file "model.pt" contained the parent folder of $DATA_PATH$ generated by the script 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.

4. Post-processing the experiments

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.

About

Code for the paper "Backward importance sampling for online estimation of state space models"

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published