File size: 1,719 Bytes
44706c2 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 | # Reproducing Experiments
Reproduce all figures from the paper.
For custom models, see the [optional section below](#running-your-memory-model).
## Train
Train a model and log to Weights & Biases (wandb). Replace `MEMORY_TYPE` with one of the supported models.
```bash
python train.py PQN_RNN --MEMORY_TYPE=my_rnn --PROJECT=my_project
```
Model weights will be saved locally after training.
## Observability Gap and Memory Bias
Download the run history from wandb and plot the gap/bias.
```python
python plotting/download_csv.py \
--entity wandb_entity \
--project=wandb_project_name \
--model-group-csv my_rnn.csv
python plotting/return_gap_bias.py \
--input-csv my_rnn.csv \
--output gap_bias.pdf
```
## Pixel Saliency
```python
python plotting/pixel_vis_pqn \
--model-path my_rnn_weight.pkl \
--env-name CartPoleEasy \
--memory_type my_rnn \
--output pixels.pdf
```
## Recall Density
```python
python plotting/density_analysis_pqn.py \
--model-dir model_weights_dir \
--out_dir your_recall_density_dir
python plotting/plot_density_summary.py \
--recall_density_dir your_recall_density_dir \
--output density.pdf
```
## Memory Contamination
```python
python plotting/noiseva.py \
--model-dir /path/to/checkpoints \
--memory-types my_rnn \
--env-names CartPoleEasy
```
## Running Your Memory Model
For a new a memory model, you must implement a memory model then register it.
Your model must expose two methods:
1. `__call__(self, recurrent_state, (obs, done)) -> recurrent_state, markov_state`
2. `initialize_carry(self) -> recurrent_state`
Consult the [`memax`](https://github.com/smorad/memax) library for exact registration details. |