Showing preview only (630K chars total). Download the full file or copy to clipboard to get everything.
Repository: BoyuanChen/neural-state-variables
Branch: main
Commit: 10483d93ac8c
Files: 227
Total size: 570.0 KB
Directory structure:
gitextract_ivg233ui/
├── .gitignore
├── LICENSE
├── README.md
├── analysis/
│ ├── README.md
│ ├── eval_intrinsic_dimension.py
│ ├── eval_phys_data.py
│ ├── eval_phys_double_pendulum/
│ │ ├── __init__.py
│ │ ├── angle_estimator.py
│ │ └── physics_estimator.py
│ ├── eval_phys_elastic_pendulum/
│ │ ├── __init__.py
│ │ ├── angle_estimator.py
│ │ └── physics_estimator.py
│ ├── eval_phys_long_term_pred.py
│ ├── eval_phys_single_pendulum/
│ │ ├── __init__.py
│ │ ├── angle_estimator.py
│ │ └── physics_estimator.py
│ ├── eval_regression.py
│ ├── intrinsic_dimension_estimation/
│ │ ├── __init__.py
│ │ ├── matlab_codes/
│ │ │ ├── DANCo.m
│ │ │ ├── DANCoFit.m
│ │ │ ├── DANCoTrain.m
│ │ │ ├── DANCo_fits.mat
│ │ │ ├── GetDim.mexw64
│ │ │ ├── KNN.m
│ │ │ ├── MLE.m
│ │ │ ├── MiND_KL.m
│ │ │ ├── MiND_ML.m
│ │ │ ├── demo_idEstimation.m
│ │ │ ├── gauss.m
│ │ │ ├── html/
│ │ │ │ └── demo_idEstimation.html
│ │ │ ├── linSubspSpanOrthonormalize.m
│ │ │ ├── parseParamsNamed.m
│ │ │ ├── private/
│ │ │ │ ├── DANCo_estimateKL.m
│ │ │ │ └── DANCo_statistics.m
│ │ │ └── randsphere.m
│ │ └── methods.py
│ └── latent_regression/
│ ├── __init__.py
│ └── regressors.py
├── configs/
│ ├── air_dancer/
│ │ ├── latentpred/
│ │ │ ├── config1.yaml
│ │ │ ├── config2.yaml
│ │ │ └── config3.yaml
│ │ ├── model/
│ │ │ ├── config1.yaml
│ │ │ ├── config2.yaml
│ │ │ └── config3.yaml
│ │ ├── model64/
│ │ │ ├── config1.yaml
│ │ │ ├── config2.yaml
│ │ │ └── config3.yaml
│ │ └── refine64/
│ │ ├── config1.yaml
│ │ ├── config2.yaml
│ │ └── config3.yaml
│ ├── circular_motion/
│ │ ├── model/
│ │ │ ├── config1.yaml
│ │ │ ├── config2.yaml
│ │ │ └── config3.yaml
│ │ ├── model64/
│ │ │ ├── config1.yaml
│ │ │ ├── config2.yaml
│ │ │ └── config3.yaml
│ │ └── refine64/
│ │ ├── config1.yaml
│ │ ├── config2.yaml
│ │ └── config3.yaml
│ ├── double_pendulum/
│ │ ├── latentpred/
│ │ │ ├── config1.yaml
│ │ │ ├── config2.yaml
│ │ │ └── config3.yaml
│ │ ├── model/
│ │ │ ├── config1.yaml
│ │ │ ├── config2.yaml
│ │ │ └── config3.yaml
│ │ ├── model64/
│ │ │ ├── config1.yaml
│ │ │ ├── config2.yaml
│ │ │ └── config3.yaml
│ │ └── refine64/
│ │ ├── config1.yaml
│ │ ├── config2.yaml
│ │ └── config3.yaml
│ ├── elastic_pendulum/
│ │ ├── latentpred/
│ │ │ ├── config1.yaml
│ │ │ ├── config2.yaml
│ │ │ └── config3.yaml
│ │ ├── model/
│ │ │ ├── config1.yaml
│ │ │ ├── config2.yaml
│ │ │ └── config3.yaml
│ │ ├── model64/
│ │ │ ├── config1.yaml
│ │ │ ├── config2.yaml
│ │ │ └── config3.yaml
│ │ └── refine64/
│ │ ├── config1.yaml
│ │ ├── config2.yaml
│ │ └── config3.yaml
│ ├── fire/
│ │ ├── latentpred/
│ │ │ ├── config1.yaml
│ │ │ ├── config2.yaml
│ │ │ └── config3.yaml
│ │ ├── model/
│ │ │ ├── config1.yaml
│ │ │ ├── config2.yaml
│ │ │ └── config3.yaml
│ │ ├── model64/
│ │ │ ├── config1.yaml
│ │ │ ├── config2.yaml
│ │ │ └── config3.yaml
│ │ └── refine64/
│ │ ├── config1.yaml
│ │ ├── config2.yaml
│ │ └── config3.yaml
│ ├── lava_lamp/
│ │ ├── latentpred/
│ │ │ ├── config1.yaml
│ │ │ ├── config2.yaml
│ │ │ └── config3.yaml
│ │ ├── model/
│ │ │ ├── config1.yaml
│ │ │ ├── config2.yaml
│ │ │ └── config3.yaml
│ │ ├── model64/
│ │ │ ├── config1.yaml
│ │ │ ├── config2.yaml
│ │ │ └── config3.yaml
│ │ └── refine64/
│ │ ├── config1.yaml
│ │ ├── config2.yaml
│ │ └── config3.yaml
│ ├── reaction_diffusion/
│ │ ├── latentpred/
│ │ │ ├── config1.yaml
│ │ │ ├── config2.yaml
│ │ │ └── config3.yaml
│ │ ├── model/
│ │ │ ├── config1.yaml
│ │ │ ├── config2.yaml
│ │ │ └── config3.yaml
│ │ ├── model64/
│ │ │ ├── config1.yaml
│ │ │ ├── config2.yaml
│ │ │ └── config3.yaml
│ │ └── refine64/
│ │ ├── config1.yaml
│ │ ├── config2.yaml
│ │ └── config3.yaml
│ ├── single_pendulum/
│ │ ├── latentpred/
│ │ │ ├── config1.yaml
│ │ │ ├── config2.yaml
│ │ │ └── config3.yaml
│ │ ├── model/
│ │ │ ├── config1.yaml
│ │ │ ├── config2.yaml
│ │ │ └── config3.yaml
│ │ ├── model64/
│ │ │ ├── config1.yaml
│ │ │ ├── config2.yaml
│ │ │ └── config3.yaml
│ │ └── refine64/
│ │ ├── config1.yaml
│ │ ├── config2.yaml
│ │ └── config3.yaml
│ ├── swingstick_magnetic/
│ │ ├── model/
│ │ │ ├── config1.yaml
│ │ │ ├── config2.yaml
│ │ │ └── config3.yaml
│ │ ├── model64/
│ │ │ ├── config1.yaml
│ │ │ ├── config2.yaml
│ │ │ └── config3.yaml
│ │ └── refine64/
│ │ ├── config1.yaml
│ │ ├── config2.yaml
│ │ └── config3.yaml
│ └── swingstick_non_magnetic/
│ ├── latentpred/
│ │ ├── config1.yaml
│ │ ├── config2.yaml
│ │ └── config3.yaml
│ ├── model/
│ │ ├── config1.yaml
│ │ ├── config2.yaml
│ │ └── config3.yaml
│ ├── model64/
│ │ ├── config1.yaml
│ │ ├── config2.yaml
│ │ └── config3.yaml
│ └── refine64/
│ ├── config1.yaml
│ ├── config2.yaml
│ └── config3.yaml
├── datainfo/
│ ├── README.md
│ ├── air_dancer/
│ │ ├── data_split_dict_1.json
│ │ ├── data_split_dict_2.json
│ │ └── data_split_dict_3.json
│ ├── circular_motion/
│ │ ├── data_split_dict_1.json
│ │ ├── data_split_dict_2.json
│ │ └── data_split_dict_3.json
│ ├── collect/
│ │ ├── circular_motion/
│ │ │ └── make_data.py
│ │ ├── double_pendulum/
│ │ │ ├── README.md
│ │ │ ├── convert_video.py
│ │ │ ├── equalize_background.py
│ │ │ └── split_data.py
│ │ ├── elastic_pendulum/
│ │ │ └── make_data.py
│ │ ├── fire/
│ │ │ └── split_data.py
│ │ ├── lava_lamp/
│ │ │ └── split_data.py
│ │ ├── reaction_diffusion/
│ │ │ ├── make_data.py
│ │ │ ├── reaction_diffusion.m
│ │ │ └── reaction_diffusion_rhs.m
│ │ ├── single_pendulum/
│ │ │ └── make_data.py
│ │ └── utils/
│ │ └── sort_vids.py
│ ├── double_pendulum/
│ │ ├── data_split_dict_1.json
│ │ ├── data_split_dict_2.json
│ │ └── data_split_dict_3.json
│ ├── elastic_pendulum/
│ │ ├── data_split_dict_1.json
│ │ ├── data_split_dict_2.json
│ │ └── data_split_dict_3.json
│ ├── fire/
│ │ ├── data_split_dict_1.json
│ │ ├── data_split_dict_2.json
│ │ └── data_split_dict_3.json
│ ├── lava_lamp/
│ │ ├── data_split_dict_1.json
│ │ ├── data_split_dict_2.json
│ │ └── data_split_dict_3.json
│ ├── reaction_diffusion/
│ │ ├── data_split_dict_1.json
│ │ ├── data_split_dict_2.json
│ │ └── data_split_dict_3.json
│ ├── single_pendulum/
│ │ ├── data_split_dict_1.json
│ │ ├── data_split_dict_2.json
│ │ └── data_split_dict_3.json
│ ├── swingstick_magnetic/
│ │ ├── data_split_dict_1.json
│ │ ├── data_split_dict_2.json
│ │ └── data_split_dict_3.json
│ └── swingstick_non_magnetic/
│ ├── data_split_dict_1.json
│ ├── data_split_dict_2.json
│ └── data_split_dict_3.json
├── dataset.py
├── eval.py
├── main.py
├── model_utils.py
├── models.py
├── models_latentpred.py
├── pred.py
├── requirements.txt
├── scripts/
│ ├── encoder_decoder_64_eval.sh
│ ├── encoder_decoder_64_eval_gather.sh
│ ├── encoder_decoder_64_long_term_model_rollout.sh
│ ├── encoder_decoder_64_long_term_model_rollout_perturb_all.sh
│ ├── encoder_decoder_64_train.sh
│ ├── encoder_decoder_estimate_dimension.sh
│ ├── encoder_decoder_eval.sh
│ ├── encoder_decoder_eval_gather.sh
│ ├── encoder_decoder_long_term_model_rollout.sh
│ ├── encoder_decoder_long_term_model_rollout_perturb_all.sh
│ ├── encoder_decoder_train.sh
│ ├── latentpred_train.sh
│ ├── long_term_eval_stability.sh
│ ├── long_term_eval_stability_hybrid.sh
│ ├── refine_64_eval.sh
│ ├── refine_64_eval_gather.sh
│ ├── refine_64_long_term_hybrid_rollout.sh
│ ├── refine_64_long_term_model_rollout.sh
│ ├── refine_64_long_term_model_rollout_perturb_all.sh
│ └── refine_64_train.sh
├── stability.py
└── utils/
├── common.py
└── dimension.py
================================================
FILE CONTENTS
================================================
================================================
FILE: .gitignore
================================================
*.*~
*~
__pycache__
scripts/logs_*
================================================
FILE: LICENSE
================================================
MIT License
Copyright (c) 2021 Boyuan Chen
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
================================================
FILE: README.md
================================================
# Discovering State Variables Hidden in Experimental Data
[Boyuan Chen](http://boyuanchen.com/),
[Kuang Huang](https://cm3.apam.columbia.edu/people/kuang-huang),
[Sunand Raghupathi](https://www.linkedin.com/in/sunand-raghupathi?trk=public_profile_browsemap),
[Ishaan Chandratreya](https://www.linkedin.com/in/ishaan-chandratreya-546aa6141),
[Qiang Du](https://www.engineering.columbia.edu/faculty/qiang-du),
[Hod Lipson](https://www.hodlipson.com/)
<br>
Columbia University
<br>
### [Project Website](https://www.cs.columbia.edu/~bchen/neural-state-variables) | [Video](https://youtu.be/KWHXchlJzSw) | [Paper](http://arxiv.org/abs/2112.10755)
## Overview
This repo contains the PyTorch implementation for paper "Discovering State Variables Hidden in Experimental Data".

## Citation
If you find our paper or codebase helpful, please consider citing:
```
@article{chen2021discover,
title={Discovering State Variables Hidden in Experimental Data},
author={Chen, Boyuan and Huang, Kuang and Raghupathi, Sunand and Chandratreya, Ishaan and Du, Qiang and Lipson, Hod},
journal={arXiv preprint arXiv:2112.10755},
year={2021}
}
```
## Content
- [Installation](#installation)
- [Logging](#logging)
- [Data Preparation](#data-preparation)
- [Training and Testing](#training-and-testing)
- [Intrinsic Dimension Estimation](#intrinsic-dimension-estimation)
- [Long-term Prediction and Stability Evaluation](#long-term-prediction-and-stability-evaluation)
- [Evaluation and Analysis](#evaluation-analysis)
- [License](#license)
## Installation
The installation has been test on Ubuntu 18.04 with CUDA 11.0. All the experiments are performed on one GeForce RTX 2080 Ti Nvidia GPU.
Create a python virtual environment and install the dependencies.
```
virtualenv -p /usr/bin/python3.6 env3.6
source env3.6/bin/activate
pip install -r requirements.txt
```
**Note**: You may need to install Matlab on your computer to use some of the data collectors and intrinsic dimension estimation algorithms.
## Logingg
We first introduce the naming convention of the saved files so that it is clear what will be saved and where they will be saved.
1. Log folder naming convention:
```
logs_{dataset}_{model_name}_{seed}
```
2. Inside the logs folder, the structure and contents are:
```
\logs_{dataset}_{model_name}_{seed}
\lightning_logs
\checkpoints [saved checkpoint]
\version_0 [training stats]
\version_1 [testing stats]
\predictions [testing predicted images]
\prediction_long_term [long term predicted images]
\variables [file id and latent vectors on testing data]
\variables_train [file id and latent vectors on training data]
\variables_val [file id and latent vectors on validation data]
```
## Data Preparation
We provide nine datasets with their own download links below.
- [circular_motion](https://drive.google.com/file/d/19DFYqh08B2L-YX_bTmpmxYu2jpARqoUA/view?usp=sharing) (circular motion system)
- [reaction_diffusion](https://drive.google.com/file/d/1LOqpB0l86lELEegX5sV9NwHkGKeHoaTN/view?usp=sharing) (reaction diffusion system)
- [single_pendulum](https://drive.google.com/file/d/1rw6vrVcV3KCIaVVwKMMhoZ9Jph5u-Zdf/view?usp=sharing) (single pendulum system)
- [double_pendulum](https://drive.google.com/file/d/1QEtk4JjnRysIEjtkZIKBjACu_IiTAdX6/view?usp=sharing) (rigid double pendulum system)
- [elastic_pendulum](https://drive.google.com/file/d/1Y8vzawQZhzPHp6cpLFuyM2LHuhgLjH9H/view?usp=sharing) (elastic double pendulum system)
- [swingstick_non_magnetic](https://drive.google.com/file/d/1BfeGW4XTFyGdyBO0G_YnSnRyJGu2WRnc/view?usp=sharing) (swing stick system)
- [air_dancer](https://drive.google.com/file/d/163KvwevY1fnDnI6WiWpc5Zaz-WWwPaAS/view?usp=sharing) (air dancer system)
- [lava_lamp](https://drive.google.com/file/d/1R-I2CZaJLe2D4H818-n25l54R0pbKQfo/view?usp=sharing) (lava lamp system)
- [fire](https://drive.google.com/file/d/1OIH6SalwPyD_lkXBLZq6bzmKfrp-xhrI/view?usp=sharing) (fire system)
Save the downloaded dataset as ```data/{dataset_name}```, where ```data``` is your customized dataset folder. **Please make sure that ```data``` is an absolute path and you need to change the ```data_filepath``` item in the ```config.yaml``` files in ```configs``` to specify your customized dataset folder**.
Please refer to the [datainfo](datainfo) folder for more details about data structure and dataset collection process.
## Training and Testing
Our approach involves three models:
- dynamics predictive model (encoder-decoder / encoder-decoder-64)
- latent reconstruction model (refine-64)
- neural latent dynamics model (latentpred)
1. Navigate to the scripts folder
```
cd scripts
```
2. Train the dynamics predictive model (encoder-decoder and encoder-decoder-64) and then save the high-dimensional latent vectors from the testing data.
```
./encoder_decoder_64_train.sh {dataset_name} {gpu no.}
./encoder_decoder_train.sh {dataset_name} {gpu no.}
./encoder_decoder_64_eval.sh {dataset_name} {gpu no.}
./encoder_decoder_eval.sh {dataset_name} {gpu no.}
```
3. Run forward pass on the trained encoder-deocer model and encoder-decoder-64 model to save the high-dimensional latent vectors from the training and validation data. The saved latent vectors will be used as the training and validataion data for training and validating the latent reconstruction model.
```
./encoder_decoder_eval_gather.sh {dataset_name} {gpu no.}
./encoder_decoder_64_eval_gather.sh {dataset_name} {gpu no.}
```
4. Before you proceed this step, please refer to the next section to obtain the system's intrinsic dimension and then come back to this step.
Train the latent reconstruction model (refine-64) with the saved 64-dim latent vectors from previous steps. Then save the obtained Neural State Variables from both training and testing data.
```
./refine_64_train.sh {dataset_name} {gpu no.}
./refine_64_eval.sh {dataset_name} {gpu no.}
./refine_64_eval_gather.sh {dataset_name} {gpu no.}
```
5. Train the neural latent dynamics model (latentpred) with the trained models from previous steps.
```
./latentpred_train.sh single_pendulum {dataset_name} {gpu no.}
```
## Intrinsic Dimension Estimation
With the trained dynamics predictive model, our approach provides subroutines to estimate the system's intrinsic dimension (ID) using manifold learning algorithms. The estimated intrinsic dimension will be used to decide the number of Neural State Variables and to design the latent reconstruction model. Only after this step you can proceed to train the latent reconstruction model to obtain Neural State Variables.
1. Navigate to the scripts folder
```
cd scripts
```
which is the default directory saving all models' log folders.
2. Estimate the intrinsic dimension from the saved latent vectors of the encoder-decoder models for all random seeds.
```
./encoder_decoder_estimate_dimension.sh {dataset_name}
```
3. Calculate the final intrinsic dimension estimated values (mean and standard deviation).
```
python ../utils/dimension.py {dataset_name}
```
## Long-term Prediction and Stability Evaluation
With all above trained models, our approach offers system long-term predictions through model rollouts as well as stability evaluation of the long-term predictions.
1. Navigate to the scripts folder
```
cd scripts
```
2. Long-term prediction with single model rollouts.
```
./encoder_decoder_long_term_model_rollout.sh {dataset_name} {gpu no.}
./encoder_decoder_64_long_term_model_rollout.sh {dataset_name} {gpu no.}
./refine_64_long_term_model_rollout.sh {dataset_name} {gpu no.}
```
The predictions will be saved in the ```prediction_long_term``` subfolder under the model's log folder.
3. Long-term prediction with hybrid model rollouts.
```
./refine_64_long_term_hybrid_rollout.sh {dataset_name} {gpu no.} {step}
```
where ```step``` is the number of model rollouts via 64-dim latent vectors before a model rollout via Neural State Variables.
The predictions will be saved in the ```prediction_long_term``` subfolder under the refine-64 model's log folder.
4. Long-term prediction with single model rollouts from perturbed initial frames.
```
./encoder_decoder_long_term_model_rollout_perturb_all.sh {dataset_name} {gpu no.}
./encoder_decoder_64_long_term_model_rollout_perturb_all.sh {dataset_name} {gpu no.}
./refine_64_long_term_model_rollout_perturb_all.sh {dataset_name} {gpu no.}
```
The predictions will be saved in the ```prediction_long_term``` subfolder under the model's log folder.
3. Stability evaluation on long-term predictions with single model rollouts
```
./long_term_eval_stability.sh {dataset_name} {gpu no.}
```
and on long-term predictions with hybrid model rollouts
```
./long_term_eval_stability_hybrid.sh {dataset_name} {gpu no.} {step}
```
where ```step``` is as mentioned above for hybrid model rollouts.
The evaluated latent space errors measuring the prediction stability will be saved in the ```stability.npy``` file under the respective ```prediction_long_term``` folders.
**Note**: The default long-term prediction length is 60 (in frames). You will need to modify the scripts if you want to use a different prediction length.
## Evaluation and Analysis
Please refer to the [analysis](analysis) folder for detailed instructions for physical evaluation and analysis.
## License
This repository is released under the MIT license. See [LICENSE](LICENSE) for additional details.
================================================
FILE: analysis/README.md
================================================
## Physics Evaluation on Known Systems
We provide physics evaluation algorithms extracting physical variables including positions, velocities, and energies from ground truth and predicted frames for the three known systems (single pendulum, rigid double pendulum, and elastic double pendulum).
You can use these algorithms to evaluate the physical accuracy of predictions.
1. Evaluate physical variables from ground truth data.
```
python eval_phys_data.py dataset_name data_filepath
```
The ```dataset_name``` can be single_pendulum, double_pendulum, or elastic_pendulum. The ```data_filepath``` is the respective data filepath, e.g., ```data/single_pendulum``` where ```data``` is your customized data folder. The results will be saved in the ```phys_vars.npy``` file under ```data_filepath```.
2. Evaluate physical variables from long-term predictions via model rollouts and compute physical errors between ground truth data and the predictions.
```
python eval_phys_long_term_pred.py config_filepath pred_save_path
```
The ```config_filepath``` is the model configuration filepath, e.g., ```../configs/single_pendulum/model/config1.yaml```. The ```pred_save_path``` is the path to the predicted images, e.g., ```../scripts/logs_single_pendulum_encoder-decoder_1/prediction_long_term/model_rollout/```. The results will be saved in the ```phys_vars.npy```, ```phys_error.npy```, and ```pixel_error.npy``` files under ```pred_save_path```.
**Note**: ```eval_phys_single_pendulum```, ```eval_phys_double_pendulum```, and ```eval_phys_elastic_pendulum``` are helper packages for evaluating physical variables for the above command lines.
## Intrinsic Dimension Estimation
1. Navigate to the scripts folder
```
cd ../scripts
```
which is the default directory saving all models' log folders.
2. Estimate intrinsic dimension from model latent vectors using the Levina-Bickel method
```
python ../analysis/eval_intrinsic_dimension.py {config_filepath} model-latent NA
```
or using all methods (Levina-Bickel, MiND-ML, MiND-KL, Hein, CD)
```
python ../analysis/eval_intrinsic_dimension.py {config_filepath} model-latent all-methods
```
The ```config_filepath``` is the model configuration filepath, e.g., ```../configs/single_pendulum/model/config1.yaml```. The results will be saved in the ```intrinsic_dimension.npy``` file (using the Levina-Bickel method) or the ```intrinsic_dimension_all_methods.npy``` file (using all methods) in the ```variables``` subfolder under the model's log folder.
3. Estimate intrinsic dimension from raw data (image pairs) using the Levina-Bickel method
```
python ../analysis/eval_intrinsic_dimension.py {config_filepath} data-image NA
```
or using all methods (Levina-Bickel, MiND-ML, MiND-KL, Hein, CD)
```
python ../analysis/eval_intrinsic_dimension.py {config_filepath} data-image all-methods
```
The ```config_filepath``` is the model configuration filepath, e.g., ```../configs/single_pendulum/model/config1.yaml```. The results will be saved in the ```intrinsic_dimension_image.npy``` file (using the Levina-Bickel method) or the ```intrinsic_dimension_image_all_methods.npy``` file (using all methods) in the ```variables``` subfolder under the model's log folder. Here the model configuration only provides data filepath and test video ids.
**Note**: ```intrinsic_dimension_estimation``` are helper packages providing various intrinsic dimension estimation methods. When choosing the ```all-methods``` option, the MATLAB and MATLAB Engine API for Python should be installed on the machine, see instructions [here](https://www.mathworks.com/help/matlab/matlab_external/install-the-matlab-engine-for-python.html).
References of MATLAB codes:
```
[1] Gabriele Lombardi (2021). Intrinsic dimensionality estimation techniques (https://www.mathworks.com/matlabcentral/fileexchange/40112-intrinsic-dimensionality-estimation-techniques), MATLAB Central File Exchange. Retrieved October 21, 2021.
[2] M. Hein and J.-Y. Audibert, Intrinsic dimensionality estimation of submanifolds in Euclidean space, Proceedings of the 22nd Internatical Conference on Machine Learning (https://www.ml.uni-saarland.de/code/IntDim/IntDim.htm).
```
## Latent Space Regression on Known Systems
1. Navigate to the scripts folder
```
cd ../scripts
```
which is the default directory saving all models' log folders.
2. Regress physical variables from the model latent vectors
```
python ../analysis/eval_regression.py config_filepath NA
```
or from the first ```num_components``` principal components of the model latent vectors
```
python ../analysis/eval_regression.py config_filepath num_components
```
The ```config_filepath``` is the model configuration filepath, e.g., ```../configs/single_pendulum/model/config1.yaml```. The results will be saved in the ```regression_results.npy``` file (with model latent vectors) or the ```regression_results_pca_{num_components}.npy``` file (with first few principal components of model latent vectors) in the ```variables``` subfolder under the model's log folder.
================================================
FILE: analysis/eval_intrinsic_dimension.py
================================================
import numpy as np
import os
import sys
from tqdm import tqdm
from PIL import Image
import json
import yaml
import pprint
from munch import munchify
from intrinsic_dimension_estimation import ID_Estimator
def load_config(filepath):
with open(filepath, 'r') as stream:
try:
trainer_params = yaml.safe_load(stream)
return trainer_params
except yaml.YAMLError as exc:
print(exc)
def remove_duplicates(X):
return np.unique(X, axis=0)
def eval_id_latent(vars_filepath, if_refine, if_all_methods):
if if_refine:
latent = np.load(os.path.join(vars_filepath, 'refine_latent.npy'))
else:
latent = np.load(os.path.join(vars_filepath, 'latent.npy'))
print(f'Number of samples: {latent.shape[0]}; Latent dimension: {latent.shape[1]}')
latent = remove_duplicates(latent)
print(f'Number of samples (duplicates removed): {latent.shape[0]}')
estimator = ID_Estimator()
k_list = (latent.shape[0] * np.linspace(0.008, 0.016, 5)).astype('int')
print(f'List of numbers of nearest neighbors: {k_list}')
if if_all_methods:
dims = estimator.fit_all_methods(latent, k_list)
np.save(os.path.join(vars_filepath, 'intrinsic_dimension_all_methods.npy'), dims)
else:
dims = estimator.fit(latent, k_list)
np.save(os.path.join(vars_filepath, 'intrinsic_dimension.npy'), dims)
def eval_id_image(data_filepath, test_vid_ids, vars_filepath, if_all_methods):
print('Reading image data...')
data = []
for p_vid_idx in tqdm(test_vid_ids):
vid_filepath = os.path.join(data_filepath, str(p_vid_idx))
num_frames = len(os.listdir(vid_filepath))
suf = os.listdir(vid_filepath)[0].split('.')[-1]
for p_frame in range(num_frames - 3):
img_list = []
for p in range(2):
img = Image.open(os.path.join(vid_filepath, str(p_frame + p) + '.' + suf))
img = img.resize((128, 128))
img = np.array(img) / 255.0
img_list.append(img)
data_p = np.concatenate(img_list, 1).reshape([1, -1])
data.append(data_p)
data = np.concatenate(data, 0)
print(f'Number of samples: {data.shape[0]}; Image dimension (flattened): {data.shape[1]}')
data = remove_duplicates(data)
print(f'Number of samples (duplicates removed): {data.shape[0]}')
estimator = ID_Estimator()
k_list = (data.shape[0] * np.linspace(0.008, 0.016, 5)).astype('int')
print(f'List of numbers of nearest neighbors: {k_list}')
if if_all_methods:
dims = estimator.fit_all_methods(data, k_list)
np.save(os.path.join(vars_filepath, 'intrinsic_dimension_image_all_methods.npy'), dims)
else:
dims = estimator.fit(data, k_list)
np.save(os.path.join(vars_filepath, 'intrinsic_dimension_image.npy'), dims)
if __name__ == '__main__':
config_filepath = str(sys.argv[1])
cfg = load_config(filepath=config_filepath)
pprint.pprint(cfg)
cfg = munchify(cfg)
if_all_methods = (str(sys.argv[3]) == 'all-methods')
if str(sys.argv[2]) == 'model-latent':
log_dir = '_'.join([cfg.log_dir, cfg.dataset, cfg.model_name, str(cfg.seed)])
vars_filepath = os.path.join(log_dir, 'variables')
if_refine = ('refine' in cfg.model_name)
dims = eval_id_latent(vars_filepath, if_refine, if_all_methods)
elif str(sys.argv[2]) == 'data-image':
data_filepath = os.path.join(cfg.data_filepath, cfg.dataset)
with open(os.path.join('../datainfo', cfg.dataset, f'data_split_dict_{cfg.seed}.json'), 'r') as file:
seq_dict = json.load(file)
test_vid_ids = seq_dict['test']
log_dir = '_'.join([cfg.log_dir, cfg.dataset, cfg.model_name, str(cfg.seed)])
vars_filepath = os.path.join(log_dir, 'variables')
dims = eval_id_image(data_filepath, test_vid_ids, vars_filepath, if_all_methods)
else:
assert False, 'Invalid arguments...'
================================================
FILE: analysis/eval_phys_data.py
================================================
import os
import sys
import cv2
import numpy as np
from tqdm import tqdm
def eval_phys_data_single_pendulum(data_filepath, num_vids, num_frms, save_path):
from eval_phys_single_pendulum import eval_physics, phys_vars_list
phys = {p_var:[] for p_var in phys_vars_list}
for n in tqdm(range(num_vids)):
seq_filepath = os.path.join(data_filepath, str(n))
frames = []
for p in range(num_frms):
frame_p = cv2.imread(os.path.join(seq_filepath, str(p)+'.png'))
frames.append(frame_p)
phys_tmp = eval_physics(frames)
for p_var in phys_vars_list:
phys[p_var].append(phys_tmp[p_var])
for p_var in phys_vars_list:
phys[p_var] = np.array(phys[p_var])
np.save(save_path, phys)
def eval_phys_data_double_pendulum(data_filepath, num_vids, num_frms, save_path):
from eval_phys_double_pendulum import eval_physics, phys_vars_list
phys = {p_var:[] for p_var in phys_vars_list}
for n in tqdm(range(num_vids)):
seq_filepath = os.path.join(data_filepath, str(n))
frames = []
for p in range(num_frms):
frame_p = cv2.imread(os.path.join(seq_filepath, str(p)+'.png'))
frames.append(frame_p)
phys_tmp = eval_physics(frames)
for p_var in phys_vars_list:
phys[p_var].append(phys_tmp[p_var])
for p_var in phys_vars_list:
phys[p_var] = np.array(phys[p_var])
# remove outliers
thresh_1 = np.nanpercentile(np.abs(phys['vel_theta_1']), 98)
thresh_2 = np.nanpercentile(np.abs(phys['vel_theta_2']), 98)
for n in range(num_vids):
for p in range(num_frms):
if (not np.isnan(phys['vel_theta_1'][n, p]) and np.abs(phys['vel_theta_1'][n, p]) >= thresh_1) \
or (not np.isnan(phys['vel_theta_2'][n, p]) and np.abs(phys['vel_theta_2'][n, p]) >= thresh_2):
phys['vel_theta_1'][n, p] = np.nan
phys['vel_theta_2'][n, p] = np.nan
phys['kinetic energy'][n, p] = np.nan
phys['total energy'][n, p] = np.nan
np.save(save_path, phys)
def eval_phys_data_elastic_pendulum(data_filepath, num_vids, num_frms, save_path):
from eval_phys_elastic_pendulum import eval_physics, phys_vars_list
phys = {p_var:[] for p_var in phys_vars_list}
for n in tqdm(range(num_vids)):
seq_filepath = os.path.join(data_filepath, str(n))
frames = []
for p in range(num_frms):
frame_p = cv2.imread(os.path.join(seq_filepath, str(p)+'.png'))
frames.append(frame_p)
phys_tmp = eval_physics(frames)
for p_var in phys_vars_list:
phys[p_var].append(phys_tmp[p_var])
for p_var in phys_vars_list:
phys[p_var] = np.array(phys[p_var])
# remove outliers
thresh_1 = np.nanpercentile(np.abs(phys['vel_theta_1']), 98)
thresh_2 = np.nanpercentile(np.abs(phys['vel_theta_2']), 98)
thresh_z = np.nanpercentile(np.abs(phys['vel_z']), 98)
for n in range(num_vids):
for p in range(num_frms):
if (not np.isnan(phys['vel_theta_1'][n, p]) and np.abs(phys['vel_theta_1'][n, p]) >= thresh_1) \
or (not np.isnan(phys['vel_theta_2'][n, p]) and np.abs(phys['vel_theta_2'][n, p]) >= thresh_2) \
or (not np.isnan(phys['vel_z'][n, p]) and np.abs(phys['vel_z'][n, p]) >= thresh_z):
phys['vel_theta_1'][n, p] = np.nan
phys['vel_theta_2'][n, p] = np.nan
phys['vel_z'][n, p] = np.nan
phys['kinetic energy'][n, p] = np.nan
phys['total energy'][n, p] = np.nan
np.save(save_path, phys)
if __name__ == '__main__':
dataset = str(sys.argv[1])
data_filepath = str(sys.argv[2])
save_path = os.path.join(data_filepath, 'phys_vars.npy')
if dataset == 'single_pendulum':
eval_phys_data_single_pendulum(data_filepath, 1200, 60, save_path)
elif dataset == 'double_pendulum':
eval_phys_data_double_pendulum(data_filepath, 1100, 60, save_path)
elif dataset == 'elastic_pendulum':
eval_phys_data_elastic_pendulum(data_filepath, 1200, 60, save_path)
else:
assert False, 'Unknown system...'
================================================
FILE: analysis/eval_phys_double_pendulum/__init__.py
================================================
from .angle_estimator import obtain_angle
from .physics_estimator import *
import numpy as np
phys_vars_list = {'reject', 'theta_1', 'vel_theta_1', 'theta_2', 'vel_theta_2', 'kinetic energy',
'potential energy', 'total energy'}
def eval_physics(frames):
num_frames = len(frames)
reject = np.zeros(num_frames, dtype=bool)
theta_1 = np.zeros(num_frames)
theta_2 = np.zeros(num_frames)
# estimate angles
for p in range(num_frames):
reject_p, angles_p, _ = obtain_angle(frames[p])
if reject_p:
reject[p] = True
theta_1[p] = np.nan
theta_2[p] = np.nan
else:
reject[p] = False
theta_1[p] = angles_p[0]
theta_2[p] = angles_p[1]
# calculate velocities
vel_theta_1 = np.zeros(num_frames)
vel_theta_2 = np.zeros(num_frames)
sub_ids = np.ma.clump_unmasked(np.ma.masked_array(theta_1, reject))
for ids in sub_ids:
vel_theta_1[ids] = calc_velocity(theta_1[ids].copy())
vel_theta_2[ids] = calc_velocity(theta_2[ids].copy())
vel_theta_1[reject] = np.nan
vel_theta_2[reject] = np.nan
# calculate energies
kinetic_energy, potential_energy, total_energy = calc_energy(theta_1, theta_2, vel_theta_1, vel_theta_2)
# save results
phys = dict.fromkeys(phys_vars_list)
phys['reject'] = reject
phys['theta_1'] = theta_1
phys['vel_theta_1'] = vel_theta_1
phys['theta_2'] = theta_2
phys['vel_theta_2'] = vel_theta_2
phys['kinetic energy'] = kinetic_energy
phys['potential energy'] = potential_energy
phys['total energy'] = total_energy
return phys
================================================
FILE: analysis/eval_phys_double_pendulum/angle_estimator.py
================================================
'''
This script provides utility functions estimating angles of a double pendulum from image.
Step 1. Extract each of the two pendulums from the image.
Step 2. Do a rectangle fitting of each pendulum.
Step 3. Estimate the angles of the pendulums.
Certain images will be rejected if any pendulum does not exist, is hidden, or has a wrong shape.
'''
import cv2
import os
import numpy as np
'''
Extract the two pendulums from the image.
Args:
img: double pendulum image in BGR format
Returns:
seg_1: segmentation of the first pendulum
seg_2: segmentation of the second pendulum
'''
def seg_from_img(img):
# pixel thresholds (in HSV)
v_min_1 = (0, 0, 0)
v_max_1 = (255, 255, 140)
v_min_2 = (60, 0, 0)
v_max_2 = (255, 255, 255)
# background color in HSV (RGB: [215, 205, 192])
bg_color = [17, 27, 215]
img_hsv = cv2.cvtColor(img, cv2.COLOR_BGR2HSV)
# extract the first pendulum
seg_1 = cv2.inRange(img_hsv, v_min_1, v_max_1)
# remove the first pendulum by replacing it with background pixels
img_hsv[seg_1==255] = bg_color
# extract the second pendulum
seg_2 = cv2.inRange(img_hsv, v_min_2, v_max_2)
return seg_1, seg_2
'''
Fit pendulum in a rectangle.
Args:
seg: segmentation of the pendulum
Returns:
rej: (True/False) if the image is rejected
rect: (Box2D structure) the fitted rectangle
'''
def fit_pendulum(seg):
# find all contours
contours, _ = cv2.findContours(seg, cv2.RETR_TREE, cv2.CHAIN_APPROX_SIMPLE)
# reject if no contours found
if len(contours) == 0:
return True, None
# find the contour with the maximum area
cnt = max(contours, key=cv2.contourArea)
area = cv2.contourArea(cnt)
# reject if the contour is too small
if area < 125:
return True, None
# rectangle fitting
rect = cv2.minAreaRect(cnt)
_, (width, height), _ = rect
# reject if the rectangle is too close to a square
if abs(height-width) < 8:
return True, None
# reject if the rectangle does not properly fit the contour
if height*width > 2 * area:
return True, None
return False, rect
'''
Estimate the angle of pendulum from its fitted rectangle.
Args:
rect: (Box2D structure) the fitted rectangle
ref_pt: reference point to determine the arrow direction
Returns:
angle: the estimated angle in radians in range (0, 2*pi)
box: box points of the rectangle
arrow: the arrow pointing along the angle
'''
def estimate_angle(rect, ref_pt):
# box points
box = cv2.boxPoints(rect)
# center, width and height
(cx, cy), (width, height), _ = rect
# specify the direction vector of the pendulum
if width < height:
v_d = box[0] - box[1]
else:
v_d = box[0] - box[3]
# reference vector
v_ref = np.array([cx, cy]) - ref_pt
# choose the one from v_d and -v_d whose angle with v_ref
# is less than pi
if np.dot(v_d, v_ref) < 0:
v_d = -v_d
# counterclockwise angle from (0,-1) to v_d
angle = np.arctan2(-v_d[1], v_d[0]) + np.pi/2
if angle < 0:
angle += 2*np.pi
arrow = ((int(cx), int(cy)), (int(cx+v_d[0]), int(cy+v_d[1])))
return angle, box, arrow
'''
Obtain the angles of double pendulum from image
Args:
img: double pendulum image in BGR format
Returns:
rej: (True/False) if the image is rejected
angles: the estimated angles in radians in range (0, 2*pi)
img_marked: image marked with the fitted rectangles,
the direction vectors and the estimated angles (BGR format)
'''
def obtain_angle(img):
img_marked = img.copy()
seg_1, seg_2 = seg_from_img(img)
rej_1, rect_1 = fit_pendulum(seg_1)
rej_2, rect_2 = fit_pendulum(seg_2)
if rej_1:
rej = True
angles = []
cv2.putText(img_marked, 'Reject arm 1', (10, 20), cv2.FONT_HERSHEY_SIMPLEX, 0.5, (0, 0, 0), 1)
elif rej_2:
rej = True
angles = []
cv2.putText(img_marked, 'Reject arm 2', (10, 20), cv2.FONT_HERSHEY_SIMPLEX, 0.5, (0, 0, 0), 1)
else:
rej = False
img_center = np.array([64, 64])
angle_1, box_1, arrow_1 = estimate_angle(rect_1, img_center)
(cx, cy), _, _ = rect_1
pd_1_end = 2 * np.array([cx, cy]) - img_center
angle_2, box_2, arrow_2 = estimate_angle(rect_2, pd_1_end)
angles = [angle_1, angle_2]
# mark the fitted rectangles
cv2.drawContours(img_marked, [np.int0(box_1)], 0, (0,0,255), 2)
cv2.drawContours(img_marked, [np.int0(box_2)], 0, (0,0,255), 2)
# mark the direction vectors
cv2.arrowedLine(img_marked, arrow_1[0], arrow_1[1], (0, 0, 255), 1, tipLength=0.25)
cv2.arrowedLine(img_marked, arrow_2[0], arrow_2[1], (0, 0, 255), 1, tipLength=0.25)
# mark the estimated angles in degrees
text = str(round(angle_1*180/np.pi)) + ' ' + str(round(angle_2*180/np.pi))
cv2.putText(img_marked, text, (10, 20), cv2.FONT_HERSHEY_SIMPLEX, 0.5, (0, 0, 0), 1)
return rej, angles, img_marked
================================================
FILE: analysis/eval_phys_double_pendulum/physics_estimator.py
================================================
'''
This script provides utility functions estimating angular velocities
and other physical quantities from angles of double pendulum.
'''
import numpy as np
from scipy.interpolate import CubicSpline
# physical parameters
fps = 60 # frames per second
L1, L2 = 0.205, 0.179 # pendulum rod lengths (m)
w1, w2 = 0.038, 0.038 # pendulum rod widths (m)
m1, m2 = 0.262, 0.110 # bob masses (kg)
g = 9.81 # gravitational acceleration (m/s^2)
'''
Calculate the absolute difference between two angles th1 and th2 on a circle.
Assumed that the absolute difference between the two angles is within range (0,pi).
'''
def calc_diff(th1, th2):
diff = np.abs(th2 - th1)
diff = np.minimum(diff, 2*np.pi-diff)
return diff
'''
Calculate the average of two angles th1 and th2 on a circle.
Assumed that the absolute difference between the two angles is within range (0,pi).
'''
def calc_avrg(th1, th2):
avrg = (th1 + th2) / 2
diff = np.abs(th2 - th1)
if diff > np.pi:
avrg -= np.pi
if avrg < 0:
avrg += 2*np.pi
return avrg
'''
Calculate angular velocities from a sequence of angles
using numerical differentiation.
method='fd': finite difference;
method='spline': cubic spline fitting.
'''
def calc_velocity(th, method='spline'):
len_seq = th.shape[0]
# isolated data
if len_seq == 1:
return np.nan
# preprocessing: periodic extension of angles
for i in range(1, len_seq):
if th[i] - th[i-1] > np.pi:
th[i:] -= 2*np.pi
elif th[i] - th[i-1] < -np.pi:
th[i:] += 2*np.pi
vel_th = np.zeros(len_seq)
# finite difference
if method == 'fd':
for i in range(1, len_seq):
vel_th[i] = (th[i] - th[i-1]) * fps
vel_th[0] = (th[1] - th[0]) * fps
# cubic spline fitting
elif method == 'spline':
t = np.arange(len_seq) / fps
cs = CubicSpline(t, th)
vel_th = cs(t, 1)
# use finite difference at boundary points to improve accuracy
vel_th[0] = (th[1] - th[0]) * fps
vel_th[-1] = (th[-1] - th[-2]) * fps
else:
assert False, 'Unrecognizable differentiation method!'
return vel_th
'''
Calculate energies from angles and angular velocities
'''
def calc_energy(th1, th2, vel_th1, vel_th2):
# centers of masses in x-y coordinates
x1 = (L1 / 2) * np.sin(th1)
y1 = (-L1 / 2) * np.cos(th1)
x2 = (L1 * np.sin(th1)) + (L2 / 2) * np.sin(th2)
y2 = (-L1 * np.cos(th1)) - (L2 / 2) * np.cos(th2)
# velocities in x-y coordinates
vel_x1 = vel_th1 * (L1 / 2) * np.cos(th1)
vel_y1 = vel_th1 * (L1 / 2) * np.sin(th1)
vel_x2 = vel_th1 * L1 * np.cos(th1) + (vel_th2 / 2) * L2 * np.cos(th2)
vel_y2 = vel_th1 * L1 * np.sin(th1) + (vel_th2 / 2) * L2 * np.sin(th2)
# moments of inertia
I1 = (1. / 12.) * m1 * (w1 ** 2 + L1 ** 2)
I2 = (1. / 12.) * m2 * (w2 ** 2 + L2 ** 2)
# potential energy
V = g * (m1 * y1 + m2 * y2)
# kinetic energy (translation + rotation)
T = 0.5 * m1 * (vel_x1 ** 2 + vel_y1 ** 2) + 0.5 * m2 * (vel_x2 ** 2 + vel_y2 ** 2) + 0.5 * I1 * (
vel_th1 ** 2) + 0.5 * I2 * (vel_th2 ** 2)
# total energy
E = T + V
return T, V, E
================================================
FILE: analysis/eval_phys_elastic_pendulum/__init__.py
================================================
from .angle_estimator import obtain_angle_stretch
from .physics_estimator import *
import numpy as np
phys_vars_list = {'reject', 'theta_1', 'vel_theta_1', 'theta_2', 'vel_theta_2', 'z', 'vel_z',
'kinetic energy', 'potential energy', 'total energy'}
def eval_physics(frames):
num_frames = len(frames)
reject = np.zeros(num_frames, dtype=bool)
theta_1 = np.zeros(num_frames)
theta_2 = np.zeros(num_frames)
z = np.zeros(num_frames)
# estimate angles and stretch
for p in range(num_frames):
reject_p, angles_p, stretch_p, _ = obtain_angle_stretch(frames[p])
if reject_p:
reject[p] = True
theta_1[p] = np.nan
theta_2[p] = np.nan
z[p] = np.nan
else:
reject[p] = False
theta_1[p] = angles_p[0]
theta_2[p] = angles_p[1]
z[p] = stretch_p
# calculate velocities
vel_theta_1 = np.zeros(num_frames)
vel_theta_2 = np.zeros(num_frames)
vel_z = np.zeros(num_frames)
sub_ids = np.ma.clump_unmasked(np.ma.masked_array(theta_1, reject))
for ids in sub_ids:
vel_theta_1[ids] = calc_velocity(theta_1[ids].copy())
vel_theta_2[ids] = calc_velocity(theta_2[ids].copy())
vel_z[ids] = calc_velocity(z[ids].copy(), periodic=False)
vel_theta_1[reject] = np.nan
vel_theta_2[reject] = np.nan
vel_z[reject] = np.nan
# calculate energies
kinetic_energy, potential_energy, total_energy = calc_energy(theta_1, theta_2, z, vel_theta_1, vel_theta_2, vel_z)
# save results
phys = dict.fromkeys(phys_vars_list)
phys['reject'] = reject
phys['theta_1'] = theta_1
phys['vel_theta_1'] = vel_theta_1
phys['theta_2'] = theta_2
phys['vel_theta_2'] = vel_theta_2
phys['z'] = z
phys['vel_z'] = vel_z
phys['kinetic energy'] = kinetic_energy
phys['potential energy'] = potential_energy
phys['total energy'] = total_energy
return phys
================================================
FILE: analysis/eval_phys_elastic_pendulum/angle_estimator.py
================================================
'''
This script provides utility functions estimating angles and stretch of a elastic double pendulum from image.
Step 1. Extract each of the two pendulums from the image.
Step 2. Do a rectangle fitting of each pendulum.
Step 3. Estimate the angles of the pendulums and the stretch of the elastic one.
Certain images will be rejected if any pendulum does not exist, is hidden, or has a wrong shape.
'''
import cv2
import os
import numpy as np
'''
Extract the two pendulums from the image.
Args:
img: elastic double pendulum image in BGR format
Returns:
seg_1: segmentation of the first pendulum
seg_2: segmentation of the second pendulum
'''
def seg_from_img(img):
# pixel thresholds (in HSV)
v_min_1 = (0, 0, 0)
v_max_1 = (255, 255, 140)
v_min_2 = (60, 0, 0)
v_max_2 = (255, 255, 255)
# background color in HSV (RGB: [215, 205, 192])
bg_color = [17, 27, 215]
img_hsv = cv2.cvtColor(img, cv2.COLOR_BGR2HSV)
# extract the first pendulum
seg_1 = cv2.inRange(img_hsv, v_min_1, v_max_1)
# remove the first pendulum by replacing it with background pixels
img_hsv[seg_1==255] = bg_color
# extract the second pendulum
seg_2 = cv2.inRange(img_hsv, v_min_2, v_max_2)
return seg_1, seg_2
'''
Fit pendulum in a rectangle.
Args:
seg: segmentation of the pendulum
Returns:
rej: (True/False) if the image is rejected
rect: (Box2D structure) the fitted rectangle
'''
def fit_pendulum(seg):
# find all contours
contours, _ = cv2.findContours(seg, cv2.RETR_TREE, cv2.CHAIN_APPROX_SIMPLE)
# reject if no contours found
if len(contours) == 0:
return True, None
# find the contour with the maximum area
cnt = max(contours, key=cv2.contourArea)
area = cv2.contourArea(cnt)
# reject if the contour is too small
if area < 60:
return True, None
# rectangle fitting
rect = cv2.minAreaRect(cnt)
_, (width, height), _ = rect
# reject if the rectangle is too close to a square
if abs(height-width) < 4:
return True, None
# reject if the rectangle does not properly fit the contour
if height*width > 1.8 * area:
return True, None
return False, rect
'''
Estimate the angle of pendulum from its fitted rectangle.
Args:
rect: (Box2D structure) the fitted rectangle
ref_pt: reference point to determine the arrow direction
Returns:
angle: the estimated angle in radians in range (0, 2*pi)
box: box points of the rectangle
arrow: the arrow pointing along the angle
'''
def estimate_angle(rect, ref_pt):
# box points
box = cv2.boxPoints(rect)
# center, width and height
(cx, cy), (width, height), _ = rect
# specify the direction vector of the pendulum
if width < height:
v_d = box[0] - box[1]
else:
v_d = box[0] - box[3]
# reference vector
v_ref = np.array([cx, cy]) - ref_pt
# choose the one from v_d and -v_d whose angle with v_ref
# is less than pi
if np.dot(v_d, v_ref) < 0:
v_d = -v_d
# counterclockwise angle from (0,-1) to v_d
angle = np.arctan2(-v_d[1], v_d[0]) + np.pi/2
if angle < 0:
angle += 2*np.pi
arrow = ((int(cx), int(cy)), (int(cx+v_d[0]), int(cy+v_d[1])))
return angle, box, arrow
'''
Obtain the angles and stretch of elastic double pendulum from image
Args:
img: elastic double pendulum image in BGR format
Returns:
rej: (True/False) if the image is rejected
angles: the estimated angles in radians in range (0, 2*pi)
stretch: the estimated stretch of the elastic pendulum (unit: m)
img_marked: image marked with the fitted rectangles,
the direction vectors and the estimated angles and stretch (BGR format)
'''
def obtain_angle_stretch(img):
img_marked = img.copy()
seg_1, seg_2 = seg_from_img(img)
rej_1, rect_1 = fit_pendulum(seg_1)
rej_2, rect_2 = fit_pendulum(seg_2)
if rej_1:
rej = True
angles = []
stretch = None
cv2.putText(img_marked, 'Reject arm 1', (10, 20), cv2.FONT_HERSHEY_SIMPLEX, 0.5, (0, 0, 0), 1)
elif rej_2:
rej = True
angles = []
stretch = None
cv2.putText(img_marked, 'Reject arm 2', (10, 20), cv2.FONT_HERSHEY_SIMPLEX, 0.5, (0, 0, 0), 1)
else:
rej = False
img_center = np.array([64, 64])
angle_1, box_1, arrow_1 = estimate_angle(rect_1, img_center)
(cx, cy), (width, height), _ = rect_1
pd_1_end = 2 * np.array([cx, cy]) - img_center
angle_2, box_2, arrow_2 = estimate_angle(rect_2, pd_1_end)
angles = [angle_1, angle_2]
# compute the stretch of the elastic pendulum (unit: m)
# max(width, height): stretched length of the elastic pendulum in pixels
L_0_img = 24 # unstretched length of the elastic pendulum in pixels
L_0 = 0.205 # unstretched length of the elastic pendulum (m)
stretch = (max(width, height) - L_0_img) / L_0_img * L_0
# mark the fitted rectangles
cv2.drawContours(img_marked, [np.int0(box_1)], 0, (0,0,255), 2)
cv2.drawContours(img_marked, [np.int0(box_2)], 0, (0,0,255), 2)
# mark the direction vectors
cv2.arrowedLine(img_marked, arrow_1[0], arrow_1[1], (0, 0, 255), 1, tipLength=0.25)
cv2.arrowedLine(img_marked, arrow_2[0], arrow_2[1], (0, 0, 255), 1, tipLength=0.25)
# mark the estimated angles (degrees) and stretch (m)
text = str(round(angle_1*180/np.pi)) + ' ' + str(round(angle_2*180/np.pi)) + ' ' + ('%.2f' % stretch)
cv2.putText(img_marked, text, (10, 20), cv2.FONT_HERSHEY_SIMPLEX, 0.45, (0, 0, 0), 1)
return rej, angles, stretch, img_marked
================================================
FILE: analysis/eval_phys_elastic_pendulum/physics_estimator.py
================================================
'''
This script provides utility functions estimating velocities
and other physical quantities of elastic double pendulum.
'''
import numpy as np
from scipy.interpolate import CubicSpline
# physical parameters
fps = 60 # frames per second
L_0 = 0.205 # elastic pendulum unstretched length (m)
L = 0.179 # rigid pendulum rod length (m)
w = 0.038 # rigid pendulum rod width (m)
m = 0.110 # rigid pendulum mass (kg)
g = 9.81 # gravitational acceleration (m/s^2)
k = 40.0 # elastic constant (kg/s^2)
'''
Calculate the absolute difference between two angles th1 and th2 on a circle.
Assumed that the absolute difference between the two angles is within range (0,pi).
'''
def calc_diff(th1, th2):
diff = np.abs(th2 - th1)
diff = np.minimum(diff, 2*np.pi-diff)
return diff
'''
Calculate the average of two angles th1 and th2 on a circle.
Assumed that the absolute difference between the two angles is within range (0,pi).
'''
def calc_avrg(th1, th2):
avrg = (th1 + th2) / 2
diff = np.abs(th2 - th1)
if diff > np.pi:
avrg -= np.pi
if avrg < 0:
avrg += 2*np.pi
return avrg
'''
Normalize the angle to (-pi, pi).
'''
def normalize_angle(theta):
return np.arctan2(np.sin(theta), np.cos(theta))
'''
Calculate velocities from a sequence of data
using numerical differentiation.
method='fd': finite difference;
method='spline': cubic spline fitting.
'''
def calc_velocity(x, method='spline', periodic=True):
len_seq = x.shape[0]
# isolated data
if len_seq == 1:
return np.nan
# preprocessing: periodic extension of angles
if periodic:
for i in range(1, len_seq):
if x[i] - x[i-1] > np.pi:
x[i:] -= 2*np.pi
elif x[i] - x[i-1] < -np.pi:
x[i:] += 2*np.pi
vel_x = np.zeros(len_seq)
# finite difference
if method == 'fd':
for i in range(1, len_seq):
vel_x[i] = (x[i] - x[i-1]) * fps
vel_x[0] = (x[1] - x[0]) * fps
# cubic spline fitting
elif method == 'spline':
t = np.arange(len_seq) / fps
cs = CubicSpline(t, x)
vel_x = cs(t, 1)
# use finite difference at boundary points to improve accuracy
vel_x[0] = (x[1] - x[0]) * fps
vel_x[-1] = (x[-1] - x[-2]) * fps
else:
assert False, 'Unrecognizable differentiation method!'
return vel_x
'''
Calculate energies
'''
def calc_energy(th1, th2, z, vel_th1, vel_th2, vel_z):
# center of mass in x-y coordinates
x = (L_0 + z) * np.sin(th1) + (L / 2) * np.sin(th2)
y = -(L_0 + z) * np.cos(th1) - (L / 2) * np.cos(th2)
# velocities in x-y coordinates
vel_x = vel_th1 * (L_0 + z) * np.cos(th1) + vel_th2 * (L / 2) * np.cos(th2) + vel_z * np.sin(th1)
vel_y = vel_th1 * (L_0 + z) * np.sin(th1) + vel_th2 * (L / 2) * np.sin(th2) - vel_z * np.cos(th1)
# moment of inertia
I = (1. / 12.) * m * (w ** 2 + L ** 2)
# potential energy (gravitational + elastic)
V = m * g * y + 0.5 * k * z**2
# kinetic energy (translation + rotation)
T = 0.5 * m * (vel_x ** 2 + vel_y ** 2) + 0.5 * I * vel_th2 ** 2
# total energy
E = T + V
return T, V, E
================================================
FILE: analysis/eval_phys_long_term_pred.py
================================================
"""
Evaluate long-term prediction accuracy in physical variables.
"""
import os
import sys
import numpy as np
from scipy import stats
import cv2
import json
import yaml
import pprint
from tqdm import tqdm
from munch import munchify
'''
Calculate the absolute difference between two angles th1 and th2 on a circle.
Assumed that the absolute difference between the two angles is within range (0,pi).
'''
def calc_diff(th1, th2):
diff = np.abs(th2 - th1)
diff = np.minimum(diff, 2*np.pi-diff)
return diff
'''
Calculate the pixel mean square error between two images.
'''
def calc_pixel_MSE(img1, img2):
return np.mean((img1/255.0 - img2/255.0) ** 2)
def load_config(filepath):
with open(filepath, 'r') as stream:
try:
trainer_params = yaml.safe_load(stream)
return trainer_params
except yaml.YAMLError as exc:
print(exc)
def eval_pred_physics(data_filepath, pred_save_path, vid_ids, phys_vars_list, eval_physics):
phys = {p_var:[] for p_var in phys_vars_list}
for idx in tqdm(vid_ids):
data_vid_filepath = os.path.join(data_filepath, str(idx))
pred_vid_filepath = os.path.join(pred_save_path, str(idx))
num_frames = len(os.listdir(data_vid_filepath))
num_pred_frames = len(os.listdir(pred_vid_filepath))
frames = []
for p in range(num_frames):
if (num_pred_frames == num_frames - 2) and (p == 0 or p == 1):
# read the initial two frames from ground truth data
frame_p = cv2.imread(os.path.join(data_vid_filepath, str(p)+'.png'))
else:
frame_p = cv2.imread(os.path.join(pred_vid_filepath, str(p)+'.png'))
frames.append(frame_p)
phys_tmp = eval_physics(frames)
for p_var in phys_vars_list:
phys[p_var].append(phys_tmp[p_var])
for p_var in phys_vars_list:
phys[p_var] = np.array(phys[p_var])
return phys
def load_data_physics(data_filepath, vid_ids, phys_vars_list):
phys = np.load(os.path.join(data_filepath, 'phys_vars.npy'), allow_pickle=True).item()
for p_var in phys_vars_list:
phys[p_var] = phys[p_var][vid_ids]
return phys
def eval_physics_error(phys_pred, phys_data, phys_vars_list):
phys_vars_list_2 = [p_var for p_var in phys_vars_list if p_var!='reject']
phys_error = {}
phys_error['reject'] = phys_pred['reject'].copy()
if 'reject' in phys_data.keys():
phys_error['reject_data'] = phys_data['reject'].copy()
else:
phys_error['reject_data'] = np.zeros(phys_pred['reject'].shape)
for p_var in phys_vars_list_2:
if p_var in ['theta', 'theta_1', 'theta_2']:
phys_error[p_var] = calc_diff(phys_pred[p_var], phys_data[p_var])
else:
phys_error[p_var] = np.abs(phys_pred[p_var] - phys_data[p_var])
return phys_error
def eval_pixel_error(data_filepath, pred_save_path, vid_ids):
pixel_error = []
for idx in tqdm(vid_ids):
data_vid_filepath = os.path.join(data_filepath, str(idx))
pred_vid_filepath = os.path.join(pred_save_path, str(idx))
num_frames = len(os.listdir(data_vid_filepath))
pixel_error_idx = []
for p in range(num_frames):
if p == 0 or p == 1:
pixel_error_idx.append(0)
else:
data = cv2.imread(os.path.join(data_vid_filepath, str(p)+'.png'))
pred = cv2.imread(os.path.join(pred_vid_filepath, str(p)+'.png'))
pixel_error_idx.append(calc_pixel_MSE(data, pred))
pixel_error.append(pixel_error_idx)
return np.array(pixel_error)
def main():
config_filepath = str(sys.argv[1])
pred_save_path = str(sys.argv[2])
cfg = load_config(filepath=config_filepath)
pprint.pprint(cfg)
cfg = munchify(cfg)
data_filepath = os.path.join(cfg.data_filepath, cfg.dataset)
with open(os.path.join('../datainfo', cfg.dataset, f'data_split_dict_{cfg.seed}.json'), 'r') as file:
seq_dict = json.load(file)
vid_ids = seq_dict['test']
if cfg.dataset == 'single_pendulum':
from eval_phys_single_pendulum import phys_vars_list, eval_physics
elif cfg.dataset == 'double_pendulum':
from eval_phys_double_pendulum import phys_vars_list, eval_physics
elif cfg.dataset == 'elastic_pendulum':
from eval_phys_elastic_pendulum import phys_vars_list, eval_physics
else:
assert False, 'Unknown system...'
phys_pred = eval_pred_physics(data_filepath, pred_save_path, vid_ids, phys_vars_list, eval_physics)
phys_data = load_data_physics(data_filepath, vid_ids, phys_vars_list)
phys_error = eval_physics_error(phys_pred, phys_data, phys_vars_list)
pixel_error = eval_pixel_error(data_filepath, pred_save_path, vid_ids)
np.save(os.path.join(pred_save_path, 'phys_vars.npy'), phys_pred)
np.save(os.path.join(pred_save_path, 'phys_error.npy'), phys_error)
np.save(os.path.join(pred_save_path, 'pixel_error.npy'), pixel_error)
if __name__ == '__main__':
main()
================================================
FILE: analysis/eval_phys_single_pendulum/__init__.py
================================================
from .angle_estimator import obtain_angle
from .physics_estimator import *
import numpy as np
phys_vars_list = {'reject', 'theta', 'vel_theta', 'kinetic energy',
'potential energy', 'total energy'}
def eval_physics(frames):
num_frames = len(frames)
reject = np.zeros(num_frames, dtype=bool)
theta = np.zeros(num_frames)
# estimate angles
for p in range(num_frames):
reject_p, theta_p, _ = obtain_angle(frames[p])
if reject_p:
reject[p] = True
theta[p] = np.nan
else:
reject[p] = False
theta[p] = theta_p
# calculate velocities
vel_theta = np.zeros(num_frames)
sub_ids = np.ma.clump_unmasked(np.ma.masked_array(theta, reject))
for ids in sub_ids:
vel_theta[ids] = calc_velocity(theta[ids].copy())
vel_theta[reject] = np.nan
# calculate energies
kinetic_energy, potential_energy, total_energy = calc_energy(theta, vel_theta)
# save results
phys = dict.fromkeys(phys_vars_list)
phys['reject'] = reject
phys['theta'] = theta
phys['vel_theta'] = vel_theta
phys['kinetic energy'] = kinetic_energy
phys['potential energy'] = potential_energy
phys['total energy'] = total_energy
return phys
================================================
FILE: analysis/eval_phys_single_pendulum/angle_estimator.py
================================================
'''
This script provides utility functions estimating the angle of a single pendulum from image.
Step 1. Extract the pendulum from the image.
Step 2. Do a rectangle fitting of the pendulum.
Step 3. Estimate the angle of the pendulum.
Certain images will be rejected if the pendulum does not exist or has a wrong shape.
'''
import cv2
import os
import numpy as np
'''
Extract the pendulum from the image.
Args:
img: single pendulum image in BGR format
Returns:
seg: segmentation of the pendulum
'''
def seg_from_img(img):
# pixel thresholds (in HSV)
v_min = (60, 0, 0)
v_max = (255, 255, 255)
# extract the pendulum
img_hsv = cv2.cvtColor(img, cv2.COLOR_BGR2HSV)
seg = cv2.inRange(img_hsv, v_min, v_max)
return seg
'''
Fit pendulum in a rectangle.
Args:
seg: segmentation of the pendulum
Returns:
rej: (True/False) if the image is rejected
rect: (Box2D structure) the fitted rectangle
'''
def fit_pendulum(seg):
# find all contours
contours, _ = cv2.findContours(seg, cv2.RETR_TREE, cv2.CHAIN_APPROX_SIMPLE)
# reject if no contours found
if len(contours) == 0:
return True, None
# find the contour with the maximum area
cnt = max(contours, key=cv2.contourArea)
area = cv2.contourArea(cnt)
# reject if the contour is too small
if area < 400:
return True, None
# rectangle fitting
rect = cv2.minAreaRect(cnt)
_, (width, height), _ = rect
# reject if the rectangle is too close to a square
if abs(height-width) < 35:
return True, None
# reject if the rectangle does not properly fit the contour
if height*width > 1.5 * area:
return True, None
return False, rect
'''
Estimate the angle of pendulum from its fitted rectangle.
Args:
rect: (Box2D structure) the fitted rectangle
Returns:
angle: the estimated angle in radians in range (0, 2*pi)
box: box points of the rectangle
arrow: the arrow pointing along the angle
'''
def estimate_angle(rect):
# box points
box = cv2.boxPoints(rect)
# center, width and height
(cx, cy), (width, height), _ = rect
# specify the direction vector of the pendulum
if width < height:
v_d = box[0] - box[1]
else:
v_d = box[0] - box[3]
# reference vector
v_ref = np.array([cx-64, cy-64])
# choose the one from v_d and -v_d whose angle with v_ref
# is less than pi
if np.dot(v_d, v_ref) < 0:
v_d = -v_d
# counterclockwise angle from (0,-1) to v_d
angle = np.arctan2(-v_d[1], v_d[0]) + np.pi/2
if angle < 0:
angle += 2*np.pi
arrow = ((int(cx), int(cy)), (int(cx+0.7*v_d[0]), int(cy+0.7*v_d[1])))
return angle, box, arrow
'''
Obtain the angle of single pendulum from image
Args:
img: single pendulum image in BGR format
Returns:
rej: (True/False) if the image is rejected
angle: the estimated angle in radians in range (0, 2*pi)
img_marked: image marked with the fitted rectangle,
the direction vector and the estimated angle (BGR format)
'''
def obtain_angle(img):
img_marked = img.copy()
seg = seg_from_img(img)
rej, rect = fit_pendulum(seg)
if not rej:
angle, box, arrow = estimate_angle(rect)
# mark the fitted rectangle
cv2.drawContours(img_marked, [np.int0(box)], 0, (0,0,255), 2)
# mark the direction vector
cv2.arrowedLine(img_marked, arrow[0], arrow[1], (0, 0, 255), 1, tipLength=0.25)
# mark the estimated angle in degrees
cv2.putText(img_marked, str(round(angle*180/np.pi)), (10, 20), cv2.FONT_HERSHEY_SIMPLEX, 0.5, (0, 0, 0), 1)
else:
# mark the rejection
cv2.putText(img_marked, 'Reject', (10, 20), cv2.FONT_HERSHEY_SIMPLEX, 0.5, (0, 0, 0), 1)
angle = np.nan
return rej, angle, img_marked
================================================
FILE: analysis/eval_phys_single_pendulum/physics_estimator.py
================================================
'''
This script provides utility functions estimating angular velocities
and other physical quantities from angles of single pendulum.
'''
import numpy as np
from scipy.interpolate import CubicSpline
# physical parameters
fps = 60 # frames per second
l = 0.5 # pendulum rod length (m)
m = 1.0 # bob mass (kg)
g = 9.81 # gravitational acceleration (m/s^2)
'''
Calculate the absolute difference between two angles th1 and th2 on a circle.
Assumed that the absolute difference between the two angles is within range (0,pi).
'''
def calc_diff(th1, th2):
diff = np.abs(th2 - th1)
diff = np.minimum(diff, 2*np.pi-diff)
return diff
'''
Calculate the average of two angles th1 and th2 on a circle.
Assumed that the absolute difference between the two angles is within range (0,pi).
'''
def calc_avrg(th1, th2):
avrg = (th1 + th2) / 2
diff = np.abs(th2 - th1)
if diff > np.pi:
avrg -= np.pi
if avrg < 0:
avrg += 2*np.pi
return avrg
'''
Normalize the angle to (-pi, pi).
'''
def normalize_angle(theta):
return np.arctan2(np.sin(theta), np.cos(theta))
'''
Calculate angular velocities from a sequence of angles
using numerical differentiation.
method='fd': finite difference;
method='spline': cubic spline fitting.
'''
def calc_velocity(th, method='spline'):
len_seq = th.shape[0]
# isolated data
if len_seq == 1:
return np.nan
# preprocessing: periodic extension of angles
for i in range(1, len_seq):
if th[i] - th[i-1] > np.pi:
th[i:] -= 2*np.pi
elif th[i] - th[i-1] < -np.pi:
th[i:] += 2*np.pi
vel_th = np.zeros(len_seq)
# finite difference
if method == 'fd':
for i in range(1, len_seq):
vel_th[i] = (th[i] - th[i-1]) * fps
vel_th[0] = (th[1] - th[0]) * fps
# cubic spline fitting
elif method == 'spline':
t = np.arange(len_seq) / fps
cs = CubicSpline(t, th)
vel_th = cs(t, 1)
# use finite difference at boundary points to improve accuracy
vel_th[0] = (th[1] - th[0]) * fps
vel_th[-1] = (th[-1] - th[-2]) * fps
else:
assert False, 'Unrecognizable differentiation method!'
return vel_th
'''
Calculate energies from angles and angular velocities
Moment of inertia of the pendulum: I=ml^2/3
'''
def calc_energy(th, vel_th):
T = m * l**2 / 6 * vel_th**2
V = - m * g * l / 2 * np.cos(th)
E = T + V
return T, V, E
================================================
FILE: analysis/eval_regression.py
================================================
import os
import sys
import numpy as np
from tqdm import tqdm
import json
import yaml
import pprint
from munch import munchify
from latent_regression import pca, mlp_regress
def load_config(filepath):
with open(filepath, 'r') as stream:
try:
trainer_params = yaml.safe_load(stream)
return trainer_params
except yaml.YAMLError as exc:
print(exc)
# parse the video no. and frame no. from the data id (example : '7_0.png')
def parse_data_id(data_id):
lhs, rhs = data_id.split('_')
vid_n = int(lhs)
frm_n = int(rhs.split('.')[0])
return vid_n, frm_n
def physical_variables_from_data_ids(phys_all, ids):
phys_vars_list = []
for p_var in phys_all.keys():
if p_var == 'reject':
continue
for t in range(4):
phys_vars_list.append(f'{p_var} (t={t})')
num_data = ids.shape[0]
phys = {p_var:np.zeros(num_data) for p_var in phys_vars_list}
for n in range(num_data):
vid_n, frm_n = parse_data_id(ids[n])
for p_var in phys_all.keys():
if p_var == 'reject':
continue
for t in range(4):
phys[f'{p_var} (t={t})'][n] = phys_all[p_var][vid_n, frm_n+t]
return phys
def main():
config_filepath = str(sys.argv[1])
cfg = load_config(filepath=config_filepath)
pprint.pprint(cfg)
cfg = munchify(cfg)
if_refine = ('refine' in cfg.model_name)
phys_all = np.load(os.path.join(cfg.data_filepath, cfg.dataset, 'phys_vars.npy'), allow_pickle=True).item()
log_dir = '_'.join([cfg.log_dir, cfg.dataset, cfg.model_name, str(cfg.seed)])
# latent vectors and physical variables (train and test)
ids_train = np.load(os.path.join(log_dir, 'variables_train', 'ids.npy'))
ids_test = np.load(os.path.join(log_dir, 'variables', 'ids.npy'))
if if_refine:
latent_train = np.load(os.path.join(log_dir, 'variables_train', 'refine_latent.npy'))
latent_test = np.load(os.path.join(log_dir, 'variables', 'refine_latent.npy'))
else:
latent_train = np.load(os.path.join(log_dir, 'variables_train', 'latent.npy'))
latent_test = np.load(os.path.join(log_dir, 'variables', 'latent.npy'))
phys_train = physical_variables_from_data_ids(phys_all, ids_train)
phys_test = physical_variables_from_data_ids(phys_all, ids_test)
phys_vars_list = phys_train.keys()
# remove outliers
is_outlier_train = np.full(latent_train.shape[0], False)
for p_var in phys_vars_list:
is_outlier_train = is_outlier_train | np.isnan(phys_train[p_var])
for p_var in phys_vars_list:
phys_train[p_var] = phys_train[p_var][~is_outlier_train]
latent_train = latent_train[~is_outlier_train]
is_outlier_test = np.full(latent_test.shape[0], False)
for p_var in phys_vars_list:
is_outlier_test = is_outlier_test | np.isnan(phys_test[p_var])
for p_var in phys_vars_list:
phys_test[p_var] = phys_test[p_var][~is_outlier_test]
latent_test = latent_test[~is_outlier_test]
print(f'Valid training samples: {latent_train.shape[0]}; test samples: {latent_test.shape[0]}.')
# only use first few principal components (optional)
if str(sys.argv[2]) == 'NA':
num_components = None
else:
num_components = int(sys.argv[2])
latent_train, latent_test, pca_model = pca(latent_train, latent_test, num_components, cfg.seed)
num_samples = 3
sample_size = int(0.3 * latent_train.shape[0])
train_error = {p_var:np.zeros(num_samples) for p_var in phys_vars_list}
test_error = {p_var:np.zeros(num_samples) for p_var in phys_vars_list}
reg_models = {p_var:np.empty(num_samples, dtype=object) for p_var in phys_vars_list}
rng = np.random.default_rng(cfg.seed)
for i in range(num_samples):
print('random samples #'+str(i+1))
samp_ids = rng.choice(latent_train.shape[0], sample_size, replace=False)
for p_var in phys_vars_list:
print('doing '+p_var+' regression...')
train_error[p_var][i], test_error[p_var][i], reg_models[p_var][i] = mlp_regress(latent_train[samp_ids], latent_test, phys_train[p_var][samp_ids], phys_test[p_var], cfg.seed)
if num_components == None:
np.save(os.path.join(log_dir, 'variables', 'regression_results.npy'), [train_error, test_error, reg_models])
else:
np.save(os.path.join(log_dir, 'variables', 'regression_results_pca_'+str(num_components)+'.npy'), [train_error, test_error, pca_model, reg_models])
if __name__ =='__main__':
main()
================================================
FILE: analysis/intrinsic_dimension_estimation/__init__.py
================================================
import numpy as np
from .methods import *
class ID_Estimator:
def __init__(self, method='Levina_Bickel'):
self.all_methods = ['Levina_Bickel', 'MiND_ML', 'MiND_KL', 'Hein', 'CD']
self.set_method(method)
def set_method(self, method='Levina_Bickel'):
if method not in self.all_methods:
assert False, 'Unknown method!'
else:
self.method = method
def fit(self, X, k_list=20, n_jobs=4):
if self.method in ['Hein', 'CD']:
dim_Hein, dim_CD = Hein_CD(X)
return dim_Hein if self.method=='Hein' else dim_CD
else:
if np.isscalar(k_list):
k_list = np.array([k_list])
else:
k_list = np.array(k_list)
kmax = np.max(k_list) + 2
dists, inds = kNN(X, kmax, n_jobs)
dims = []
for k in k_list:
if self.method == 'Levina_Bickel':
dims.append(Levina_Bickel(X, dists, k))
elif self.method == 'MiND_ML':
dims.append(MiND_ML(X, dists, k))
elif self.method == 'MiND_KL':
dims.append(MiND_KL(X, dists, k))
else:
pass
if len(dims) == 1:
return dims[0]
else:
return np.array(dims)
def fit_all_methods(self, X, k_list=[20], n_jobs=4):
k_list = np.array(k_list)
kmax = np.max(k_list) + 2
dists, inds = kNN(X, kmax, n_jobs)
dim_all_methods = {method:[] for method in self.all_methods}
dim_all_methods['Hein'], dim_all_methods['CD'] = Hein_CD(X)
for k in k_list:
dim_all_methods['Levina_Bickel'].append(Levina_Bickel(X, dists, k))
dim_all_methods['MiND_ML'].append(MiND_ML(X, dists, k))
dim_all_methods['MiND_KL'].append(MiND_KL(X, dists, k))
for method in self.all_methods:
dim_all_methods[method] = np.array(dim_all_methods[method])
return dim_all_methods
================================================
FILE: analysis/intrinsic_dimension_estimation/matlab_codes/DANCo.m
================================================
function [d,kl] = DANCo(data,varargin)
% DANCO Estmating the intrinsic dimensionality of a dataset
%
% function [d,kl] = DANCo(data, ParamName,ParamValue, ...)
%
% This funciton estimates the intrinsic dimensionality of a given dataset
% by means of the DANCo algorithm described in:
%
% "DANCo: Dimensionality from Angle and Norm Concentration"
% C. Ceruti, S. Bassis, A. Rozza, G. Lombardi, E. Casiraghi, P. Campadelli
% arXiv:1206.3881v1, http://arxiv.org/abs/1206.3881v1
%
% with the complexity improvement given by separating the training step
% from the evaluation one (requires fitting models in the file DANCo_fits).
%
% Parameters
% ----------
% IN:
% data = The data matrix (DxN) with a sample per column.
% Named parameters:
% 'k'
% The number of neighbours to be used, must be >= 1. (def=10)
% 'minDim'
% The minimal number of dimensions. (def=1)
% 'maxDim'
% The maximal number of dimensions. (def=size(data,1))
% 'sigma'
% Standard deviation of the gaussian smoothing filter executed on
% the estimated divergences. (def=[]=no smoothing)
% 'fractal'
% Is the fractal dimension required? (def=false)
% 'mlMethod'
% Algorithm used to pre-estimate d:
% MLE = Levina's algorithm.
% MiND_MLI = ML on the first neighbour.
% MiND_MLK = ML on the first neighbour and optimization.
% (def='MiND_MLK')
% 'minCorrectionDim'
% Minimal dimensionality estimated with the selected mlMethod such
% that DANCO is adopted for correction, for lower dimensionalities
% the mlMethod result is produced. (def=5)
% 'inds'
% Precomputed knn indices as returned by the KNN function for k
% set to k+2 with respect to the given k parameter. (also dists must
% be present)
% 'dists'
% Precomputed knn distances as returned by the KNN function for k
% set to k+2 with respect to the given k parameter. (also inds must
% be present)
% 'normalized'
% Are the inds/dists already normalized? Normalized here means that
% all the k+2 distances are normalized wrt the last one and the first
% (zero) and the last (one) are removed. (def=true)
% OUT:
% d = Estimated intrinsic dimensionality of the dataset.
% kl = The Kullback Leibler divergences curve for d=1..D.
%
% Examples
% --------
% X = randsphere(30,1000,1);
% V = linSubspSpanOrthonormalize(randn(120,30));
% pts = V*X;
% [inds,dists] = KNN(pts,12,true);
% [d,kl] = DANCo(pts,'inds',inds,'dists',dists,'minDim',20,'maxDim',40);
% Checking parameters:
if nargin<1; error('A dataset is required'); end
% Infos:
[D,N] = size(data);
% Default parameters:
params = struct('k',{10}, ...
'minDim',{1}, 'maxDim',{D}, ...
'fractal',{false}, ...
'sigma',{[]},...
'mlMethod',{'MiND_MLK'}, ...
'normalized',{true}, ...
'minCorrectionDim',{5});
% Parsing named parameters:
if nargin > 1
try
params = parseParamsNamed(varargin, false, params);
catch e
error('Pairs ''name,value'' are required as arguments after the dataset.');
end
end
% Estimating the parameters for the real data:
[isLowDim,dHat,mu,tau] = DANCo_statistics(data,params.k,params,nargout > 1);
% Correction based on the KL-divergence:
if not(isLowDim) || nargout > 1
% Initializing the parameters:
params2 = struct( ...
'mlMethod',{params.mlMethod}, ...
'minCorrectionDim',{params.minCorrectionDim});
numDims = params.maxDim - params.minDim + 1;
% Computing the reference parameters:
dHat_ref = zeros(1,numDims);
mu_ref = zeros(1,numDims);
tau_ref = zeros(1,numDims);
for i = 1:numDims
% Generating the dataset:
data2 = randsphere(params.minDim + i - 1, N);
% Estimating the parameters:
[~,dHat_ref(i),mu_ref(i),tau_ref(i)] = ...
DANCo_statistics(data2,params.k,params2,true);
end
% Estimating the KL-divergence for all the cases d=1:D:
kl = DANCo_estimateKL(params.k,dHat,mu,tau,dHat_ref,mu_ref,tau_ref);
end
% Smoothing if required:
if (not(isLowDim) || nargout > 1) && not(isempty(params.sigma))
% Preparing the impulse response:
rad = 4*ceil(params.sigma/2);
h = gauss(-rad:rad,params.sigma,0,false);
h = h/sum(h);
% Filtering:
kl = conv([flipdim(kl,2),kl,kl],h,'same');
kl = kl(numDims+1:end-numDims);
end
% The dimensionality estimation:
if isLowDim
% Using the MLE estimation:
if params.fractal; d = dHat;
else d = round(dHat); end
else
% Selecting the minimum kl position:
[~,d] = min(kl);
% Refining for the fractal dimension:
if params.fractal
% Fitting with a cubic smoothing spline:
fn = csapi(1:numDims,kl);
% Locating the minima:
opts = optimset('Display','off','TolX',1e-3);
d = fminsearch(@(x)(fnval(fn,x)),d,opts);
end
end
% Correcting the dimension considering the minimal one:
d = d + params.minDim - 1;
end
================================================
FILE: analysis/intrinsic_dimension_estimation/matlab_codes/DANCoFit.m
================================================
function [d,kl] = DANCoFit(data,varargin)
% DANCOFIT Estmating the intrinsic dimensionality of a dataset
%
% function [d,kl] = DANCoFit(data, ParamName,ParamValue, ...)
%
% This funciton estimates the intrinsic dimensionality of a given dataset
% by means of the fast DANCo algorithm described in:
%
% "DANCo: Dimensionality from Angle and Norm Concentration"
% C. Ceruti, S. Bassis, A. Rozza, G. Lombardi, E. Casiraghi, P. Campadelli
% arXiv:1206.3881v1, http://arxiv.org/abs/1206.3881v1
%
% with the complexity improvement given by separating the training step
% from the evaluation one (requires fitting models in the file DANCo_fits).
%
% Parameters
% ----------
% IN:
% data = The data matrix (DxN) with a sample per column.
% Named parameters:
% 'fractal'
% Is the fractal dimension required? (def=false)
% 'mlMethod'
% Algorithm used to pre-estimate d:
% MLE = Levina's algorithm.
% MiND_MLI = ML on the first neighbour.
% MiND_MLK = ML on the first neighbour and optimization.
% (def='MiND_MLK')
% 'minCorrectionDim'
% Minimal dimensionality estimated with the selected mlMethod such
% that DANCO is adopted for correction, for lower dimensionalities
% the mlMethod result is produced. (def=5)
% 'inds'
% Precomputed knn indices as returned by the KNN function for k
% set to k+2 with respect to the given k parameter. (also dists must
% be present)
% 'dists'
% Precomputed knn distances as returned by the KNN function for k
% set to k+2 with respect to the given k parameter. (also inds must
% be present)
% 'normalized'
% Are the inds/dists already normalized? Normalized here means that
% all the k+2 distances are normalized wrt the last one and the first
% (zero) and the last (one) are removed. (def=true)
% 'modelfile'
% The name of the model file to be used. (def='DANCo_fits')
% OUT:
% d = Estimated intrinsic dimensionality of the dataset.
% kl = The Kullback Leibler divergences curve for d=1..D.
%
% Examples
% --------
% X = randsphere(30,1000,1);
% V = linSubspSpanOrthonormalize(randn(120,30));
% pts = V*X;
% [inds,dists] = KNN(pts,12,true);
% [d,kl] = DANCoFit(pts,'inds',inds,'dists',dists);
% Checking parameters:
if nargin<1; error('A dataset is required'); end
% Infos:
[D,N] = size(data);
d = 1:D;
% Default parameters:
params = struct('fractal',{false}, ...
'mlMethod',{'MiND_MLK'}, ...
'normalized',{true}, ...
'minCorrectionDim',{5}, ...
'modelfile',{'DANCo_fits'});
% Parsing named parameters:
if nargin > 1
try
params = parseParamsNamed(varargin, false, params);
catch e
error('Pairs ''name,value'' are required as arguments after the dataset.');
end
end
% Loading the model:
load(params.modelfile);
% Estimating the parameters:
[isLowDim,dHat,mu,tau] = DANCo_statistics(data,k,params,nargout > 1);
% Correction based on the KL-divergence:
if not(isLowDim) || nargout > 1
% Computing the reference parameters:
dHat_ref = feval(fitDhat,d,N);
mu_ref = feval(fitMu,d,N);
tau_ref = feval(fitTau,d,N);
% Estimating the KL-divergence for all the cases d=1:D:
kl = DANCo_estimateKL(k,dHat,mu,tau,dHat_ref,mu_ref,tau_ref);
end
% The dimensionality estimation:
if isLowDim
% Using the MLE estimation:
if params.fractal; d = dHat;
else d = round(dHat); end
else
% Selecting the minimum kl position:
[~,d] = min(kl);
% Refining for the fractal dimension:
if params.fractal
% Fitting with a cubic smoothing spline:
fn = csapi(1:D,kl);
% Locating the minima:
opts = optimset('Display','off','TolX',1e-3);
d = fminsearch(@(x)(fnval(fn,x)),d,opts);
end
end
end
================================================
FILE: analysis/intrinsic_dimension_estimation/matlab_codes/DANCoTrain.m
================================================
function DANCoTrain(modelfile,varargin)
% DANCoTrain Training the DANCoFit model file.
%
% function DANCoTrain(modelfile, ParamName,ParamValue, ...)
%
% This funciton executes experiments with points uniformly drawn from
% hyper-spheres with unitary radius to produce the fitting functions used
% by DANCoFit, if you use this please cite:
%
% "DANCo: Dimensionality from Angle and Norm Concentration"
% C. Ceruti, S. Bassis, A. Rozza, G. Lombardi, E. Casiraghi, P. Campadelli
% arXiv:1206.3881v1, http://arxiv.org/abs/1206.3881v1
%
% Parameters
% ----------
% IN:
% modelfile = The name of the model file to be produced.
% Named parameters:
% 'k'
% The number of neighbours to be used, must be >= 1. (def=10)
% 'maxDim'
% The maximal dimensionality to be used in the experiments, more
% dims means more computation but also accurate fits. (def=100)
% 'cardinalities'
% The list of cardinalities to be used in the experiments, more
% cardinalities means more computation but also accurate fits, the
% suggested choice is to adopt an 1-2-5 series.
% (def=[50,100,200,500,1000,2000,5000])
% 'iterations'
% The number of iterations for experiment (results averaged), more
% iterations means more computation but also accurate fits. (def=100)
% 'mlMethod'
% Algorithm used to pre-estimate d:
% MLE = Levina's algorithm.
% MiND_MLI = ML on the first neighbour.
% MiND_MLK = ML on the first neighbour and optimization.
% (def='MiND_MLK')
%
% Example
% -------
% DANCoTrain('sampleModel','maxDim',20,'cardinalities',[200,500,1000],'iterations',1);
% X = randsphere(10,500);
% V = linSubspSpanOrthonormalize(randn(20,10));
% pts = V*X;
% DANCoFit(pts,'modelfile','sampleModel')
% Checking parameters:
if nargin<1; error('A model file name is required.'); end
% Default parameters:
params = struct('k',{10}, ...
'maxDim',{100}, ...
'cardinalities',{[50,100,200,500,1000,2000,5000]}, ...
'iterations',{100}, ...
'mlMethod',{'MiND_MLK'});
% Parsing named parameters:
if nargin > 1
try
params = parseParamsNamed(varargin, false, params);
catch e
error('Pairs ''name,value'' are required as arguments after the dataset.');
end
end
% Parameters to be passed to the statistics computation function:
params2 = struct( ...
'mlMethod',{params.mlMethod}, ...
'minCorrectionDim',{1});
k = params.k;
% Computing the size of the statistic matrices:
N = numel(params.cardinalities);
D = params.maxDim;
% Initialization:
dHat = zeros(D-1,N);
mu = zeros(D-1,N);
tau = zeros(D-1,N);
for d = 2:D
for n = 1:N
% Initializing the data of this iteration:
dHat_ref = zeros(1,params.iterations);
mu_ref = zeros(1,params.iterations);
tau_ref = zeros(1,params.iterations);
% Executing the experiments:
for i = 1:params.iterations
% Generating the dataset:
data = randsphere(d, params.cardinalities(n));
% Sayng to the user what I'm doing:
fprintf('(d = %d \tn = %d \ti = %d)...', ...
d,params.cardinalities(n),i);
% Estimating the parameters:
[~,dHat_ref(i),mu_ref(i),tau_ref(i)] = ...
DANCo_statistics(data,k,params2,true);
% Sayng to the user what I'm doing:
fprintf(' \tDONE!\n');
end
% Storing the results:
dHat(d-1,n) = mean(dHat_ref);
mu(d-1,n) = mean(mu_ref);
tau(d-1,n) = mean(tau_ref);
end
end
% Sayng to the user what I'm doing:
fprintf('Fitting & saving...');
% Initializing:
inVars = {2:D,params.cardinalities};
% Fitting the funcitons:
fitDhatFun = fnxtr(csaps(inVars,dHat),2);
fitMuFun = fnxtr(csaps(inVars,mu),2);
fitTauFun = fnxtr(csaps(inVars,tau),2);
% Producing function handles:
fitDhat = @(D,N)(fnval(fitDhatFun,{D,N})');
fitMu = @(D,N)(fnval(fitMuFun,{D,N})');
fitTau = @(D,N)(fnval(fitTauFun,{D,N})');
% Writing the model:
save(modelfile,'fitMu','fitTau','fitDhat','k');
% Sayng to the user what I'm doing:
fprintf(' \tDONE!\n');
end
================================================
FILE: analysis/intrinsic_dimension_estimation/matlab_codes/KNN.m
================================================
function [inds,dists] = KNN(X,k,normalized)
%KNN A multi-version knnsearch
%
% function [inds,dists] = KNN(X,k)
%
% This function allows to identify the indexes (and optionally the
% distances) of the first k neighbours of each given columnwise point.
%
% IN:
% X = The dataset, each column represents a point.
% k = The number of neighbours of interest. (def=10)
% normalized = Must the k neighbours be normalized?
% (triggers a k+2 search, def=false)
% OUT:
% inds = Each row i-th contains the neighbour indexes of the i-th point.
% dists = Each row i-th contains the neighbour distances of the i-th point.
% Checking parameters:
if nargin<1; error('Dataset required.'); end
if nargin<2; k=10; end
if nargin<3; normalized=false; end
% Managing th normalized:
if normalized; k=k+2; end
% Checking the version:
if datenum(version('-date')) < 734729
% Computing all the distances:
dists = L2(X, X);
% Sorting:
[dists, inds] = sort(dists, 2);
% Choosing the first k elements:
dists = dists(:,1:k);
inds = inds(:,1:k);
else
% The Matlab implementation:
X = X';
[inds, dists] = knnsearch(X,X,'K',k);
end
% Managing th normalized:
if normalized
% Cropping both inds and dists:
inds = inds(:,2:end-1);
dists = dists(:,2:end);
% Normalizing and removing the last element:
dists = dists(:,1:end-1)./repmat(dists(:,end),[1,size(dists,2)-1]);
end
end
% ------------------------ LOCAL FUNCTIONS ------------------------
% L2 distance (by Roland Bunschoten):
function d = L2(a,b)
d = real(sqrt(bsxfun(@plus, sum(a .* a)', bsxfun(@minus, sum(b .* b), 2 * a' * b))));
end
================================================
FILE: analysis/intrinsic_dimension_estimation/matlab_codes/MLE.m
================================================
function [d,ds] = MLE(data,varargin)
%MLE Intrinsic dimensionality using the Levina's MLE technique
%
% function [d,ds] = MLE(data, ParamName,ParamValue, ...)
%
% This funciton estimates the intrinsic dimensionality of a dataset using
% the Levina's Maximum Likelihood Estimator (MLE).
%
% Parameters
% ----------
% IN:
% data = Matrix DxN containing the dataset as columnwise points.
% Named parameters:
% 'k'
% The number of neighbours to be used, must be >= 1. (def=10)
% 'dists'
% Precomputed knn distanced as returned by the KNN function for k
% set to k+2 with respect to the given k parameter (k is set to
% "size(dists,2)-2" if knn is present).
% 'normalized'
% Are the dists already normalized? Normalized here means that all
% the k+2 distances are normalized wrt the last one and the first
% (zero) and the last (one) are removed. (def=true)
% OUT:
% d = Estimated intrinsic dimensionality of the dataset.
% ds = Local estimations.
%
% Examples
% --------
% X = randsphere(30,1000,1);
% V = linSubspSpanOrthonormalize(randn(120,30));
% pts = V*X;
% [inds,dists] = KNN(pts,12,true);
% d = MLE(pts,'dists',dists);
% Checking parameters:
if nargin<1; error('A dataset is required'); end
% Infos:
N = size(data,2);
% Default parameters:
params = struct('k',{10},'normalized',{true});
% Parsing named parameters:
if nargin > 1
try
params = parseParamsNamed(varargin, false, params);
catch e
error('Pairs ''name,value'' are required as arguments after the dataset.');
end
end
% Is the knn already there?
mustDoKnn = true;
if isfield(params,'dists')
% Extracting and checking:
dists = params.dists;
if size(dists,1) == N && size(dists,2) > 2
% KNN already present:
params.k = size(dists,2)-2;
mustDoKnn = false;
end
end
% Finding the KNNs:
if mustDoKnn
if not(isfield(params,'k'))
error('One parameter of ''dists'' or ''k'' is required.');
end
[~,dists] = KNN(data,params.k,true);
end
% Normalizing the distances:
if not(mustDoKnn || params.normalized)
% Cropping the dists:
dists = dists(:,2:end);
% Normalizing and removing the last element:
dists = dists(:,1:end-1)./repmat(dists(:,end),[1,size(dists,2)-1]);
end
% Local estimation:
ds = -1./mean(log(dists),2);
% Harmonic mean:
d = 1./mean(1./ds);
end
================================================
FILE: analysis/intrinsic_dimension_estimation/matlab_codes/MiND_KL.m
================================================
function [d,kl] = MiND_KL(data,varargin)
%MiND_KL Intrinsic dimensionality using the MiND_KL technique
%
% function [d,kl] = MiND_KL(data, ParamName,ParamValue, ...)
%
% This funciton estimates the intrinsic dimensionality of a dataset using
% the Minimum Neighbor Distance estimators described in:
%
% "Minimum Neighbor Distance Estimators of Intrinsic Dimension",
% A.Rozza, G.Lombardi, C.Ceruti, E.Casiraghi, P.Campadelli,
% Published to the European Conference of Machine Learning (ECML 2011).
%
% Parameters
% ----------
% IN:
% data = Matrix DxN containing the dataset as columnwise points.
% Named parameters:
% 'k'
% The number of neighbours to be used, must be >= 1. (def=10)
% 'minDim'
% The minimal number of dimensions. (def=1)
% 'maxDim'
% The maximal number of dimensions. (def=size(data,1))
% 'sigma'
% Standard deviation of the gaussian smoothing filter executed on
% the estimated divergences. (def=[]=no smoothing)
% 'dists'
% Precomputed knn distanced as returned by the KNN function for k
% set to k+2 with respect to the given k parameter (k is set to
% "size(dists,2)-2" if knn is present).
% 'normalized'
% Are the dists already normalized? Normalized here means that all
% the k+2 distances are normalized wrt the last one and the first
% (zero) and the last (one) are removed. (def=true)
% OUT:
% d = Estimated intrinsic dimensionality of the dataset.
% kl = The Kullback Leibler divergences curve for d=1..D.
%
% Examples
% --------
% X = randsphere(30,1000,1);
% V = linSubspSpanOrthonormalize(randn(120,30));
% pts = V*X;
% [inds,dists] = KNN(pts,12,true);
% [d,kl] = MiND_KL(pts,'dists',dists);
% Checking parameters:
if nargin<1; error('A dataset is required'); end
% Infos:
[D,N] = size(data);
% Default parameters:
params = struct('k',{10}, ...
'normalized',{true}, ...
'minDim',{1}, 'maxDim',{D}, ...
'sigma',[]);
% Parsing named parameters:
if nargin > 1
try
params = parseParamsNamed(varargin, false, params);
catch e
error('Pairs ''name,value'' are required as arguments after the dataset.');
end
end
% Is the knn already there?
mustDoKnn = true;
if isfield(params,'dists')
% Extracting and checking:
dists = params.dists;
if size(dists,1) == N && size(dists,2) > 2
% KNN already present:
params.k = size(dists,2)-2;
mustDoKnn = false;
end
end
% Finding the KNNs:
if mustDoKnn
if not(isfield(params,'k'))
error('One parameter of ''dists'' or ''k'' is required.');
end
[~,dists] = KNN(data,params.k+2);
end
% Normalizing the distances:
if mustDoKnn || not(params.normalized)
% Cropping the dists:
dists = dists(:,2:end);
% Normalizing and removing the last element:
dists = dists(:,1:end-1)./repmat(dists(:,end),[1,size(dists,2)-1]);
end
% Only the first normalized neighbour is required:
k = size(dists,2);
dists = dists(:,1)';
% Executing the experiments with unit uniformly-sampled hyper-spheres:
numDims = params.maxDim - params.minDim + 1;
kl = zeros(1,numDims);
for i=1:numDims
% Generating the data:
data2 = randsphere(params.minDim + i - 1, N);
% Computing the normalized knn distances:
[~,distsExp] = KNN(data2,k,true);
distsExp = distsExp(:,1)';
% Estimating the Kullback-Leibler divergence:
kl(i) = wangKL1d(distsExp,dists);
end
% Smoothing if required:
if not(isempty(params.sigma))
% Preparing the impulse response:
rad = 4*ceil(params.sigma/2);
h = gauss(-rad:rad,params.sigma,0,false);
h = h/sum(h);
% Filtering:
kl = conv([flipdim(kl,2),kl,kl],h,'same');
kl = kl(numDims+1:end-numDims);
end
% Estimating the id:
[~,d] = min(kl);
d = d + params.minDim - 1;
end
% ------------------------ LOCAL FUNCTIONS ------------------------
% Wang's Kullback-Leibler divergence estimator in one dimension:
function div = wangKL1d(data1,data2)
% Getting data:
n = numel(data1);
m = numel(data2);
data1 = sort(data1);
% Generating the nearest neighbors for data1:
nnData1 = [-inf,data1,inf];
nnData1 = abs(nnData1(1:end-1)-nnData1(2:end));
nnData1 = min([nnData1(1:end-1);nnData1(2:end)],[],1);
% Generating the nearest neighbors for data2:
nnData2 = min(abs(repmat(data1,[m,1]) - repmat(data2',[1,n])),[],1);
% Computing the kl div:
div = abs(sum(log(nnData2./(nnData1+eps)))/n + log(m/(n-1)));
end
================================================
FILE: analysis/intrinsic_dimension_estimation/matlab_codes/MiND_ML.m
================================================
function d = MiND_ML(data,varargin)
%MiND_ML Intrinsic dimensionality using the MiND_ML techniques
%
% function d = MiND_ML(data, ParamName,ParamValue, ...)
%
% This funciton estimates the intrinsic dimensionality of a dataset using
% the Minimum Neighbor Distance estimators described in:
%
% "Minimum Neighbor Distance Estimators of Intrinsic Dimension",
% A.Rozza, G.Lombardi, C.Ceruti, E.Casiraghi, P.Campadelli,
% Published to the European Conference of Machine Learning (ECML 2011).
%
% Parameters
% ----------
% IN:
% data = Matrix DxN containing the dataset as columnwise points.
% Named parameters:
% 'k'
% The number of neighbours to be used, must be >= 1. (def=10)
% 'optimize'
% Must an optimization step be executed to estimate a fractal id,
% that is MiND_MLK instead of MiND_MLI? (def=false)
% 'dists'
% Precomputed knn distanced as returned by the KNN function for k
% set to k+2 with respect to the given k parameter (k is set to
% "size(dists,2)-2" if knn is present).
% 'normalized'
% Are the dists already normalized? Normalized here means that all
% the k+2 distances are normalized wrt the last one and the first
% (zero) and the last (one) are removed. (def=true)
% OUT:
% d = Estimated intrinsic dimensionality of the dataset.
%
% Examples
% --------
% X = randsphere(30,1000,1);
% V = linSubspSpanOrthonormalize(randn(120,30));
% pts = V*X;
% [inds,dists] = KNN(pts,12,true);
% d = MiND_ML(pts,'dists',dists);
% Checking parameters:
if nargin<1; error('A dataset is required'); end
% Infos:
[D,N] = size(data);
% Default parameters:
params = struct('k',{10},'optimize',{false},'normalized',{true});
% Parsing named parameters:
if nargin > 1
try
params = parseParamsNamed(varargin, false, params);
catch e
error('Pairs ''name,value'' are required as arguments after the dataset.');
end
end
% Is the knn already there?
mustDoKnn = true;
if isfield(params,'dists')
% Extracting and checking:
dists = params.dists;
if size(dists,1) == N && size(dists,2) > 2
% KNN already present:
params.k = size(dists,2)-2;
mustDoKnn = false;
end
end
% Finding the KNNs:
if mustDoKnn
if not(isfield(params,'k'))
error('One parameter of ''dists'' or ''k'' is required.');
end
[~,dists] = KNN(data,params.k,true);
end
% Normalizing the distances:
if not(mustDoKnn || params.normalized)
% Cropping the dists:
dists = dists(:,2:end);
% Normalizing and removing the last element:
dists = dists(:,1:end-1)./repmat(dists(:,end),[1,size(dists,2)-1]);
end
% Infos:
[n,k] = size(dists);
% The first normalized distance:
r = dists(:,1);
% The log likelihood derivative squared:
fun = @(d)((n/d)+sum(log(r)-((k-1).*(log(r).*r.^d))./(1-r.^d)))^2;
% Evaluating it:
vals = zeros(1,D);
for d=1:D; vals(d)=fun(d); end
% MiND_MLI result:
[~,d] = min(vals);
% The optimization:
if params.optimize
opts = optimset('Display','off','TolX',1e-3);
d = fminsearch(fun,d,opts);
end
end
================================================
FILE: analysis/intrinsic_dimension_estimation/matlab_codes/demo_idEstimation.m
================================================
%% Intrinsic Dimensionality (id) estimation
%
% In the past decade the development of automatic techniques to estimate
% the intrinsic dimensionality of a given dataset has gained considerable
% attention due to its relevance in several application elds.
%
% In this small toolbox some of the state-of-art techniques are implemented
% as functions that use a "standard" interface to use them, thus allowing
% client code to be decoupled from the knowledge of the applied technique.
%
% For more details see/cite:
%
% "Minimum Neighbor Distance Estimators of Intrinsic Dimension",
% A.Rozza, G.Lombardi, C.Ceruti, E.Casiraghi, P.Campadelli,
% Published to the European Conference of Machine Learning (ECML 2011).
%
% "DANCo: Dimensionality from Angle and Norm Concentration",
% C. Ceruti, S. Bassis, A. Rozza, G. Lombardi, E. Casiraghi, P. Campadelli
% arXiv:1206.3881v1, http://arxiv.org/abs/1206.3881v1
%% Usage of this id-estimation toolbox
%
% As an example here we generate a simple dataset and test all the
% implemented techniques on it to compare the results, the dataset is an
% hypersphere in R^{10} linearly embedded in R^{20}.
% Generating the dataset:
d = 10; D = 20;
X = randsphere(d,500);
V = linSubspSpanOrthonormalize(randn(D,d));
data = V*X;
% A first base estimation:
fprintf('MLE => %2.2f\n', MLE(data));
fprintf('DANCoFit => %2.2f\n', DANCoFit(data));
%%
% The techniques:
estimators = {'MLE','MiND_ML','MiND_KL','DANCo','DANCoFit'};
% Initializing the results:
idEst = zeros(1,numel(estimators));
spentTime = zeros(1,numel(estimators));
% Running the experiments:
for i = 1:numel(estimators)
% Obtaining the funciton:
estimator = str2func(estimators{i});
% Estimating:
tic;
idEst(i) = estimator(data);
spentTime(i) = toc;
end
% Plotting the results:
figure; bar([idEst(:),spentTime(:)]); hold on;
plot([0,numel(estimators)+1],[d,d],'b:');
set(gca,'xticklabel',estimators);
legend({'Estimated id','Spent time'},'Location','NorthWest');
title(sprintf('Estimating the id of a %dd hypersphere linearly embedded in R^{%d}',d,D));
%% Estimators based on the Kullback-Leibler divergence
%
% Some of the presented algorithms estimate the Kullback-Leibler divergence
% between the distribution of some statistics computed on the real dataset
% and those computed on synthetically-cenerated data (hyperspheres) or by
% means of fitting functions (trained using the statistics produced by
% synthetic data). Here the results obtained by some of them.
% Initialization:
estimators = {'MiND_KL','DANCo','DANCoFit'};
% Initializing the results:
idEst = zeros(1,numel(estimators));
spentTime = zeros(1,numel(estimators));
kls = zeros(numel(estimators),D);
% Running the experiments:
for i = 1:numel(estimators)
% Obtaining the funciton:
estimator = str2func(estimators{i});
% Estimating:
tic;
[idEst(i),kls(i,:)] = estimator(data);
spentTime(i) = toc;
end
% Notice that DANCo produces unreliable results for d=1:
Ds = 2:D;
kls2 = kls(:,Ds);
% Plotting the results:
figure; plot(Ds,kls2'); hold on;
plot([idEst;idEst],[zeros(size(idEst));max(kls2(:))*ones(size(idEst))],':');
legend(estimators,'Location','NorthEast');
title('KL-based id estimatros: the estimated KLs');
================================================
FILE: analysis/intrinsic_dimension_estimation/matlab_codes/gauss.m
================================================
function func = gauss(x, sigma, mu, norm)
% GAUSS Returns the monodimensional gaussian function
%
% Return the evaluation of the gaussian function on an array of points
%
% Params:
%
% x: The array of x points (def=[-10:10])
% sigma: The standard deviation (def=2.5)
% mu: The mean of th e gaussian (def=0)
% norm: Must be normalized? (def=true)
% Check x
if nargin<1
x = -10:10;
end
% Check sigma
if nargin<2
sigma = 2.5;
end
% Check mean
if nargin<3
mu = 0;
end
% Check norm
if nargin<4
norm = true;
end
% Computing the gaussian funcion
if norm
func = exp(-(x-mu).^2/(2*sigma^2))/(sigma*sqrt(2*pi));
else
func = exp(-(x-mu).^2/(2*sigma^2));
end
================================================
FILE: analysis/intrinsic_dimension_estimation/matlab_codes/html/demo_idEstimation.html
================================================
<!DOCTYPE html
PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html><head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<!--
This HTML was auto-generated from MATLAB code.
To make changes, update the MATLAB code and republish this document.
--><title>Intrinsic Dimensionality (id) estimation</title><meta name="generator" content="MATLAB 7.13"><link rel="schema.DC" href="http://purl.org/dc/elements/1.1/"><meta name="DC.date" content="2013-01-31"><meta name="DC.source" content="demo_idEstimation.m"><style type="text/css">
body {
background-color: white;
margin:10px;
}
h1 {
color: #990000;
font-size: x-large;
}
h2 {
color: #990000;
font-size: medium;
}
/* Make the text shrink to fit narrow windows, but not stretch too far in
wide windows. */
p,h1,h2,div.content div {
max-width: 600px;
/* Hack for IE6 */
width: auto !important; width: 600px;
}
pre.codeinput {
background: #EEEEEE;
padding: 10px;
}
@media print {
pre.codeinput {word-wrap:break-word; width:100%;}
}
span.keyword {color: #0000FF}
span.comment {color: #228B22}
span.string {color: #A020F0}
span.untermstring {color: #B20000}
span.syscmd {color: #B28C00}
pre.codeoutput {
color: #666666;
padding: 10px;
}
pre.error {
color: red;
}
p.footer {
text-align: right;
font-size: xx-small;
font-weight: lighter;
font-style: italic;
color: gray;
}
</style></head><body><div class="content"><h1>Intrinsic Dimensionality (id) estimation</h1><!--introduction--><p>In the past decade the development of automatic techniques to estimate the intrinsic dimensionality of a given dataset has gained considerable attention due to its relevance in several application elds.</p><p>In this small toolbox some of the state-of-art techniques are implemented as functions that use a "standard" interface to use them, thus allowing client code to be decoupled from the knowledge of the applied technique.</p><p>For more details see/cite:</p><pre>"Minimum Neighbor Distance Estimators of Intrinsic Dimension",
A.Rozza, G.Lombardi, C.Ceruti, E.Casiraghi, P.Campadelli,
Published to the European Conference of Machine Learning (ECML 2011).</pre><pre>"DANCo: Dimensionality from Angle and Norm Concentration",
C. Ceruti, S. Bassis, A. Rozza, G. Lombardi, E. Casiraghi, P. Campadelli
arXiv:1206.3881v1, http://arxiv.org/abs/1206.3881v1</pre><!--/introduction--><h2>Contents</h2><div><ul><li><a href="#1">Usage of this id-estimation toolbox</a></li><li><a href="#3">Estimators based on the Kullback-Leibler divergence</a></li></ul></div><h2>Usage of this id-estimation toolbox<a name="1"></a></h2><p>As an example here we generate a simple dataset and test all the implemented techniques on it to compare the results, the dataset is an hypersphere in R^{10} linearly embedded in R^{20}.</p><pre class="codeinput"><span class="comment">% Generating the dataset:</span>
d = 10; D = 20;
X = randsphere(d,500);
V = linSubspSpanOrthonormalize(randn(D,d));
data = V*X;
<span class="comment">% A first base estimation:</span>
fprintf(<span class="string">'MLE => %2.2f\n'</span>, MLE(data));
fprintf(<span class="string">'DANCoFit => %2.2f\n'</span>, DANCoFit(data));
</pre><pre class="codeoutput">MLE => 8.07
DANCoFit => 10.00
</pre><pre class="codeinput"><span class="comment">% The techniques:</span>
estimators = {<span class="string">'MLE'</span>,<span class="string">'MiND_ML'</span>,<span class="string">'MiND_KL'</span>,<span class="string">'DANCo'</span>,<span class="string">'DANCoFit'</span>};
<span class="comment">% Initializing the results:</span>
idEst = zeros(1,numel(estimators));
spentTime = zeros(1,numel(estimators));
<span class="comment">% Running the experiments:</span>
<span class="keyword">for</span> i = 1:numel(estimators)
<span class="comment">% Obtaining the funciton:</span>
estimator = str2func(estimators{i});
<span class="comment">% Estimating:</span>
tic;
idEst(i) = estimator(data);
spentTime(i) = toc;
<span class="keyword">end</span>
<span class="comment">% Plotting the results:</span>
figure; bar([idEst(:),spentTime(:)]); hold <span class="string">on</span>;
plot([0,numel(estimators)+1],[d,d],<span class="string">'b:'</span>);
set(gca,<span class="string">'xticklabel'</span>,estimators);
legend({<span class="string">'Estimated id'</span>,<span class="string">'Spent time'</span>},<span class="string">'Location'</span>,<span class="string">'NorthWest'</span>);
title(sprintf(<span class="string">'Estimating the id of a %dd hypersphere linearly embedded in R^{%d}'</span>,d,D));
</pre><img vspace="5" hspace="5" src="demo_idEstimation_01.png" alt=""> <h2>Estimators based on the Kullback-Leibler divergence<a name="3"></a></h2><p>Some of the presented algorithms estimate the Kullback-Leibler divergence between the distribution of some statistics computed on the real dataset and those computed on synthetically-cenerated data (hyperspheres) or by means of fitting functions (trained using the statistics produced by synthetic data). Here the results obtained by some of them.</p><pre class="codeinput"><span class="comment">% Initialization:</span>
estimators = {<span class="string">'MiND_KL'</span>,<span class="string">'DANCo'</span>,<span class="string">'DANCoFit'</span>};
<span class="comment">% Initializing the results:</span>
idEst = zeros(1,numel(estimators));
spentTime = zeros(1,numel(estimators));
kls = zeros(numel(estimators),D);
<span class="comment">% Running the experiments:</span>
<span class="keyword">for</span> i = 1:numel(estimators)
<span class="comment">% Obtaining the funciton:</span>
estimator = str2func(estimators{i});
<span class="comment">% Estimating:</span>
tic;
[idEst(i),kls(i,:)] = estimator(data);
spentTime(i) = toc;
<span class="keyword">end</span>
<span class="comment">% Notice that DANCo produces unreliable results for d=1:</span>
Ds = 2:D;
kls2 = kls(:,Ds);
<span class="comment">% Plotting the results:</span>
figure; plot(Ds,kls2'); hold <span class="string">on</span>;
plot([idEst;idEst],[zeros(size(idEst));max(kls2(:))*ones(size(idEst))],<span class="string">':'</span>);
legend(estimators,<span class="string">'Location'</span>,<span class="string">'NorthEast'</span>);
title(<span class="string">'KL-based id estimatros: the estimated KLs'</span>);
</pre><img vspace="5" hspace="5" src="demo_idEstimation_02.png" alt=""> <p class="footer"><br>
Published with MATLAB® 7.13<br></p></div><!--
##### SOURCE BEGIN #####
%% Intrinsic Dimensionality (id) estimation
%
% In the past decade the development of automatic techniques to estimate
% the intrinsic dimensionality of a given dataset has gained considerable
% attention due to its relevance in several application elds.
%
% In this small toolbox some of the state-of-art techniques are implemented
% as functions that use a "standard" interface to use them, thus allowing
% client code to be decoupled from the knowledge of the applied technique.
%
% For more details see/cite:
%
% "Minimum Neighbor Distance Estimators of Intrinsic Dimension",
% A.Rozza, G.Lombardi, C.Ceruti, E.Casiraghi, P.Campadelli,
% Published to the European Conference of Machine Learning (ECML 2011).
%
% "DANCo: Dimensionality from Angle and Norm Concentration",
% C. Ceruti, S. Bassis, A. Rozza, G. Lombardi, E. Casiraghi, P. Campadelli
% arXiv:1206.3881v1, http://arxiv.org/abs/1206.3881v1
%% Usage of this id-estimation toolbox
%
% As an example here we generate a simple dataset and test all the
% implemented techniques on it to compare the results, the dataset is an
% hypersphere in R^{10} linearly embedded in R^{20}.
% Generating the dataset:
d = 10; D = 20;
X = randsphere(d,500);
V = linSubspSpanOrthonormalize(randn(D,d));
data = V*X;
% A first base estimation:
fprintf('MLE => %2.2f\n', MLE(data));
fprintf('DANCoFit => %2.2f\n', DANCoFit(data));
%%
% The techniques:
estimators = {'MLE','MiND_ML','MiND_KL','DANCo','DANCoFit'};
% Initializing the results:
idEst = zeros(1,numel(estimators));
spentTime = zeros(1,numel(estimators));
% Running the experiments:
for i = 1:numel(estimators)
% Obtaining the funciton:
estimator = str2func(estimators{i});
% Estimating:
tic;
idEst(i) = estimator(data);
spentTime(i) = toc;
end
% Plotting the results:
figure; bar([idEst(:),spentTime(:)]); hold on;
plot([0,numel(estimators)+1],[d,d],'b:');
set(gca,'xticklabel',estimators);
legend({'Estimated id','Spent time'},'Location','NorthWest');
title(sprintf('Estimating the id of a %dd hypersphere linearly embedded in R^{%d}',d,D));
%% Estimators based on the Kullback-Leibler divergence
%
% Some of the presented algorithms estimate the Kullback-Leibler divergence
% between the distribution of some statistics computed on the real dataset
% and those computed on synthetically-cenerated data (hyperspheres) or by
% means of fitting functions (trained using the statistics produced by
% synthetic data). Here the results obtained by some of them.
% Initialization:
estimators = {'MiND_KL','DANCo','DANCoFit'};
% Initializing the results:
idEst = zeros(1,numel(estimators));
spentTime = zeros(1,numel(estimators));
kls = zeros(numel(estimators),D);
% Running the experiments:
for i = 1:numel(estimators)
% Obtaining the funciton:
estimator = str2func(estimators{i});
% Estimating:
tic;
[idEst(i),kls(i,:)] = estimator(data);
spentTime(i) = toc;
end
% Notice that DANCo produces unreliable results for d=1:
Ds = 2:D;
kls2 = kls(:,Ds);
% Plotting the results:
figure; plot(Ds,kls2'); hold on;
plot([idEst;idEst],[zeros(size(idEst));max(kls2(:))*ones(size(idEst))],':');
legend(estimators,'Location','NorthEast');
title('KL-based id estimatros: the estimated KLs');
##### SOURCE END #####
--></body></html>
================================================
FILE: analysis/intrinsic_dimension_estimation/matlab_codes/linSubspSpanOrthonormalize.m
================================================
function Vo = linSubspSpanOrthonormalize(V)
% LINSUBSPSPANORTHONORMALIZE Orthonormalizes a linear subspace span matrix.
%
% function Vo = linSubspSpanOrthonormalize(V)
%
% This funciton takes a DxN matrix that represents a set of N linear
% independent vectors of a D-dimensional space, and that identifies an
% N-dimensional linear subspace, and orthonormalizes them so that the
% subspace spanned is the same but the vectors are versors orthogonal one
% each other. The solutions to this problem are infinitely many, the one
% given is the one that normalizes the first vector, orthonormalizes the
% second with respect to the plane containing the first two vectors,
% orthonormalizes the third with respect to the 3D space spanned by the
% first three vectors and so on. Obviously must be 1<=N<=D.
%
% Parameters
% ----------
% IN:
% V = The DxN matrix containing the N vectors.
% OUT:
% Vo = The orthonormalized linear subspace base.
%
% Pre
% ---
% - The columns of V must be linear independent (i.e. rank(V')==N).
% - The columns of V must be >=1 and <=D.
%
% Post
% ----
% - The returned Vo contains columns that are normal
% (i.e. norm(V(:,i)==1).
% - The returned Vo contains columns that are orthogonal
% (i.e. dot(V(:,i),V(:,j))==0 for i~=j).
% Check params:
if size(V,2)<1 || size(V,2)>size(V,1)
error('N columns must be >=1 and <=D rows!');
end
% Check for linearly dependence:
if rank(V')~=size(V,2)
error('The V vectors must be linearly independent!');
end
% Normalizing the V vectors:
normV = sqrt(sum(V.^2));
normV(normV==0) = eps;
V = V./repmat(normV,[size(V,1),1]);
% Orthogonalizing:
for i=2:size(V,2)
% Computing the projection on the subspace:
proj = V(:,1)*dot(V(:,1),V(:,i));
for j=2:i-1
% The projection of the Vi vector over the Vj orthonormal versor:
proj = proj + V(:,j)*dot(V(:,j),V(:,i));
end
% Removing and normalizing:
V(:,i) = V(:,i) - proj;
V(:,i) = V(:,i)./norm(V(:,i));
end
% Returning:
Vo = V;
================================================
FILE: analysis/intrinsic_dimension_estimation/matlab_codes/parseParamsNamed.m
================================================
function pars = parseParamsNamed(parsCell,recurse,parsi,multi)
% PARSEPARAMSNAMED Getting named parameters as a structure.
%
% function pars = parseParamsNamed(parsCell,recurse,parsi,multi)
%
% This function allows to get named parameters as a struct object. Named
% parameters are sequences of strings and values pair where the string
% represents the name of the parameter and the value its value.
%
% Parameters
% ----------
% IN:
% parsCell = The cell containing the parameters (like varargin).
% recurse = Must the parsing recurse in sub-cells? (def=false)
% parsi = Initial struct (with default values). (def=struct)
% multi = Must the multi-valued fields be grouped in a cell? (def=false)
% OUT:
% pars = The structure containing the parameters.
% Chck parameters:
if nargin<1 || ~isa(parsCell,'cell')
error('A cell with parameters must be passed as parameter!');
end
if nargin<2; recurse=false; end
if nargin<3; parsi=struct; end
if nargin<4; multi=false; end
% Check for the size:
N = numel(parsCell);
if mod(N,2)~=0
error('The cell must contain an even number of elements!');
end
% Init:
pars = parsi;
% Iterating on parameters:
for i=1:2:N
% Get the name:
name = parsCell{i};
if ~isa(name,'char')
error('The name of parameters must be a string!');
end
% Getting the value:
value = parsCell{i+1};
if recurse && isa(value,'cell')
% Generating the substructure:
value = parseParamsNamed(value,recurse);
end
% Checking if multi:
if multi
% Init:
if not(isfield(pars,name))
pars.(name) = {};
end
if not(isa(pars.(name),'cell'))
pars.(name) = {pars.(name)};
end
% Packing:
pars.(name){end+1} = value;
else
% Saving the last:
pars.(name) = value;
end
end
================================================
FILE: analysis/intrinsic_dimension_estimation/matlab_codes/private/DANCo_estimateKL.m
================================================
function kl = DANCo_estimateKL(k,dHat,mu,tau,dHat_ref,mu_ref,tau_ref)
%DANCO_ESTIMATEKL Estimating the Kullback-Leibler divergence for DANCo
%
% function kl = DANCo_estimateKL(k,dHat,mu,tau,dHat_ref,mu_ref,tau_ref)
%
% This function estimates the Kullback-Leibler divergence between the
% distances/angles bivariate distributions over two datasets whose
% statistic parameters are {dHat,mu,tau} and {dHat_ref,mu_ref,tau_ref}
% respectively.
%
% Parameters
% ----------
% IN:
% k = The KNN parameter.
% dHat,mu,tau = Statistics for the real dataset.
% dHat_ref,mu_ref,tau_ref = Statistics for the synthetic dataset.
% Checking parameters:
if nargin<7; error('Too few parameters'); end
% Doing the computation:
kl = EstimateKL_dists(dHat,dHat_ref,k) + ...
EstimateKL_angles(mu,tau,mu_ref,tau_ref);
end
% ------------------------ LOCAL FUNCTIONS ------------------------
% Estimating the KL-divergence for all the cases d=1:D:
function kl = EstimateKL_angles(m1,k1,m2,k2)
% The bessel values:
bk2 = besseli(0,k2);
bk1 = besseli(0,k1);
ak1 = besseli(1,k1);
ck1 = besseli(1,-k1);
% Checking for infs:
if(isinf(k1)); k1 = realmax; end
k2(isinf(k2)) = realmax;
bk2(isinf(bk2)) = realmax;
if(isinf(bk1)); bk1 = realmax; end
if(isinf(ak1)); ak1 = realmax; end
if(isinf(ck1)); ck1 = realmax; end
% Computing the KL:
kl = abs(log(bk2./bk1) + (ak1-ck1)./(2*bk1).*(k1-k2.*cos(m2-m1)));
end
% -----------------------------------------------------------------
% Estimating the KL-divergence for the distances:
function kl = EstimateKL_dists(d1,d2,k)
% Initializing:
bin = zeros(numel(d2),k+1);
% Computing the terms in the summary:
for i=1:k+1
bin(:,i) = (-1)^(i-1)*nchoosek(k,i-1).*psi(1+(i-1)*(d1./d2));
end
% Estimating the KL in cloised form:
kl = -(1+harmonic(k-1)-harmonic(k)*(d2./d1)+log(d2./d1)+(k-1)*sum(bin,2)');
end
% -----------------------------------------------------------------
% Harmonic numbers (by David Terr):
function h = harmonic(z)
if z == 1
h = 1;
else
h = log(z) + 0.5772196649 + 1/(2*z) - 1/(12*z^2) + 1/(120*z^4) - 1/(252*z^6);
end
end
================================================
FILE: analysis/intrinsic_dimension_estimation/matlab_codes/private/DANCo_statistics.m
================================================
function [isLowDim,dHat,mu,tau] = DANCo_statistics(data,k,params,force)
%DANCO_STATISTICS Computes the statistics used by DANCo
%
% function [isLowDim,dHat,mu,tau] = DANCo_statistics(data,k,params,force)
%
% This funciton allows to compute the statistic parameters used by DANCo
% to estimate the intrinsic dimensionality, in cas of isLowDim==true only
% the dHat value is computed (the other output values set to 0 in this
% case).
%
% Parameters
% ----------
% IN:
% data = The dataset as a matrix with columnwise vectors.
% k = KNN parameter.
% params = The named parameters passed to DANCo (see DANCo or DANCoFit).
% force = Forces the computation of mu and tau. (def=false).
% OUT:
% isLowDim = True if the intrinsic dimensionality is considered low, in
% this case the dHat estimation is considered good enough.
% dHat = Estimated id by means of biased esimators like MLE or MiND.
% mu,tau = Von Mises circular statistic parameters.
% Checking parameters:
if nargin<3; error('A dataset, k, and the parameters are required'); end
if nargin<4; force=false; end
if not(isa(params,'struct')); error('Params must be a struct'); end
if not(isfield(params,'mlMethod')); error('An mlMethod is required'); end
if not(isfield(params,'minCorrectionDim')); error('A minCorrectionDim is required'); end
% Infos:
N = size(data,2);
% Is the knn already there?
mustDoKnn = true;
if isfield(params,'inds') && isfield(params,'dists')
% Extracting and checking:
inds = params.inds;
dists = params.dists;
if size(dists,1) == N && size(dists,2) >= k+2 && size(inds,1) == N && size(inds,2) >= k+2
% KNN already present:
dists = dists(:,1:k+2);
inds = inds(:,1:k+2);
mustDoKnn = false;
end
end
% Finding the KNNs only if needed:
if mustDoKnn
% It's needed!
[inds,dists] = KNN(data,k,true);
end
% Normalizing the distances:
if not(mustDoKnn || (isfield(params,'normalized') && params.normalized))
% Cropping both dists and inds:
dists = dists(:,2:end);
inds = inds(:,2:end);
% Normalizing and removing the last element:
dists = dists(:,1:end-1)./repmat(dists(:,end),[1,size(dists,2)-1]);
end
% Estimating dHat:
switch params.mlMethod
case 'MLE'
dHat = MLE(data,'dists',dists,'normalized',true);
case 'MiND_MLI'
dHat = MiND_ML(data,'dists',dists,'optimize',false,'normalized',true);
case 'MiND_MLK'
dHat = MiND_ML(data,'dists',dists,'optimize',true,'normalized',true);
otherwise
error(['Unknown mlMethod: ' params.mlMethod]);
end
% Correction based on the KL-divergence:
isLowDim = dHat < params.minCorrectionDim;
if not(isLowDim) || force
% The circular statistics:
angles = ComputeAngles(data,inds);
[mu,tau] = CircStats(angles);
% Averaging the parameters:
mu = angle(sum(exp(1i*mu)));
tau = mean(tau);
else
% Fake parameters:
mu = 0;
tau = 0;
end
end
% ------------------------ LOCAL FUNCTIONS ------------------------
% Computing the used angular statistics:
function [mu,tau] = CircStats(angles)
% Computing the complex circular means:
cm = sum(exp(1i*angles),2);
% Computing the von Mises parameters:
mu = angle(cm);
r = abs(cm)/size(angles,2);
% The R function:
if r < 0.53; tau = 2*r + r.^3 + 5*r.^5./6; else
if r < 0.85; tau = -0.4 + 1.39*r + 0.43./(1-r);
else tau = 1./(r.^3 - 4*r.^2 + 3*r); end
end
% Correcting for small sample sizes:
if size(angles,2) < 15
mask = tau < 2;
tau(mask) = max(tau(mask)-2./(size(angles,2).*tau(mask)),0);
tau(~mask) = (size(angles,2)-1).^3.*tau(~mask)./(size(angles,2).^3+size(angles,2));
end
end
% -----------------------------------------------------------------
% Computing the pairwase angles for neighbours:
function angles = ComputeAngles(data,inds)
% Init:
K = size(inds,2);
angles = zeros(size(inds,1),K*(K-1)/2);
cnk = combnk(1:size(inds,2),2);
% Iterating on points:
for i=1:size(data,2)
% Translating and normalizing points:
pts = data(:,inds(i,:)) - repmat(data(:,i),[1,K]);
pts = pts./repmat(sqrt(sum(pts.^2,1)),[size(pts,1),1]);
% Computing all the pairwise angles:
a = pts(:,cnk(:,1)); b = pts(:,cnk(:,2));
angles(i,:) = atan2(sqrt(sum((b-repmat(sum(a.*b,1),[size(a,1),1]).*a).^2,1)),sum(a.*b,1));
end
end
================================================
FILE: analysis/intrinsic_dimension_estimation/matlab_codes/randsphere.m
================================================
function X = randsphere(d,N,r)
% RANDSPHERE Random points uniformly drawn from a spere with radius r
%
% function X = randsphere(d,N,r)
%
% This function generates random data samples from a uniform hypersphere
% with a given radius. The algorithm is the one reported by Roger Stafford
% on matlabcentral/fileexchange.
%
% Parameters
% ----------
% IN:
% d = Space dimensionality. (def=2)
% N = Number of points. (def=1000)
% r = Hypersphere radius. (def=1)
% OUT:
% X = Matrix of points (columnwise).
% Checking parameters:
if nargin<1; d=2; end
if nargin<2; N=1000; end
if nargin<3; r=1; end
% Gaussian randomly sampled points:
X = randn(d,N);
% Squared norms:
s2 = sum(X.^2,1);
% Correcting the points norms:
X = X.*repmat(r*(gammainc(s2/2,d/2).^(1/d))./sqrt(s2),d,1);
end
================================================
FILE: analysis/intrinsic_dimension_estimation/methods.py
================================================
import numpy as np
import os
from sklearn.neighbors import NearestNeighbors
def kNN(X, n_neighbors, n_jobs):
neigh = NearestNeighbors(n_neighbors=n_neighbors, n_jobs=n_jobs).fit(X)
dists, inds = neigh.kneighbors(X)
return dists, inds
def Levina_Bickel(X, dists, k):
m = np.log(dists[:, k:k+1] / dists[:, 1:k])
m = (k-2) / np.sum(m, axis=1)
dim = np.mean(m)
return dim
def start_matlab_engine():
import matlab.engine
eng = matlab.engine.start_matlab()
eng.addpath(os.path.join(os.path.split(__file__)[0], 'matlab_codes'))
return eng
def MiND_ML(X, dists, k):
import matlab.engine
eng = start_matlab_engine()
X_mat = matlab.double(X.T.tolist())
dists_mat = matlab.double(dists[:, :k+2].tolist())
dim = eng.MiND_ML(X_mat, 'dists', dists_mat, 'normalized', False, 'optimize', True)
return dim
def MiND_KL(X, dists, k, maxDim=30):
import matlab.engine
eng = start_matlab_engine()
X_mat = matlab.double(X.T.tolist())
dists_mat = matlab.double(dists[:, :k+2].tolist())
dim = eng.MiND_KL(X_mat, 'k', matlab.double([k]), 'maxDim', matlab.double([maxDim]),
'dists', dists_mat, 'normalized', False, nargout=1)
return dim
def DANCo(X, dists, inds, k, maxDim=30):
import matlab.engine
eng = start_matlab_engine()
X_mat = matlab.double(X.T.tolist())
dists_mat = matlab.double(dists[:, :k+2].tolist())
inds_mat = matlab.int32((inds[:, :k+2]+1).tolist()) # fit Matlab indices
dim = eng.DANCo(X_mat, 'k', matlab.double([k]), 'maxDim', matlab.double([maxDim]), 'fractal', True,
'dists', dists_mat, 'inds', inds_mat, 'normalized', False, nargout=1)
return dim
def Hein_CD(X):
import matlab.engine
eng = start_matlab_engine()
X_mat = matlab.double(X.T.tolist())
dim = eng.GetDim(X_mat, nargout=1)
dim = np.array(dim)[0]
return dim[0], dim[1]
================================================
FILE: analysis/latent_regression/__init__.py
================================================
from .regressors import *
================================================
FILE: analysis/latent_regression/regressors.py
================================================
import numpy as np
from sklearn.preprocessing import StandardScaler
from sklearn.decomposition import PCA
from sklearn.neural_network import MLPRegressor
from sklearn.linear_model import LinearRegression
def mlp_regress(X_train, X_test, y_train, y_test, random_state=0):
scaler = StandardScaler()
nn = MLPRegressor(hidden_layer_sizes=(64, 64, 64, 64, 64), activation='relu', solver='adam',
learning_rate='adaptive', alpha=0.01, random_state=random_state)
X_train_scaled = scaler.fit_transform(X_train)
X_test_scaled = scaler.transform(X_test)
y_norm = np.max(np.abs(y_train))
nn.fit(X_train_scaled, y_train / y_norm)
train_error = np.mean(np.abs(nn.predict(X_train_scaled) * y_norm - y_train))
test_error = np.mean(np.abs(nn.predict(X_test_scaled) * y_norm - y_test))
return train_error, test_error, {'scaler':scaler, 'model':nn}
def lin_regress(X_train, X_test, y_train, y_test):
reg = LinearRegression()
reg.fit(X_train, y_train)
train_error = np.mean(np.abs(reg.predict(X_train) - y_train))
test_error = np.mean(np.abs(reg.predict(X_test) - y_test))
return train_error, test_error, reg
def pca(X_train, X_test, num_components, random_state=0):
pca = PCA(num_components, random_state=random_state)
pca.fit(X_train)
return pca.transform(X_train), pca.transform(X_test), pca
================================================
FILE: configs/air_dancer/latentpred/config1.yaml
================================================
lr: 0.01
seed: 1
if_cuda: True
gamma: 0.5
log_dir: 'logs'
train_batch: 512
val_batch: 256
test_batch: 256
num_workers: 8
model_name: 'latent-prediction'
data_filepath: './data/'
dataset: 'air_dancer'
lr_schedule: [20, 50, 100, 300]
num_gpus: 1
epochs: 1000
================================================
FILE: configs/air_dancer/latentpred/config2.yaml
================================================
lr: 0.01
seed: 2
if_cuda: True
gamma: 0.5
log_dir: 'logs'
train_batch: 512
val_batch: 256
test_batch: 256
num_workers: 8
model_name: 'latent-prediction'
data_filepath: './data/'
dataset: 'air_dancer'
lr_schedule: [20, 50, 100, 300]
num_gpus: 1
epochs: 1000
================================================
FILE: configs/air_dancer/latentpred/config3.yaml
================================================
lr: 0.02
seed: 3
if_cuda: True
gamma: 0.5
log_dir: 'logs'
train_batch: 512
val_batch: 256
test_batch: 256
num_workers: 8
model_name: 'latent-prediction'
data_filepath: './data/'
dataset: 'air_dancer'
lr_schedule: [20, 50, 100, 300]
num_gpus: 1
epochs: 1000
================================================
FILE: configs/air_dancer/model/config1.yaml
================================================
lr: 0.001
seed: 1
if_cuda: True
gamma: 0.5
log_dir: 'logs'
train_batch: 512
val_batch: 256
test_batch: 256
num_workers: 8
model_name: 'encoder-decoder'
data_filepath: './data/'
dataset: 'air_dancer'
lr_schedule: [20, 50, 100, 300]
num_gpus: 1
epochs: 1000
================================================
FILE: configs/air_dancer/model/config2.yaml
================================================
lr: 0.001
seed: 2
if_cuda: True
gamma: 0.5
log_dir: 'logs'
train_batch: 512
val_batch: 256
test_batch: 256
num_workers: 8
model_name: 'encoder-decoder'
data_filepath: './data/'
dataset: 'air_dancer'
lr_schedule: [20, 50, 100, 300]
num_gpus: 1
epochs: 1000
================================================
FILE: configs/air_dancer/model/config3.yaml
================================================
lr: 0.001
seed: 3
if_cuda: True
gamma: 0.5
log_dir: 'logs'
train_batch: 512
val_batch: 256
test_batch: 256
num_workers: 8
model_name: 'encoder-decoder'
data_filepath: './data/'
dataset: 'air_dancer'
lr_schedule: [20, 50, 100, 300]
num_gpus: 1
epochs: 1000
================================================
FILE: configs/air_dancer/model64/config1.yaml
================================================
lr: 0.001
seed: 1
if_cuda: True
gamma: 0.5
log_dir: 'logs'
train_batch: 512
val_batch: 256
test_batch: 256
num_workers: 8
model_name: 'encoder-decoder-64'
data_filepath: './data/'
dataset: 'air_dancer'
lr_schedule: [20, 50, 100, 300]
num_gpus: 1
epochs: 1000
================================================
FILE: configs/air_dancer/model64/config2.yaml
================================================
lr: 0.001
seed: 2
if_cuda: True
gamma: 0.5
log_dir: 'logs'
train_batch: 512
val_batch: 256
test_batch: 256
num_workers: 8
model_name: 'encoder-decoder-64'
data_filepath: './data/'
dataset: 'air_dancer'
lr_schedule: [20, 50, 100, 300]
num_gpus: 1
epochs: 1000
================================================
FILE: configs/air_dancer/model64/config3.yaml
================================================
lr: 0.001
seed: 3
if_cuda: True
gamma: 0.5
log_dir: 'logs'
train_batch: 512
val_batch: 256
test_batch: 256
num_workers: 8
model_name: 'encoder-decoder-64'
data_filepath: './data/'
dataset: 'air_dancer'
lr_schedule: [20, 50, 100, 300]
num_gpus: 1
epochs: 1000
================================================
FILE: configs/air_dancer/refine64/config1.yaml
================================================
lr: 0.0006
seed: 1
if_cuda: True
gamma: 0.5
log_dir: 'logs'
train_batch: 512
val_batch: 256
test_batch: 256
num_workers: 8
model_name: 'refine-64'
data_filepath: './data/'
dataset: 'air_dancer'
lr_schedule: [15, 30, 100, 300]
num_gpus: 1
epochs: 1000
================================================
FILE: configs/air_dancer/refine64/config2.yaml
================================================
lr: 0.0003
seed: 2
if_cuda: True
gamma: 0.5
log_dir: 'logs'
train_batch: 512
val_batch: 256
test_batch: 256
num_workers: 8
model_name: 'refine-64'
data_filepath: './data/'
dataset: 'air_dancer'
lr_schedule: [15, 30, 100, 300]
num_gpus: 1
epochs: 1000
================================================
FILE: configs/air_dancer/refine64/config3.yaml
================================================
lr: 0.0004
seed: 3
if_cuda: True
gamma: 0.5
log_dir: 'logs'
train_batch: 512
val_batch: 256
test_batch: 256
num_workers: 8
model_name: 'refine-64'
data_filepath: './data/'
dataset: 'air_dancer'
lr_schedule: [15, 30, 100, 300]
num_gpus: 1
epochs: 1000
================================================
FILE: configs/circular_motion/model/config1.yaml
================================================
lr: 0.001
seed: 1
if_cuda: True
gamma: 0.5
log_dir: 'logs'
train_batch: 512
val_batch: 256
test_batch: 256
num_workers: 8
model_name: 'encoder-decoder'
data_filepath: './data/'
dataset: 'circular_motion'
lr_schedule: [20, 50, 100, 300]
num_gpus: 1
epochs: 1000
================================================
FILE: configs/circular_motion/model/config2.yaml
================================================
lr: 0.001
seed: 2
if_cuda: True
gamma: 0.5
log_dir: 'logs'
train_batch: 512
val_batch: 256
test_batch: 256
num_workers: 8
model_name: 'encoder-decoder'
data_filepath: './data/'
dataset: 'circular_motion'
lr_schedule: [20, 50, 100, 300]
num_gpus: 1
epochs: 1000
================================================
FILE: configs/circular_motion/model/config3.yaml
================================================
lr: 0.001
seed: 3
if_cuda: True
gamma: 0.5
log_dir: 'logs'
train_batch: 512
val_batch: 256
test_batch: 256
num_workers: 8
model_name: 'encoder-decoder'
data_filepath: './data/'
dataset: 'circular_motion'
lr_schedule: [20, 50, 100, 300]
num_gpus: 1
epochs: 1000
================================================
FILE: configs/circular_motion/model64/config1.yaml
================================================
lr: 0.001
seed: 1
if_cuda: True
gamma: 0.5
log_dir: 'logs'
train_batch: 512
val_batch: 256
test_batch: 256
num_workers: 8
model_name: 'encoder-decoder-64'
data_filepath: './data/'
dataset: 'circular_motion'
lr_schedule: [20, 50, 100, 300]
num_gpus: 1
epochs: 1000
================================================
FILE: configs/circular_motion/model64/config2.yaml
================================================
lr: 0.001
seed: 2
if_cuda: True
gamma: 0.5
log_dir: 'logs'
train_batch: 512
val_batch: 256
test_batch: 256
num_workers: 8
model_name: 'encoder-decoder-64'
data_filepath: './data/'
dataset: 'circular_motion'
lr_schedule: [20, 50, 100, 300]
num_gpus: 1
epochs: 1000
================================================
FILE: configs/circular_motion/model64/config3.yaml
================================================
lr: 0.001
seed: 3
if_cuda: True
gamma: 0.5
log_dir: 'logs'
train_batch: 512
val_batch: 256
test_batch: 256
num_workers: 8
model_name: 'encoder-decoder-64'
data_filepath: './data/'
dataset: 'circular_motion'
lr_schedule: [20, 50, 100, 300]
num_gpus: 1
epochs: 1000
================================================
FILE: configs/circular_motion/refine64/config1.yaml
================================================
lr: 0.0003
seed: 1
if_cuda: True
gamma: 0.5
log_dir: 'logs'
train_batch: 512
val_batch: 256
test_batch: 256
num_workers: 8
model_name: 'refine-64'
data_filepath: './data/'
dataset: 'circular_motion'
lr_schedule: [15, 30, 100, 300]
num_gpus: 1
epochs: 1000
================================================
FILE: configs/circular_motion/refine64/config2.yaml
================================================
lr: 0.0003
seed: 2
if_cuda: True
gamma: 0.5
log_dir: 'logs'
train_batch: 512
val_batch: 256
test_batch: 256
num_workers: 8
model_name: 'refine-64'
data_filepath: './data/'
dataset: 'circular_motion'
lr_schedule: [15, 30, 100, 300]
num_gpus: 1
epochs: 1000
================================================
FILE: configs/circular_motion/refine64/config3.yaml
================================================
lr: 0.0003
seed: 3
if_cuda: True
gamma: 0.5
log_dir: 'logs'
train_batch: 512
val_batch: 256
test_batch: 256
num_workers: 8
model_name: 'refine-64'
data_filepath: './data/'
dataset: 'circular_motion'
lr_schedule: [15, 30, 100, 300]
num_gpus: 1
epochs: 1000
================================================
FILE: configs/double_pendulum/latentpred/config1.yaml
================================================
lr: 0.03
seed: 1
if_cuda: True
gamma: 0.5
log_dir: 'logs'
train_batch: 512
val_batch: 256
test_batch: 256
num_workers: 8
model_name: 'latent-prediction'
data_filepath: './data/'
dataset: 'double_pendulum'
lr_schedule: [20, 50, 100, 300]
num_gpus: 1
epochs: 1000
================================================
FILE: configs/double_pendulum/latentpred/config2.yaml
================================================
lr: 0.03
seed: 2
if_cuda: True
gamma: 0.5
log_dir: 'logs'
train_batch: 512
val_batch: 256
test_batch: 256
num_workers: 8
model_name: 'latent-prediction'
data_filepath: './data/'
dataset: 'double_pendulum'
lr_schedule: [20, 50, 100, 300]
num_gpus: 1
epochs: 1000
================================================
FILE: configs/double_pendulum/latentpred/config3.yaml
================================================
lr: 0.03
seed: 3
if_cuda: True
gamma: 0.5
log_dir: 'logs'
train_batch: 512
val_batch: 256
test_batch: 256
num_workers: 8
model_name: 'latent-prediction'
data_filepath: './data/'
dataset: 'double_pendulum'
lr_schedule: [20, 50, 100, 300]
num_gpus: 1
epochs: 1000
================================================
FILE: configs/double_pendulum/model/config1.yaml
================================================
lr: 0.001
seed: 1
if_cuda: True
gamma: 0.5
log_dir: 'logs'
train_batch: 512
val_batch: 256
test_batch: 256
num_workers: 8
model_name: 'encoder-decoder'
data_filepath: './data/'
dataset: 'double_pendulum'
lr_schedule: [20, 50, 100, 300]
num_gpus: 1
epochs: 1000
================================================
FILE: configs/double_pendulum/model/config2.yaml
================================================
lr: 0.001
seed: 2
if_cuda: True
gamma: 0.5
log_dir: 'logs'
train_batch: 512
val_batch: 256
test_batch: 256
num_workers: 8
model_name: 'encoder-decoder'
data_filepath: './data/'
dataset: 'double_pendulum'
lr_schedule: [20, 50, 100, 300]
num_gpus: 1
epochs: 1000
================================================
FILE: configs/double_pendulum/model/config3.yaml
================================================
lr: 0.001
seed: 3
if_cuda: True
gamma: 0.5
log_dir: 'logs'
train_batch: 512
val_batch: 256
test_batch: 256
num_workers: 8
model_name: 'encoder-decoder'
data_filepath: './data/'
dataset: 'double_pendulum'
lr_schedule: [20, 50, 100, 300]
num_gpus: 1
epochs: 1000
================================================
FILE: configs/double_pendulum/model64/config1.yaml
================================================
lr: 0.001
seed: 1
if_cuda: True
gamma: 0.5
log_dir: 'logs'
train_batch: 512
val_batch: 256
test_batch: 256
num_workers: 8
model_name: 'encoder-decoder-64'
data_filepath: './data/'
dataset: 'double_pendulum'
lr_schedule: [20, 50, 100, 300]
num_gpus: 1
epochs: 1000
================================================
FILE: configs/double_pendulum/model64/config2.yaml
================================================
lr: 0.001
seed: 2
if_cuda: True
gamma: 0.5
log_dir: 'logs'
train_batch: 512
val_batch: 256
test_batch: 256
num_workers: 8
model_name: 'encoder-decoder-64'
data_filepath: './data/'
dataset: 'double_pendulum'
lr_schedule: [20, 50, 100, 300]
num_gpus: 1
epochs: 1000
================================================
FILE: configs/double_pendulum/model64/config3.yaml
================================================
lr: 0.001
seed: 3
if_cuda: True
gamma: 0.5
log_dir: 'logs'
train_batch: 512
val_batch: 256
test_batch: 256
num_workers: 8
model_name: 'encoder-decoder-64'
data_filepath: './data/'
dataset: 'double_pendulum'
lr_schedule: [20, 50, 100, 300]
num_gpus: 1
epochs: 1000
================================================
FILE: configs/double_pendulum/refine64/config1.yaml
================================================
lr: 0.0003
seed: 1
if_cuda: True
gamma: 0.5
log_dir: 'logs'
train_batch: 512
val_batch: 256
test_batch: 256
num_workers: 8
model_name: 'refine-64'
data_filepath: './data/'
dataset: 'double_pendulum'
lr_schedule: [15, 30, 100, 300]
num_gpus: 1
epochs: 1000
================================================
FILE: configs/double_pendulum/refine64/config2.yaml
================================================
lr: 0.0005
seed: 2
if_cuda: True
gamma: 0.5
log_dir: 'logs'
train_batch: 512
val_batch: 256
test_batch: 256
num_workers: 8
model_name: 'refine-64'
data_filepath: './data/'
dataset: 'double_pendulum'
lr_schedule: [15, 30, 100, 300]
num_gpus: 1
epochs: 1000
================================================
FILE: configs/double_pendulum/refine64/config3.yaml
================================================
lr: 0.0004
seed: 3
if_cuda: True
gamma: 0.5
log_dir: 'logs'
train_batch: 256
val_batch: 256
test_batch: 256
num_workers: 8
model_name: 'refine-64'
data_filepath: './data/'
dataset: 'double_pendulum'
lr_schedule: [15, 30, 100, 300]
num_gpus: 1
epochs: 1000
================================================
FILE: configs/elastic_pendulum/latentpred/config1.yaml
================================================
lr: 0.02
seed: 1
if_cuda: True
gamma: 0.5
log_dir: 'logs'
train_batch: 512
val_batch: 256
test_batch: 256
num_workers: 8
model_name: 'latent-prediction'
data_filepath: './data/'
dataset: 'elastic_pendulum'
lr_schedule: [20, 50, 100, 300]
num_gpus: 1
epochs: 1000
================================================
FILE: configs/elastic_pendulum/latentpred/config2.yaml
================================================
lr: 0.02
seed: 2
if_cuda: True
gamma: 0.5
log_dir: 'logs'
train_batch: 512
val_batch: 256
test_batch: 256
num_workers: 8
model_name: 'latent-prediction'
data_filepath: './data/'
dataset: 'elastic_pendulum'
lr_schedule: [20, 50, 100, 300]
num_gpus: 1
epochs: 1000
================================================
FILE: configs/elastic_pendulum/latentpred/config3.yaml
================================================
lr: 0.01
seed: 3
if_cuda: True
gamma: 0.5
log_dir: 'logs'
train_batch: 512
val_batch: 256
test_batch: 256
num_workers: 8
model_name: 'latent-prediction'
data_filepath: './data/'
dataset: 'elastic_pendulum'
lr_schedule: [20, 50, 100, 300]
num_gpus: 1
epochs: 1000
================================================
FILE: configs/elastic_pendulum/model/config1.yaml
================================================
lr: 0.001
seed: 1
if_cuda: True
gamma: 0.5
log_dir: 'logs'
train_batch: 512
val_batch: 256
test_batch: 256
num_workers: 8
model_name: 'encoder-decoder'
data_filepath: './data/'
dataset: 'elastic_pendulum'
lr_schedule: [20, 50, 100, 300]
num_gpus: 1
epochs: 1000
================================================
FILE: configs/elastic_pendulum/model/config2.yaml
================================================
lr: 0.001
seed: 2
if_cuda: True
gamma: 0.5
log_dir: 'logs'
train_batch: 512
val_batch: 256
test_batch: 256
num_workers: 8
model_name: 'encoder-decoder'
data_filepath: './data/'
dataset: 'elastic_pendulum'
lr_schedule: [20, 50, 100, 300]
num_gpus: 1
epochs: 1000
================================================
FILE: configs/elastic_pendulum/model/config3.yaml
================================================
lr: 0.001
seed: 3
if_cuda: True
gamma: 0.5
log_dir: 'logs'
train_batch: 512
val_batch: 256
test_batch: 256
num_workers: 8
model_name: 'encoder-decoder'
data_filepath: './data/'
dataset: 'elastic_pendulum'
lr_schedule: [20, 50, 100, 300]
num_gpus: 1
epochs: 1000
================================================
FILE: configs/elastic_pendulum/model64/config1.yaml
================================================
lr: 0.001
seed: 1
if_cuda: True
gamma: 0.5
log_dir: 'logs'
train_batch: 512
val_batch: 256
test_batch: 256
num_workers: 8
model_name: 'encoder-decoder-64'
data_filepath: './data/'
dataset: 'elastic_pendulum'
lr_schedule: [20, 50, 100, 300]
num_gpus: 1
epochs: 1000
================================================
FILE: configs/elastic_pendulum/model64/config2.yaml
================================================
lr: 0.001
seed: 2
if_cuda: True
gamma: 0.5
log_dir: 'logs'
train_batch: 512
val_batch: 256
test_batch: 256
num_workers: 8
model_name: 'encoder-decoder-64'
data_filepath: './data/'
dataset: 'elastic_pendulum'
lr_schedule: [20, 50, 100, 300]
num_gpus: 1
epochs: 1000
================================================
FILE: configs/elastic_pendulum/model64/config3.yaml
================================================
lr: 0.001
seed: 3
if_cuda: True
gamma: 0.5
log_dir: 'logs'
train_batch: 512
val_batch: 256
test_batch: 256
num_workers: 8
model_name: 'encoder-decoder-64'
data_filepath: './data/'
dataset: 'elastic_pendulum'
lr_schedule: [20, 50, 100, 300]
num_gpus: 1
epochs: 1000
================================================
FILE: configs/elastic_pendulum/refine64/config1.yaml
================================================
lr: 0.0007
seed: 1
if_cuda: True
gamma: 0.5
log_dir: 'logs'
train_batch: 512
val_batch: 256
test_batch: 256
num_workers: 8
model_name: 'refine-64'
data_filepath: './data/'
dataset: 'elastic_pendulum'
lr_schedule: [15, 30, 100, 300]
num_gpus: 1
epochs: 1000
================================================
FILE: configs/elastic_pendulum/refine64/config2.yaml
================================================
lr: 0.0004
seed: 2
if_cuda: True
gamma: 0.5
log_dir: 'logs'
train_batch: 512
val_batch: 256
test_batch: 256
num_workers: 8
model_name: 'refine-64'
data_filepath: './data/'
dataset: 'elastic_pendulum'
lr_schedule: [15, 30, 100, 300]
num_gpus: 1
epochs: 1000
================================================
FILE: configs/elastic_pendulum/refine64/config3.yaml
================================================
lr: 0.0002
seed: 3
if_cuda: True
gamma: 0.5
log_dir: 'logs'
train_batch: 256
val_batch: 256
test_batch: 256
num_workers: 8
model_name: 'refine-64'
data_filepath: './data/'
dataset: 'elastic_pendulum'
lr_schedule: [15, 30, 100, 300]
num_gpus: 1
epochs: 1000
================================================
FILE: configs/fire/latentpred/config1.yaml
================================================
lr: 0.008
seed: 1
if_cuda: True
gamma: 0.5
log_dir: 'logs'
train_batch: 512
val_batch: 256
test_batch: 256
num_workers: 8
model_name: 'latent-prediction'
data_filepath: './data/'
dataset: 'fire'
lr_schedule: [20, 50, 100, 300]
num_gpus: 1
epochs: 1000
================================================
FILE: configs/fire/latentpred/config2.yaml
================================================
lr: 0.02
seed: 2
if_cuda: True
gamma: 0.5
log_dir: 'logs'
train_batch: 512
val_batch: 256
test_batch: 256
num_workers: 8
model_name: 'latent-prediction'
data_filepath: './data/'
dataset: 'fire'
lr_schedule: [20, 50, 100, 300]
num_gpus: 1
epochs: 1000
================================================
FILE: configs/fire/latentpred/config3.yaml
================================================
lr: 0.009
seed: 3
if_cuda: True
gamma: 0.5
log_dir: 'logs'
train_batch: 512
val_batch: 256
test_batch: 256
num_workers: 8
model_name: 'latent-prediction'
data_filepath: './data/'
dataset: 'fire'
lr_schedule: [20, 50, 100, 300]
num_gpus: 1
epochs: 1000
================================================
FILE: configs/fire/model/config1.yaml
================================================
lr: 0.001
seed: 1
if_cuda: True
gamma: 0.5
log_dir: 'logs'
train_batch: 512
val_batch: 256
test_batch: 256
num_workers: 8
model_name: 'encoder-decoder'
data_filepath: './data/'
dataset: 'fire'
lr_schedule: [20, 50, 100, 300]
num_gpus: 1
epochs: 1000
================================================
FILE: configs/fire/model/config2.yaml
================================================
lr: 0.001
seed: 2
if_cuda: True
gamma: 0.5
log_dir: 'logs'
train_batch: 512
val_batch: 256
test_batch: 256
num_workers: 8
model_name: 'encoder-decoder'
data_filepath: './data/'
dataset: 'fire'
lr_schedule: [20, 50, 100, 300]
num_gpus: 1
epochs: 1000
================================================
FILE: configs/fire/model/config3.yaml
================================================
lr: 0.001
seed: 3
if_cuda: True
gamma: 0.5
log_dir: 'logs'
train_batch: 512
val_batch: 256
test_batch: 256
num_workers: 8
model_name: 'encoder-decoder'
data_filepath: './data/'
dataset: 'fire'
lr_schedule: [20, 50, 100, 300]
num_gpus: 1
epochs: 1000
================================================
FILE: configs/fire/model64/config1.yaml
================================================
lr: 0.001
seed: 1
if_cuda: True
gamma: 0.5
log_dir: 'logs'
train_batch: 512
val_batch: 256
test_batch: 256
num_workers: 8
model_name: 'encoder-decoder-64'
data_filepath: './data/'
dataset: 'fire'
lr_schedule: [20, 50, 100, 300]
num_gpus: 1
epochs: 1000
================================================
FILE: configs/fire/model64/config2.yaml
================================================
lr: 0.001
seed: 2
if_cuda: True
gamma: 0.5
log_dir: 'logs'
train_batch: 512
val_batch: 256
test_batch: 256
num_workers: 8
model_name: 'encoder-decoder-64'
data_filepath: './data/'
dataset: 'fire'
lr_schedule: [20, 50, 100, 300]
num_gpus: 1
epochs: 1000
================================================
FILE: configs/fire/model64/config3.yaml
================================================
lr: 0.001
seed: 3
if_cuda: True
gamma: 0.5
log_dir: 'logs'
train_batch: 512
val_batch: 256
test_batch: 256
num_workers: 8
model_name: 'encoder-decoder-64'
data_filepath: './data/'
dataset: 'fire'
lr_schedule: [20, 50, 100, 300]
num_gpus: 1
epochs: 1000
================================================
FILE: configs/fire/refine64/config1.yaml
================================================
lr: 0.0007
seed: 1
if_cuda: True
gamma: 0.5
log_dir: 'logs'
train_batch: 512
val_batch: 256
test_batch: 256
num_workers: 8
model_name: 'refine-64'
data_filepath: './data/'
dataset: 'fire'
lr_schedule: [15, 30, 100, 300]
num_gpus: 1
epochs: 1000
================================================
FILE: configs/fire/refine64/config2.yaml
================================================
lr: 0.0006
seed: 2
if_cuda: True
gamma: 0.5
log_dir: 'logs'
train_batch: 512
val_batch: 256
test_batch: 256
num_workers: 8
model_name: 'refine-64'
data_filepath: './data/'
dataset: 'fire'
lr_schedule: [15, 30, 100, 300]
num_gpus: 1
epochs: 1000
================================================
FILE: configs/fire/refine64/config3.yaml
================================================
lr: 0.0007
seed: 3
if_cuda: True
gamma: 0.5
log_dir: 'logs'
train_batch: 512
val_batch: 256
test_batch: 256
num_workers: 8
model_name: 'refine-64'
data_filepath: './data/'
dataset: 'fire'
lr_schedule: [15, 30, 100, 300]
num_gpus: 1
epochs: 1000
================================================
FILE: configs/lava_lamp/latentpred/config1.yaml
================================================
lr: 0.008
seed: 1
if_cuda: True
gamma: 0.5
log_dir: 'logs'
train_batch: 512
val_batch: 256
test_batch: 256
num_workers: 8
model_name: 'latent-prediction'
data_filepath: './data/'
dataset: 'lava_lamp'
lr_schedule: [20, 50, 100, 300]
num_gpus: 1
epochs: 1000
================================================
FILE: configs/lava_lamp/latentpred/config2.yaml
================================================
lr: 0.009
seed: 2
if_cuda: True
gamma: 0.5
log_dir: 'logs'
train_batch: 512
val_batch: 256
test_batch: 256
num_workers: 8
model_name: 'latent-prediction'
data_filepath: './data/'
dataset: 'lava_lamp'
lr_schedule: [20, 50, 100, 300]
num_gpus: 1
epochs: 1000
================================================
FILE: configs/lava_lamp/latentpred/config3.yaml
================================================
lr: 0.01
seed: 3
if_cuda: True
gamma: 0.5
log_dir: 'logs'
train_batch: 512
val_batch: 256
test_batch: 256
num_workers: 8
model_name: 'latent-prediction'
data_filepath: './data/'
dataset: 'lava_lamp'
lr_schedule: [20, 50, 100, 300]
num_gpus: 1
epochs: 1000
================================================
FILE: configs/lava_lamp/model/config1.yaml
================================================
lr: 0.001
seed: 1
if_cuda: True
gamma: 0.5
log_dir: 'logs'
train_batch: 512
val_batch: 256
test_batch: 256
num_workers: 8
model_name: 'encoder-decoder'
data_filepath: './data/'
dataset: 'lava_lamp'
lr_schedule: [20, 50, 100, 300]
num_gpus: 1
epochs: 1000
================================================
FILE: configs/lava_lamp/model/config2.yaml
================================================
lr: 0.001
seed: 2
if_cuda: True
gamma: 0.5
log_dir: 'logs'
train_batch: 512
val_batch: 256
test_batch: 256
num_workers: 8
model_name: 'encoder-decoder'
data_filepath: './data/'
dataset: 'lava_lamp'
lr_schedule: [20, 50, 100, 300]
num_gpus: 1
epochs: 1000
================================================
FILE: configs/lava_lamp/model/config3.yaml
================================================
lr: 0.001
seed: 3
if_cuda: True
gamma: 0.5
log_dir: 'logs'
train_batch: 512
val_batch: 256
test_batch: 256
num_workers: 8
model_name: 'encoder-decoder'
data_filepath: './data/'
dataset: 'lava_lamp'
lr_schedule: [20, 50, 100, 300]
num_gpus: 1
epochs: 1000
================================================
FILE: configs/lava_lamp/model64/config1.yaml
================================================
lr: 0.001
seed: 1
if_cuda: True
gamma: 0.5
log_dir: 'logs'
train_batch: 512
val_batch: 256
test_batch: 256
num_workers: 8
model_name: 'encoder-decoder-64'
data_filepath: './data/'
dataset: 'lava_lamp'
lr_schedule: [20, 50, 100, 300]
num_gpus: 1
epochs: 1000
================================================
FILE: configs/lava_lamp/model64/config2.yaml
================================================
lr: 0.001
seed: 2
if_cuda: True
gamma: 0.5
log_dir: 'logs'
train_batch: 512
val_batch: 256
test_batch: 256
num_workers: 8
model_name: 'encoder-decoder-64'
data_filepath: './data/'
dataset: 'lava_lamp'
lr_schedule: [20, 50, 100, 300]
num_gpus: 1
epochs: 1000
================================================
FILE: configs/lava_lamp/model64/config3.yaml
================================================
lr: 0.001
seed: 3
if_cuda: True
gamma: 0.5
log_dir: 'logs'
train_batch: 512
val_batch: 256
test_batch: 256
num_workers: 8
model_name: 'encoder-decoder-64'
data_filepath: './data/'
dataset: 'lava_lamp'
lr_schedule: [20, 50, 100, 300]
num_gpus: 1
epochs: 1000
================================================
FILE: configs/lava_lamp/refine64/config1.yaml
================================================
lr: 0.0006
seed: 1
if_cuda: True
gamma: 0.5
log_dir: 'logs'
train_batch: 512
val_batch: 256
test_batch: 256
num_workers: 8
model_name: 'refine-64'
data_filepath: './data/'
dataset: 'lava_lamp'
lr_schedule: [15, 30, 100, 300]
num_gpus: 1
epochs: 1000
================================================
FILE: configs/lava_lamp/refine64/config2.yaml
================================================
lr: 0.0004
seed: 2
if_cuda: True
gamma: 0.5
log_dir: 'logs'
train_batch: 512
val_batch: 256
test_batch: 256
num_workers: 8
model_name: 'refine-64'
data_filepath: './data/'
dataset: 'lava_lamp'
lr_schedule: [15, 30, 100, 300]
num_gpus: 1
epochs: 1000
================================================
FILE: configs/lava_lamp/refine64/config3.yaml
================================================
lr: 0.0005
seed: 3
if_cuda: True
gamma: 0.5
log_dir: 'logs'
train_batch: 512
val_batch: 256
test_batch: 256
num_workers: 8
model_name: 'refine-64'
data_filepath: './data/'
dataset: 'lava_lamp'
lr_schedule: [15, 30, 100, 300]
num_gpus: 1
epochs: 1000
================================================
FILE: configs/reaction_diffusion/latentpred/config1.yaml
================================================
lr: 0.01
seed: 1
if_cuda: True
gamma: 0.5
log_dir: 'logs'
train_batch: 512
val_batch: 256
test_batch: 256
num_workers: 8
model_name: 'latent-prediction'
data_filepath: './data/'
dataset: 'reaction_diffusion'
lr_schedule: [20, 50, 100, 300]
num_gpus: 1
epochs: 1000
================================================
FILE: configs/reaction_diffusion/latentpred/config2.yaml
================================================
lr: 0.03
seed: 2
if_cuda: True
gamma: 0.5
log_dir: 'logs'
train_batch: 512
val_batch: 256
test_batch: 256
num_workers: 8
model_name: 'latent-prediction'
data_filepath: './data/'
dataset: 'reaction_diffusion'
lr_schedule: [20, 50, 100, 300]
num_gpus: 1
epochs: 1000
================================================
FILE: configs/reaction_diffusion/latentpred/config3.yaml
================================================
lr: 0.01
seed: 3
if_cuda: True
gamma: 0.5
log_dir: 'logs'
train_batch: 512
val_batch: 256
test_batch: 256
num_workers: 8
model_name: 'latent-prediction'
data_filepath: './data/'
dataset: 'reaction_diffusion'
lr_schedule: [20, 50, 100, 300]
num_gpus: 1
epochs: 1000
================================================
FILE: configs/reaction_diffusion/model/config1.yaml
================================================
lr: 0.001
seed: 1
if_cuda: True
gamma: 0.5
log_dir: 'logs'
train_batch: 512
val_batch: 256
test_batch: 256
num_workers: 8
model_name: 'encoder-decoder'
data_filepath: './data/'
dataset: 'reaction_diffusion'
lr_schedule: [20, 50, 100, 300]
num_gpus: 1
epochs: 1000
================================================
FILE: configs/reaction_diffusion/model/config2.yaml
================================================
lr: 0.001
seed: 2
if_cuda: True
gamma: 0.5
log_dir: 'logs'
train_batch: 512
val_batch: 256
test_batch: 256
num_workers: 8
model_name: 'encoder-decoder'
data_filepath: './data/'
dataset: 'reaction_diffusion'
lr_schedule: [20, 50, 100, 300]
num_gpus: 1
epochs: 1000
================================================
FILE: configs/reaction_diffusion/model/config3.yaml
================================================
lr: 0.001
seed: 3
if_cuda: True
gamma: 0.5
log_dir: 'logs'
train_batch: 512
val_batch: 256
test_batch: 256
num_workers: 8
model_name: 'encoder-decoder'
data_filepath: './data/'
dataset: 'reaction_diffusion'
lr_schedule: [20, 50, 100, 300]
num_gpus: 1
epochs: 1000
================================================
FILE: configs/reaction_diffusion/model64/config1.yaml
================================================
lr: 0.001
seed: 1
if_cuda: True
gamma: 0.5
log_dir: 'logs'
train_batch: 512
val_batch: 256
test_batch: 256
num_workers: 8
model_name: 'encoder-decoder-64'
data_filepath: './data/'
dataset: 'reaction_diffusion'
lr_schedule: [20, 50, 100, 300]
num_gpus: 1
epochs: 1000
================================================
FILE: configs/reaction_diffusion/model64/config2.yaml
================================================
lr: 0.001
seed: 2
if_cuda: True
gamma: 0.5
log_dir: 'logs'
train_batch: 512
val_batch: 256
test_batch: 256
num_workers: 8
model_name: 'encoder-decoder-64'
data_filepath: './data/'
dataset: 'reaction_diffusion'
lr_schedule: [20, 50, 100, 300]
num_gpus: 1
epochs: 1000
================================================
FILE: configs/reaction_diffusion/model64/config3.yaml
================================================
lr: 0.001
seed: 3
if_cuda: True
gamma: 0.5
log_dir: 'logs'
train_batch: 512
val_batch: 256
test_batch: 256
num_workers: 8
model_name: 'encoder-decoder-64'
data_filepath: './data/'
dataset: 'reaction_diffusion'
lr_schedule: [20, 50, 100, 300]
num_gpus: 1
epochs: 1000
================================================
FILE: configs/reaction_diffusion/refine64/config1.yaml
================================================
lr: 0.0004
seed: 1
if_cuda: True
gamma: 0.5
log_dir: 'logs'
train_batch: 512
val_batch: 256
test_batch: 256
num_workers: 8
model_name: 'refine-64'
data_filepath: './data/'
dataset: 'reaction_diffusion'
lr_schedule: [15, 30, 100, 300]
num_gpus: 1
epochs: 1000
================================================
FILE: configs/reaction_diffusion/refine64/config2.yaml
================================================
lr: 0.0003
seed: 2
if_cuda: True
gamma: 0.5
log_dir: 'logs'
train_batch: 512
val_batch: 256
test_batch: 256
num_workers: 8
model_name: 'refine-64'
data_filepath: './data/'
dataset: 'reaction_diffusion'
lr_schedule: [15, 30, 100, 300]
num_gpus: 1
epochs: 1000
================================================
FILE: configs/reaction_diffusion/refine64/config3.yaml
================================================
lr: 0.0003
seed: 3
if_cuda: True
gamma: 0.5
log_dir: 'logs'
train_batch: 256
val_batch: 256
test_batch: 256
num_workers: 8
model_name: 'refine-64'
data_filepath: './data/'
dataset: 'reaction_diffusion'
lr_schedule: [15, 30, 100, 300]
num_gpus: 1
epochs: 1000
================================================
FILE: configs/single_pendulum/latentpred/config1.yaml
================================================
lr: 0.005
seed: 1
if_cuda: True
gamma: 0.5
log_dir: 'logs'
train_batch: 512
val_batch: 256
test_batch: 256
num_workers: 8
model_name: 'latent-prediction'
data_filepath: './data/'
dataset: 'single_pendulum'
lr_schedule: [20, 50, 100, 300]
num_gpus: 1
epochs: 1000
================================================
FILE: configs/single_pendulum/latentpred/config2.yaml
================================================
lr: 0.01
seed: 2
if_cuda: True
gamma: 0.5
log_dir: 'logs'
train_batch: 512
val_batch: 256
test_batch: 256
num_workers: 8
model_name: 'latent-prediction'
data_filepath: './data/'
dataset: 'single_pendulum'
lr_schedule: [20, 50, 100, 300]
num_gpus: 1
epochs: 1000
================================================
FILE: configs/single_pendulum/latentpred/config3.yaml
================================================
lr: 0.02
seed: 3
if_cuda: True
gamma: 0.5
log_dir: 'logs'
train_batch: 512
val_batch: 256
test_batch: 256
num_workers: 8
model_name: 'latent-prediction'
data_filepath: './data/'
dataset: 'single_pendulum'
lr_schedule: [20, 50, 100, 300]
num_gpus: 1
epochs: 1000
================================================
FILE: configs/single_pendulum/model/config1.yaml
================================================
lr: 0.001
seed: 1
if_cuda: True
gamma: 0.5
log_dir: 'logs'
train_batch: 512
val_batch: 256
test_batch: 256
num_workers: 8
model_name: 'encoder-decoder'
data_filepath: './data/'
dataset: 'single_pendulum'
lr_schedule: [20, 50, 100, 300]
num_gpus: 1
epochs: 1000
================================================
FILE: configs/single_pendulum/model/config2.yaml
================================================
lr: 0.001
seed: 2
if_cuda: True
gamma: 0.5
log_dir: 'logs'
train_batch: 512
val_batch: 256
test_batch: 256
num_workers: 8
model_name: 'encoder-decoder'
data_filepath: './data/'
dataset: 'single_pendulum'
lr_schedule: [20, 50, 100, 300]
num_gpus: 1
epochs: 1000
================================================
FILE: configs/single_pendulum/model/config3.yaml
================================================
lr: 0.001
seed: 3
if_cuda: True
gamma: 0.5
log_dir: 'logs'
train_batch: 512
val_batch: 256
test_batch: 256
num_workers: 8
model_name: 'encoder-decoder'
data_filepath: './data/'
dataset: 'single_pendulum'
lr_schedule: [20, 50, 100, 300]
num_gpus: 1
epochs: 1000
================================================
FILE: configs/single_pendulum/model64/config1.yaml
================================================
lr: 0.001
seed: 1
if_cuda: True
gamma: 0.5
log_dir: 'logs'
train_batch: 512
val_batch: 256
test_batch: 256
num_workers: 8
model_name: 'encoder-decoder-64'
data_filepath: './data/'
dataset: 'single_pendulum'
lr_schedule: [20, 50, 100, 300]
num_gpus: 1
epochs: 1000
================================================
FILE: configs/single_pendulum/model64/config2.yaml
================================================
lr: 0.001
seed: 2
if_cuda: True
gamma: 0.5
log_dir: 'logs'
train_batch: 512
val_batch: 256
test_batch: 256
num_workers: 8
model_name: 'encoder-decoder-64'
data_filepath: './data/'
dataset: 'single_pendulum'
lr_schedule: [20, 50, 100, 300]
num_gpus: 1
epochs: 1000
================================================
FILE: configs/single_pendulum/model64/config3.yaml
================================================
lr: 0.001
seed: 3
if_cuda: True
gamma: 0.5
log_dir: 'logs'
train_batch: 512
val_batch: 256
test_batch: 256
num_workers: 8
model_name: 'encoder-decoder-64'
data_filepath: './data/'
dataset: 'single_pendulum'
lr_schedule: [20, 50, 100, 300]
num_gpus: 1
epochs: 1000
================================================
FILE: configs/single_pendulum/refine64/config1.yaml
================================================
lr: 0.0003
seed: 1
if_cuda: True
gamma: 0.5
log_dir: 'logs'
train_batch: 512
val_batch: 256
test_batch: 256
num_workers: 8
model_name: 'refine-64'
data_filepath: './data/'
dataset: 'single_pendulum'
lr_schedule: [15, 30, 100, 300]
num_gpus: 1
epochs: 1000
================================================
FILE: configs/single_pendulum/refine64/config2.yaml
================================================
lr: 0.0003
seed: 2
if_cuda: True
gamma: 0.5
log_dir: 'logs'
train_batch: 512
val_batch: 256
test_batch: 256
num_workers: 8
model_name: 'refine-64'
data_filepath: './data/'
dataset: 'single_pendulum'
lr_schedule: [15, 30, 100, 300]
num_gpus: 1
epochs: 1000
================================================
FILE: configs/single_pendulum/refine64/config3.yaml
================================================
lr: 0.0004
seed: 3
if_cuda: True
gamma: 0.5
log_dir: 'logs'
train_batch: 512
val_batch: 256
test_batch: 256
num_workers: 8
model_name: 'refine-64'
data_filepath: './data/'
dataset: 'single_pendulum'
lr_schedule: [15, 30, 100, 300]
num_gpus: 1
epochs: 1000
================================================
FILE: configs/swingstick_magnetic/model/config1.yaml
================================================
lr: 0.001
seed: 1
if_cuda: True
gamma: 0.5
log_dir: 'logs'
train_batch: 512
val_batch: 256
test_batch: 256
num_workers: 8
model_name: 'encoder-decoder'
data_filepath: './data/'
dataset: 'swingstick_magnetic'
lr_schedule: [20, 50, 100, 300]
num_gpus: 1
epochs: 1000
================================================
FILE: configs/swingstick_magnetic/model/config2.yaml
================================================
lr: 0.001
seed: 2
if_cuda: True
gamma: 0.5
log_dir: 'logs'
train_batch: 512
val_batch: 256
test_batch: 256
num_workers: 8
model_name: 'encoder-decoder'
data_filepath: './data/'
dataset: 'swingstick_magnetic'
lr_schedule: [20, 50, 100, 300]
num_gpus: 1
epochs: 1000
================================================
FILE: configs/swingstick_magnetic/model/config3.yaml
================================================
lr: 0.001
seed: 3
if_cuda: True
gamma: 0.5
log_dir: 'logs'
train_batch: 512
val_batch: 256
test_batch: 256
num_workers: 8
model_name: 'encoder-decoder'
data_filepath: './data/'
dataset: 'swingstick_magnetic'
lr_schedule: [20, 50, 100, 300]
num_gpus: 1
epochs: 1000
================================================
FILE: configs/swingstick_magnetic/model64/config1.yaml
================================================
lr: 0.001
seed: 1
if_cuda: True
gamma: 0.5
log_dir: 'logs'
train_batch: 512
val_batch: 256
test_batch: 256
num_workers: 8
model_name: 'encoder-decoder-64'
data_filepath: './data/'
dataset: 'swingstick_magnetic'
lr_schedule: [20, 50, 100, 300]
num_gpus: 1
epochs: 1000
================================================
FILE: configs/swingstick_magnetic/model64/config2.yaml
================================================
lr: 0.001
seed: 2
if_cuda: True
gamma: 0.5
log_dir: 'logs'
train_batch: 512
val_batch: 256
test_batch: 256
num_workers: 8
model_name: 'encoder-decoder-64'
data_filepath: './data/'
dataset: 'swingstick_magnetic'
lr_schedule: [20, 50, 100, 300]
num_gpus: 1
epochs: 1000
================================================
FILE: configs/swingstick_magnetic/model64/config3.yaml
================================================
lr: 0.001
seed: 3
if_cuda: True
gamma: 0.5
log_dir: 'logs'
train_batch: 512
val_batch: 256
test_batch: 256
num_workers: 8
model_name: 'encoder-decoder-64'
data_filepath: './data/'
dataset: 'swingstick_magnetic'
lr_schedule: [20, 50, 100, 300]
num_gpus: 1
epochs: 1000
================================================
FILE: configs/swingstick_magnetic/refine64/config1.yaml
================================================
lr: 0.001
seed: 1
if_cuda: True
gamma: 0.5
log_dir: 'logs'
train_batch: 512
val_batch: 256
test_batch: 256
num_workers: 8
model_name: 'refine-64'
data_filepath: './data/'
dataset: 'swingstick_magnetic'
lr_schedule: [15, 30, 100, 300]
num_gpus: 1
epochs: 1000
================================================
FILE: configs/swingstick_magnetic/refine64/config2.yaml
================================================
lr: 0.001
seed: 2
if_cuda: True
gamma: 0.5
log_dir: 'logs'
train_batch: 512
val_batch: 256
test_batch: 256
num_workers: 8
model_name: 'refine-64'
data_filepath: './data/'
dataset: 'swingstick_magnetic'
lr_schedule: [15, 30, 100, 300]
num_gpus: 1
epochs: 1000
================================================
FILE: configs/swingstick_magnetic/refine64/config3.yaml
================================================
lr: 0.001
seed: 3
if_cuda: True
gamma: 0.5
log_dir: 'logs'
train_batch: 512
val_batch: 256
test_batch: 256
num_workers: 8
model_name: 'refine-64'
data_filepath: './data/'
dataset: 'swingstick_magnetic'
lr_schedule: [15, 30, 100, 300]
num_gpus: 1
epochs: 1000
================================================
FILE: configs/swingstick_non_magnetic/latentpred/config1.yaml
================================================
lr: 0.02
seed: 1
if_cuda: True
gamma: 0.5
log_dir: 'logs'
train_batch: 512
val_batch: 256
test_batch: 256
num_workers: 8
model_name: 'latent-prediction'
data_filepath: './data/'
dataset: 'swingstick_non_magnetic'
lr_schedule: [20, 50, 100, 300]
num_gpus: 1
epochs: 1000
================================================
FILE: configs/swingstick_non_magnetic/latentpred/config2.yaml
================================================
lr: 0.03
seed: 2
if_cuda: True
gamma: 0.5
log_dir: 'logs'
train_batch: 512
val_batch: 256
test_batch: 256
num_workers: 8
model_name: 'latent-prediction'
data_filepath: './data/'
dataset: 'swingstick_non_magnetic'
lr_schedule: [20, 50, 100, 300]
num_gpus: 1
epochs: 1000
================================================
FILE: configs/swingstick_non_magnetic/latentpred/config3.yaml
================================================
lr: 0.01
seed: 3
if_cuda: True
gamma: 0.5
log_dir: 'logs'
train_batch: 512
val_batch: 256
test_batch: 256
num_workers: 8
model_name: 'latent-prediction'
data_filepath: './data/'
dataset: 'swingstick_non_magnetic'
lr_schedule: [20, 50, 100, 300]
num_gpus: 1
epochs: 1000
================================================
FILE: configs/swingstick_non_magnetic/model/config1.yaml
================================================
lr: 0.001
seed: 1
if_cuda: True
gamma: 0.5
log_dir: 'logs'
train_batch: 512
val_batch: 256
test_batch: 256
num_workers: 8
model_name: 'encoder-decoder'
data_filepath: './data/'
dataset: 'swingstick_non_magnetic'
lr_schedule: [20, 50, 100, 300]
num_gpus: 1
epochs: 1000
================================================
FILE: configs/swingstick_non_magnetic/model/config2.yaml
================================================
lr: 0.001
seed: 2
if_cuda: True
gamma: 0.5
log_dir: 'logs'
train_batch: 512
val_batch: 256
test_batch: 256
num_workers: 8
model_name: 'encoder-decoder'
data_filepath: './data/'
dataset: 'swingstick_non_magnetic'
lr_schedule: [20, 50, 100, 300]
num_gpus: 1
epochs: 1000
================================================
FILE: configs/swingstick_non_magnetic/model/config3.yaml
================================================
lr: 0.001
seed: 3
if_cuda: True
gamma: 0.5
log_dir: 'logs'
train_batch: 512
val_batch: 256
test_batch: 256
num_workers: 8
model_name: 'encoder-decoder'
data_filepath: './data/'
dataset: 'swingstick_non_magnetic'
lr_schedule: [20, 50, 100, 300]
num_gpus: 1
epochs: 1000
================================================
FILE: configs/swingstick_non_magnetic/model64/config1.yaml
================================================
lr: 0.001
seed: 1
if_cuda: True
gamma: 0.5
log_dir: 'logs'
train_batch: 512
val_batch: 256
test_batch: 256
num_workers: 8
model_name: 'encoder-decoder-64'
data_filepath: './data/'
dataset: 'swingstick_non_magnetic'
lr_schedule: [20, 50, 100, 300]
num_gpus: 1
epochs: 1000
================================================
FILE: configs/swingstick_non_magnetic/model64/config2.yaml
================================================
lr: 0.001
seed: 2
if_cuda: True
gamma: 0.5
log_dir: 'logs'
train_batch: 512
val_batch: 256
test_batch: 256
num_workers: 8
model_name: 'encoder-decoder-64'
data_filepath: './data/'
dataset: 'swingstick_non_magnetic'
lr_schedule: [20, 50, 100, 300]
num_gpus: 1
epochs: 1000
================================================
FILE: configs/swingstick_non_magnetic/model64/config3.yaml
================================================
lr: 0.001
seed: 3
if_cuda: True
gamma: 0.5
log_dir: 'logs'
train_batch: 512
val_batch: 256
test_batch: 256
num_workers: 8
model_name: 'encoder-decoder-64'
data_filepath: './data/'
dataset: 'swingstick_non_magnetic'
lr_schedule: [20, 50, 100, 300]
num_gpus: 1
epochs: 1000
================================================
FILE: configs/swingstick_non_magnetic/refine64/config1.yaml
================================================
lr: 0.0005
seed: 1
if_cuda: True
gamma: 0.5
log_dir: 'logs'
train_batch: 512
val_batch: 256
test_batch: 256
num_workers: 8
model_name: 'refine-64'
data_filepath: './data/'
dataset: 'swingstick_non_magnetic'
lr_schedule: [15, 30, 100, 300]
num_gpus: 1
epochs: 1000
================================================
FILE: configs/swingstick_non_magnetic/refine64/config2.yaml
================================================
lr: 0.0001
seed: 2
if_cuda: True
gamma: 0.5
log_dir: 'logs'
train_batch: 512
val_batch: 256
test_batch: 256
num_workers: 8
model_name: 'refine-64'
data_filepath: './data/'
dataset: 'swingstick_non_magnetic'
lr_schedule: [15, 30, 100, 300]
num_gpus: 1
epochs: 1000
================================================
FILE: configs/swingstick_non_magnetic/refine64/config3.yaml
================================================
lr: 0.0004
seed: 3
if_cuda: True
gamma: 0.5
log_dir: 'logs'
train_batch: 512
val_batch: 256
test_batch: 256
num_workers: 8
model_name: 'refine-64'
data_filepath: './data/'
dataset: 'swingstick_non_magnetic'
lr_schedule: [15, 30, 100, 300]
num_gpus: 1
epochs: 1000
================================================
FILE: datainfo/README.md
================================================
## Data Collection
- single_pendulum, elastic_pendulum, reaction_diffusion, circular_motion: simulation codes to generate the simulation data.
- double_pendulum: post processings.
- fire, lava_lamp: split long sequences.
- utils: split long sequences.
## Data Structure for Using Your Own Dataset
All of our datasets follow the structure below. Please prepare any new dataset as follows to use the current dataloader.
If you want to use a different file organization, you will need to write your own dataloader.
```
\double_pendulum
\0
\0.png
\1.png
\...
\1
\...
\2
\...
...
```
================================================
FILE: datainfo/air_dancer/data_split_dict_1.json
================================================
{
"test": [
2,
18,
4
],
"val": [
15,
3,
8
],
"train": [
23,
24,
11,
10,
22,
1,
5,
25,
19,
13,
9,
17,
16,
0,
7,
21,
6,
12,
20,
14
]
}
================================================
FILE: datainfo/air_dancer/data_split_dict_2.json
================================================
{
"test": [
24,
2,
1
],
"val": [
9,
5,
11
],
"train": [
3,
20,
17,
15,
0,
23,
4,
7,
14,
16,
19,
22,
12,
18,
10,
13,
21,
25,
6,
8
]
}
================================================
FILE: datainfo/air_dancer/data_split_dict_3.json
================================================
{
"test": [
17,
18,
7
],
"val": [
19,
11,
4
],
"train": [
6,
16,
23,
14,
1,
5,
21,
10,
9,
13,
25,
12,
3,
8,
22,
20,
0,
2,
24,
15
]
}
================================================
FILE: datainfo/circular_motion/data_split_dict_1.json
================================================
{
"test": [
524,
1032,
960,
907,
977,
840,
877,
802,
392,
5,
746,
980,
623,
1068,
675,
1098,
931,
470,
361,
591,
867,
975,
352,
526,
414,
237,
561,
880,
942,
552,
1059,
789,
12,
1005,
464,
345,
348,
806,
631,
89,
961,
60,
1002,
758,
1046,
335,
221,
898,
177,
767,
751,
354,
848,
827,
497,
983,
70,
805,
1034,
1022,
581,
621,
388,
1039,
1072,
1025,
681,
247,
607,
380,
204,
852,
44,
593,
941,
448,
472,
707,
477,
1015,
896,
454,
59,
864,
443,
780,
18,
52,
45,
62,
650,
209,
468,
545,
912,
4,
886,
798,
58,
999,
192,
429,
777,
967,
920,
1014,
241,
522,
129,
275
],
"val": [
456,
164,
736,
36,
149,
406,
1075,
230,
21,
1017,
442,
620,
214,
1096,
747,
259,
111,
264,
1089,
815,
431,
351,
395,
319,
24,
116,
485,
508,
329,
719,
465,
301,
728,
663,
279,
672,
172,
540,
1063,
163,
171,
71,
297,
1011,
189,
639,
944,
112,
1004,
255,
287,
773,
772,
14,
463,
17,
888,
85,
72,
689,
861,
33,
261,
836,
871,
816,
564,
817,
93,
881,
185,
598,
563,
181,
1079,
235,
823,
28,
614,
469,
339,
627,
1033,
638,
553,
551,
1,
1040,
424,
365,
832,
496,
423,
516,
963,
1019,
567,
583,
373,
890,
492,
57,
972,
436,
210,
574,
796,
531,
132,
828
],
"train": [
391,
479,
51,
1077,
882,
625,
268,
197,
433,
635,
246,
685,
640,
803,
131,
398,
1070,
580,
924,
863,
962,
238,
39,
763,
653,
455,
608,
869,
680,
768,
634,
107,
514,
509,
884,
417,
219,
146,
311,
630,
996,
290,
80,
911,
366,
353,
130,
814,
1001,
765,
100,
565,
487,
498,
158,
147,
862,
887,
13,
529,
295,
444,
916,
795,
722,
260,
1016,
950,
609,
284,
895,
542,
535,
381,
450,
294,
750,
502,
494,
326,
556,
67,
1057,
384,
933,
143,
644,
362,
1084,
120,
16,
1094,
706,
788,
233,
905,
1036,
596,
733,
853,
418,
254,
119,
26,
559,
575,
549,
1088,
834,
966,
202,
434,
1095,
95,
308,
507,
590,
154,
988,
357,
1008,
425,
360,
234,
778,
819,
883,
90,
793,
611,
1028,
901,
812,
740,
432,
923,
68,
289,
167,
679,
784,
1093,
186,
671,
891,
849,
316,
729,
669,
213,
375,
801,
304,
991,
569,
9,
633,
603,
428,
190,
940,
642,
368,
771,
857,
282,
263,
419,
330,
1031,
420,
655,
876,
520,
1041,
544,
194,
791,
81,
122,
859,
3,
656,
1042,
201,
956,
753,
266,
262,
782,
243,
334,
54,
99,
341,
140,
280,
1027,
421,
787,
43,
401,
96,
115,
989,
1071,
973,
56,
734,
1061,
617,
850,
30,
928,
534,
573,
1067,
968,
949,
499,
343,
868,
990,
837,
242,
1092,
482,
1083,
992,
568,
350,
723,
969,
612,
467,
344,
810,
503,
1087,
693,
807,
619,
174,
717,
1076,
594,
29,
624,
586,
718,
336,
809,
926,
616,
441,
409,
1045,
1053,
954,
134,
451,
501,
537,
731,
533,
1010,
1006,
491,
708,
206,
688,
125,
927,
113,
770,
459,
709,
453,
390,
200,
713,
402,
906,
152,
538,
25,
379,
654,
766,
188,
267,
493,
661,
137,
776,
121,
764,
687,
430,
978,
570,
800,
47,
82,
701,
489,
959,
396,
762,
1020,
35,
216,
939,
50,
1007,
1026,
23,
948,
702,
438,
248,
987,
878,
77,
155,
278,
745,
135,
178,
998,
309,
37,
676,
759,
775,
870,
79,
1048,
539,
712,
699,
148,
412,
613,
986,
385,
34,
446,
484,
915,
207,
774,
979,
199,
657,
378,
269,
184,
371,
271,
856,
845,
394,
532,
359,
997,
673,
476,
739,
478,
236,
821,
515,
372,
665,
865,
695,
831,
965,
285,
879,
892,
958,
331,
1000,
666,
1090,
889,
374,
1091,
974,
276,
156,
179,
585,
643,
226,
935,
0,
714,
781,
790,
510,
1049,
257,
223,
447,
293,
651,
530,
825,
69,
332,
370,
1052,
548,
1065,
525,
6,
382,
291,
474,
726,
413,
55,
415,
452,
104,
196,
292,
756,
519,
1078,
215,
647,
716,
913,
779,
437,
1013,
582,
866,
748,
829,
571,
705,
299,
527,
139,
698,
277,
75,
606,
88,
1066,
838,
427,
124,
648,
321,
15,
725,
296,
486,
270,
97,
2,
286,
383,
193,
127,
808,
151,
338,
854,
483,
1080,
1050,
307,
677,
61,
108,
636,
700,
318,
684,
546,
166,
909,
84,
696,
1035,
462,
602,
481,
195,
760,
860,
123,
473,
435,
227,
517,
358,
900,
337,
495,
715,
315,
397,
785,
142,
936,
737,
622,
769,
660,
1074,
168,
393,
356,
403,
1018,
53,
833,
855,
659,
159,
180,
386,
641,
126,
87,
475,
169,
1058,
599,
844,
902,
208,
543,
918,
377,
523,
73,
595,
224,
281,
1024,
422,
1085,
490,
506,
724,
244,
231,
1064,
512,
953,
541,
952,
7,
994,
239,
662,
176,
410,
407,
730,
914,
572,
749,
141,
363,
63,
19,
841,
903,
1043,
1069,
830,
1038,
405,
11,
1023,
597,
449,
670,
678,
562,
440,
457,
683,
839,
253,
49,
161,
550,
946,
306,
182,
820,
566,
323,
32,
558,
145,
211,
1097,
300,
1012,
109,
312,
938,
144,
153,
183,
1037,
826,
743,
652,
513,
943,
157,
674,
505,
367,
921,
692,
22,
76,
847,
757,
930,
752,
804,
249,
20,
872,
250,
94,
792,
649,
1029,
874,
103,
342,
251,
310,
592,
682,
191,
799,
42,
668,
811,
232,
985,
658,
588,
92,
458,
91,
929,
738,
369,
252,
203,
314,
710,
554,
187,
265,
364,
480,
704,
632,
220,
256,
114,
466,
615,
324,
65,
64,
408,
320,
400,
460,
327,
610,
727,
10,
27,
908,
325,
667,
212,
102,
322,
488,
894,
741,
910,
555,
744,
445,
105,
842,
1056,
697,
919,
1009,
118,
165,
899,
600,
245,
897,
754,
843,
971,
947,
932,
686,
628,
1021,
735,
46,
110,
283,
1081,
893,
786,
577,
302,
993,
273,
83,
579,
229,
951,
584,
846,
824,
601,
629,
117,
349,
851,
150,
389,
74,
416,
40,
858,
813,
945,
1062,
797,
500,
732,
618,
783,
298,
904,
1054,
346,
376,
917,
995,
957,
340,
274,
794,
964,
170,
173,
136,
86,
41,
742,
66,
240,
1082,
970,
547,
703,
922,
560,
1051,
98,
818,
272,
218,
439,
347,
138,
576,
1047,
955,
160,
885,
288,
411,
626,
333,
934,
511,
981,
303,
399,
1055,
106,
504,
198,
605,
1073,
690,
587,
1044,
101,
355,
205,
387,
835,
521,
637,
720,
1086,
175,
471,
976,
222,
604,
38,
984,
8,
133,
258,
578,
426,
162,
761,
873,
317,
78,
937,
313,
48,
217,
128,
305,
755,
1030,
875,
646,
1003,
328,
822,
589,
691,
404,
31,
664,
536,
228,
461,
528,
711,
925,
645,
225,
1060,
557,
982,
694,
518,
721
]
}
================================================
FILE: datainfo/circular_motion/data_split_dict_2.json
================================================
{
"test": [
24,
688,
255,
176,
368,
371,
58,
32,
777,
734,
919,
433,
61,
901,
966,
215,
844,
250,
272,
874,
139,
534,
772,
108,
937,
896,
698,
232,
605,
1066,
50,
668,
588,
60,
217,
391,
17,
699,
154,
750,
1001,
425,
638,
832,
1032,
621,
633,
982,
1082,
340,
664,
454,
996,
935,
718,
1062,
931,
1057,
1025,
1020,
571,
1003,
511,
944,
818,
330,
1060,
741,
724,
1079,
849,
912,
372,
1052,
736,
1065,
1044,
279,
355,
665,
361,
48,
472,
483,
363,
336,
867,
778,
652,
952,
745,
56,
1090,
549,
1028,
911,
761,
1042,
805,
882,
324,
73,
434,
515,
631,
346,
739,
173,
187,
115
],
"val": [
810,
639,
233,
1017,
82,
256,
75,
455,
731,
238,
252,
1041,
725,
520,
237,
650,
464,
98,
174,
165,
134,
34,
259,
995,
686,
143,
1049,
716,
18,
1048,
429,
620,
268,
265,
349,
924,
147,
335,
527,
498,
402,
799,
598,
530,
986,
895,
807,
458,
989,
104,
858,
323,
703,
676,
95,
230,
484,
157,
722,
636,
883,
411,
773,
270,
923,
46,
757,
619,
784,
564,
459,
315,
31,
500,
345,
292,
1098,
765,
760,
642,
630,
352,
4,
37,
155,
253,
813,
44,
603,
394,
1,
708,
535,
188,
752,
160,
958,
1033,
130,
261,
382,
21,
940,
746,
41,
25,
69,
977,
117,
84
],
"train": [
521,
97,
212,
436,
465,
835,
410,
195,
591,
288,
988,
828,
450,
127,
42,
93,
92,
970,
873,
239,
424,
1086,
956,
310,
266,
824,
142,
717,
119,
727,
1008,
357,
871,
584,
64,
396,
817,
406,
57,
2,
681,
9,
249,
864,
512,
198,
245,
40,
473,
1089,
299,
182,
601,
379,
321,
955,
763,
486,
766,
22,
906,
744,
171,
316,
702,
467,
370,
898,
274,
820,
1015,
644,
443,
707,
13,
576,
764,
109,
838,
559,
158,
26,
670,
721,
329,
789,
798,
802,
767,
133,
431,
539,
325,
672,
485,
618,
140,
135,
438,
692,
408,
608,
997,
640,
29,
344,
572,
421,
748,
6,
327,
1039,
235,
308,
796,
635,
290,
581,
713,
178,
612,
943,
568,
866,
207,
546,
519,
917,
889,
214,
339,
111,
448,
35,
63,
248,
282,
405,
163,
629,
782,
226,
659,
850,
902,
487,
1058,
592,
540,
596,
505,
831,
801,
575,
1046,
800,
833,
963,
556,
758,
504,
347,
236,
206,
441,
682,
1085,
547,
1040,
507,
87,
1094,
580,
975,
604,
648,
569,
294,
7,
916,
607,
788,
228,
281,
573,
376,
219,
915,
241,
167,
208,
1080,
216,
529,
1075,
94,
690,
907,
542,
578,
146,
120,
968,
49,
862,
211,
680,
447,
815,
586,
1068,
488,
693,
306,
271,
269,
314,
43,
792,
797,
976,
417,
954,
191,
499,
151,
729,
854,
848,
552,
781,
307,
407,
826,
881,
985,
1097,
1069,
397,
423,
508,
168,
76,
998,
627,
439,
860,
258,
229,
105,
645,
590,
751,
377,
759,
791,
597,
80,
106,
887,
891,
386,
753,
1054,
322,
100,
809,
965,
300,
843,
661,
913,
899,
617,
283,
855,
567,
99,
842,
926,
737,
574,
634,
967,
440,
987,
948,
637,
960,
886,
416,
562,
51,
513,
1019,
662,
732,
803,
66,
356,
460,
419,
897,
152,
932,
193,
359,
945,
606,
476,
583,
660,
624,
786,
369,
466,
506,
110,
557,
403,
1012,
351,
378,
1091,
981,
276,
415,
0,
251,
427,
953,
432,
942,
770,
683,
616,
566,
877,
787,
677,
456,
257,
70,
15,
286,
71,
929,
33,
123,
689,
756,
518,
332,
827,
47,
780,
614,
790,
12,
876,
112,
632,
541,
671,
129,
845,
694,
234,
156,
201,
482,
490,
884,
348,
1022,
1021,
302,
380,
921,
738,
231,
1084,
197,
210,
723,
1016,
354,
205,
964,
1038,
517,
755,
593,
1064,
305,
918,
278,
691,
1005,
1006,
242,
675,
200,
27,
116,
492,
430,
1073,
1030,
949,
687,
59,
295,
267,
920,
613,
1009,
398,
227,
880,
890,
90,
1081,
951,
785,
865,
331,
190,
172,
23,
312,
1061,
122,
362,
126,
646,
175,
45,
442,
678,
563,
446,
128,
169,
857,
775,
719,
1070,
991,
806,
623,
754,
77,
615,
684,
145,
463,
199,
304,
714,
666,
816,
863,
277,
868,
223,
333,
841,
878,
532,
808,
469,
39,
183,
85,
179,
53,
14,
65,
861,
704,
565,
1010,
457,
973,
244,
225,
647,
461,
132,
859,
247,
202,
936,
972,
962,
343,
544,
318,
1007,
149,
747,
959,
611,
385,
930,
479,
360,
445,
365,
384,
1092,
328,
287,
350,
409,
387,
743,
555,
1083,
1011,
728,
189,
776,
194,
480,
243,
101,
162,
334,
1018,
643,
649,
137,
847,
298,
452,
749,
170,
994,
554,
730,
79,
1043,
326,
218,
373,
388,
1037,
1045,
62,
284,
971,
705,
836,
888,
983,
622,
91,
516,
153,
543,
957,
837,
892,
933,
922,
673,
319,
341,
311,
651,
264,
783,
309,
551,
gitextract_ivg233ui/
├── .gitignore
├── LICENSE
├── README.md
├── analysis/
│ ├── README.md
│ ├── eval_intrinsic_dimension.py
│ ├── eval_phys_data.py
│ ├── eval_phys_double_pendulum/
│ │ ├── __init__.py
│ │ ├── angle_estimator.py
│ │ └── physics_estimator.py
│ ├── eval_phys_elastic_pendulum/
│ │ ├── __init__.py
│ │ ├── angle_estimator.py
│ │ └── physics_estimator.py
│ ├── eval_phys_long_term_pred.py
│ ├── eval_phys_single_pendulum/
│ │ ├── __init__.py
│ │ ├── angle_estimator.py
│ │ └── physics_estimator.py
│ ├── eval_regression.py
│ ├── intrinsic_dimension_estimation/
│ │ ├── __init__.py
│ │ ├── matlab_codes/
│ │ │ ├── DANCo.m
│ │ │ ├── DANCoFit.m
│ │ │ ├── DANCoTrain.m
│ │ │ ├── DANCo_fits.mat
│ │ │ ├── GetDim.mexw64
│ │ │ ├── KNN.m
│ │ │ ├── MLE.m
│ │ │ ├── MiND_KL.m
│ │ │ ├── MiND_ML.m
│ │ │ ├── demo_idEstimation.m
│ │ │ ├── gauss.m
│ │ │ ├── html/
│ │ │ │ └── demo_idEstimation.html
│ │ │ ├── linSubspSpanOrthonormalize.m
│ │ │ ├── parseParamsNamed.m
│ │ │ ├── private/
│ │ │ │ ├── DANCo_estimateKL.m
│ │ │ │ └── DANCo_statistics.m
│ │ │ └── randsphere.m
│ │ └── methods.py
│ └── latent_regression/
│ ├── __init__.py
│ └── regressors.py
├── configs/
│ ├── air_dancer/
│ │ ├── latentpred/
│ │ │ ├── config1.yaml
│ │ │ ├── config2.yaml
│ │ │ └── config3.yaml
│ │ ├── model/
│ │ │ ├── config1.yaml
│ │ │ ├── config2.yaml
│ │ │ └── config3.yaml
│ │ ├── model64/
│ │ │ ├── config1.yaml
│ │ │ ├── config2.yaml
│ │ │ └── config3.yaml
│ │ └── refine64/
│ │ ├── config1.yaml
│ │ ├── config2.yaml
│ │ └── config3.yaml
│ ├── circular_motion/
│ │ ├── model/
│ │ │ ├── config1.yaml
│ │ │ ├── config2.yaml
│ │ │ └── config3.yaml
│ │ ├── model64/
│ │ │ ├── config1.yaml
│ │ │ ├── config2.yaml
│ │ │ └── config3.yaml
│ │ └── refine64/
│ │ ├── config1.yaml
│ │ ├── config2.yaml
│ │ └── config3.yaml
│ ├── double_pendulum/
│ │ ├── latentpred/
│ │ │ ├── config1.yaml
│ │ │ ├── config2.yaml
│ │ │ └── config3.yaml
│ │ ├── model/
│ │ │ ├── config1.yaml
│ │ │ ├── config2.yaml
│ │ │ └── config3.yaml
│ │ ├── model64/
│ │ │ ├── config1.yaml
│ │ │ ├── config2.yaml
│ │ │ └── config3.yaml
│ │ └── refine64/
│ │ ├── config1.yaml
│ │ ├── config2.yaml
│ │ └── config3.yaml
│ ├── elastic_pendulum/
│ │ ├── latentpred/
│ │ │ ├── config1.yaml
│ │ │ ├── config2.yaml
│ │ │ └── config3.yaml
│ │ ├── model/
│ │ │ ├── config1.yaml
│ │ │ ├── config2.yaml
│ │ │ └── config3.yaml
│ │ ├── model64/
│ │ │ ├── config1.yaml
│ │ │ ├── config2.yaml
│ │ │ └── config3.yaml
│ │ └── refine64/
│ │ ├── config1.yaml
│ │ ├── config2.yaml
│ │ └── config3.yaml
│ ├── fire/
│ │ ├── latentpred/
│ │ │ ├── config1.yaml
│ │ │ ├── config2.yaml
│ │ │ └── config3.yaml
│ │ ├── model/
│ │ │ ├── config1.yaml
│ │ │ ├── config2.yaml
│ │ │ └── config3.yaml
│ │ ├── model64/
│ │ │ ├── config1.yaml
│ │ │ ├── config2.yaml
│ │ │ └── config3.yaml
│ │ └── refine64/
│ │ ├── config1.yaml
│ │ ├── config2.yaml
│ │ └── config3.yaml
│ ├── lava_lamp/
│ │ ├── latentpred/
│ │ │ ├── config1.yaml
│ │ │ ├── config2.yaml
│ │ │ └── config3.yaml
│ │ ├── model/
│ │ │ ├── config1.yaml
│ │ │ ├── config2.yaml
│ │ │ └── config3.yaml
│ │ ├── model64/
│ │ │ ├── config1.yaml
│ │ │ ├── config2.yaml
│ │ │ └── config3.yaml
│ │ └── refine64/
│ │ ├── config1.yaml
│ │ ├── config2.yaml
│ │ └── config3.yaml
│ ├── reaction_diffusion/
│ │ ├── latentpred/
│ │ │ ├── config1.yaml
│ │ │ ├── config2.yaml
│ │ │ └── config3.yaml
│ │ ├── model/
│ │ │ ├── config1.yaml
│ │ │ ├── config2.yaml
│ │ │ └── config3.yaml
│ │ ├── model64/
│ │ │ ├── config1.yaml
│ │ │ ├── config2.yaml
│ │ │ └── config3.yaml
│ │ └── refine64/
│ │ ├── config1.yaml
│ │ ├── config2.yaml
│ │ └── config3.yaml
│ ├── single_pendulum/
│ │ ├── latentpred/
│ │ │ ├── config1.yaml
│ │ │ ├── config2.yaml
│ │ │ └── config3.yaml
│ │ ├── model/
│ │ │ ├── config1.yaml
│ │ │ ├── config2.yaml
│ │ │ └── config3.yaml
│ │ ├── model64/
│ │ │ ├── config1.yaml
│ │ │ ├── config2.yaml
│ │ │ └── config3.yaml
│ │ └── refine64/
│ │ ├── config1.yaml
│ │ ├── config2.yaml
│ │ └── config3.yaml
│ ├── swingstick_magnetic/
│ │ ├── model/
│ │ │ ├── config1.yaml
│ │ │ ├── config2.yaml
│ │ │ └── config3.yaml
│ │ ├── model64/
│ │ │ ├── config1.yaml
│ │ │ ├── config2.yaml
│ │ │ └── config3.yaml
│ │ └── refine64/
│ │ ├── config1.yaml
│ │ ├── config2.yaml
│ │ └── config3.yaml
│ └── swingstick_non_magnetic/
│ ├── latentpred/
│ │ ├── config1.yaml
│ │ ├── config2.yaml
│ │ └── config3.yaml
│ ├── model/
│ │ ├── config1.yaml
│ │ ├── config2.yaml
│ │ └── config3.yaml
│ ├── model64/
│ │ ├── config1.yaml
│ │ ├── config2.yaml
│ │ └── config3.yaml
│ └── refine64/
│ ├── config1.yaml
│ ├── config2.yaml
│ └── config3.yaml
├── datainfo/
│ ├── README.md
│ ├── air_dancer/
│ │ ├── data_split_dict_1.json
│ │ ├── data_split_dict_2.json
│ │ └── data_split_dict_3.json
│ ├── circular_motion/
│ │ ├── data_split_dict_1.json
│ │ ├── data_split_dict_2.json
│ │ └── data_split_dict_3.json
│ ├── collect/
│ │ ├── circular_motion/
│ │ │ └── make_data.py
│ │ ├── double_pendulum/
│ │ │ ├── README.md
│ │ │ ├── convert_video.py
│ │ │ ├── equalize_background.py
│ │ │ └── split_data.py
│ │ ├── elastic_pendulum/
│ │ │ └── make_data.py
│ │ ├── fire/
│ │ │ └── split_data.py
│ │ ├── lava_lamp/
│ │ │ └── split_data.py
│ │ ├── reaction_diffusion/
│ │ │ ├── make_data.py
│ │ │ ├── reaction_diffusion.m
│ │ │ └── reaction_diffusion_rhs.m
│ │ ├── single_pendulum/
│ │ │ └── make_data.py
│ │ └── utils/
│ │ └── sort_vids.py
│ ├── double_pendulum/
│ │ ├── data_split_dict_1.json
│ │ ├── data_split_dict_2.json
│ │ └── data_split_dict_3.json
│ ├── elastic_pendulum/
│ │ ├── data_split_dict_1.json
│ │ ├── data_split_dict_2.json
│ │ └── data_split_dict_3.json
│ ├── fire/
│ │ ├── data_split_dict_1.json
│ │ ├── data_split_dict_2.json
│ │ └── data_split_dict_3.json
│ ├── lava_lamp/
│ │ ├── data_split_dict_1.json
│ │ ├── data_split_dict_2.json
│ │ └── data_split_dict_3.json
│ ├── reaction_diffusion/
│ │ ├── data_split_dict_1.json
│ │ ├── data_split_dict_2.json
│ │ └── data_split_dict_3.json
│ ├── single_pendulum/
│ │ ├── data_split_dict_1.json
│ │ ├── data_split_dict_2.json
│ │ └── data_split_dict_3.json
│ ├── swingstick_magnetic/
│ │ ├── data_split_dict_1.json
│ │ ├── data_split_dict_2.json
│ │ └── data_split_dict_3.json
│ └── swingstick_non_magnetic/
│ ├── data_split_dict_1.json
│ ├── data_split_dict_2.json
│ └── data_split_dict_3.json
├── dataset.py
├── eval.py
├── main.py
├── model_utils.py
├── models.py
├── models_latentpred.py
├── pred.py
├── requirements.txt
├── scripts/
│ ├── encoder_decoder_64_eval.sh
│ ├── encoder_decoder_64_eval_gather.sh
│ ├── encoder_decoder_64_long_term_model_rollout.sh
│ ├── encoder_decoder_64_long_term_model_rollout_perturb_all.sh
│ ├── encoder_decoder_64_train.sh
│ ├── encoder_decoder_estimate_dimension.sh
│ ├── encoder_decoder_eval.sh
│ ├── encoder_decoder_eval_gather.sh
│ ├── encoder_decoder_long_term_model_rollout.sh
│ ├── encoder_decoder_long_term_model_rollout_perturb_all.sh
│ ├── encoder_decoder_train.sh
│ ├── latentpred_train.sh
│ ├── long_term_eval_stability.sh
│ ├── long_term_eval_stability_hybrid.sh
│ ├── refine_64_eval.sh
│ ├── refine_64_eval_gather.sh
│ ├── refine_64_long_term_hybrid_rollout.sh
│ ├── refine_64_long_term_model_rollout.sh
│ ├── refine_64_long_term_model_rollout_perturb_all.sh
│ └── refine_64_train.sh
├── stability.py
└── utils/
├── common.py
└── dimension.py
SYMBOL INDEX (220 symbols across 36 files)
FILE: analysis/eval_intrinsic_dimension.py
function load_config (line 13) | def load_config(filepath):
function remove_duplicates (line 21) | def remove_duplicates(X):
function eval_id_latent (line 25) | def eval_id_latent(vars_filepath, if_refine, if_all_methods):
function eval_id_image (line 45) | def eval_id_image(data_filepath, test_vid_ids, vars_filepath, if_all_met...
FILE: analysis/eval_phys_data.py
function eval_phys_data_single_pendulum (line 8) | def eval_phys_data_single_pendulum(data_filepath, num_vids, num_frms, sa...
function eval_phys_data_double_pendulum (line 27) | def eval_phys_data_double_pendulum(data_filepath, num_vids, num_frms, sa...
function eval_phys_data_elastic_pendulum (line 58) | def eval_phys_data_elastic_pendulum(data_filepath, num_vids, num_frms, s...
FILE: analysis/eval_phys_double_pendulum/__init__.py
function eval_physics (line 11) | def eval_physics(frames):
FILE: analysis/eval_phys_double_pendulum/angle_estimator.py
function seg_from_img (line 22) | def seg_from_img(img):
function fit_pendulum (line 50) | def fit_pendulum(seg):
function estimate_angle (line 85) | def estimate_angle(rect, ref_pt):
function obtain_angle (line 119) | def obtain_angle(img):
FILE: analysis/eval_phys_double_pendulum/physics_estimator.py
function calc_diff (line 20) | def calc_diff(th1, th2):
function calc_avrg (line 29) | def calc_avrg(th1, th2):
function calc_velocity (line 44) | def calc_velocity(th, method='spline'):
function calc_energy (line 83) | def calc_energy(th1, th2, vel_th1, vel_th2):
FILE: analysis/eval_phys_elastic_pendulum/__init__.py
function eval_physics (line 11) | def eval_physics(frames):
FILE: analysis/eval_phys_elastic_pendulum/angle_estimator.py
function seg_from_img (line 22) | def seg_from_img(img):
function fit_pendulum (line 50) | def fit_pendulum(seg):
function estimate_angle (line 85) | def estimate_angle(rect, ref_pt):
function obtain_angle_stretch (line 120) | def obtain_angle_stretch(img):
FILE: analysis/eval_phys_elastic_pendulum/physics_estimator.py
function calc_diff (line 22) | def calc_diff(th1, th2):
function calc_avrg (line 31) | def calc_avrg(th1, th2):
function normalize_angle (line 43) | def normalize_angle(theta):
function calc_velocity (line 52) | def calc_velocity(x, method='spline', periodic=True):
function calc_energy (line 92) | def calc_energy(th1, th2, z, vel_th1, vel_th2, vel_z):
FILE: analysis/eval_phys_long_term_pred.py
function calc_diff (line 21) | def calc_diff(th1, th2):
function calc_pixel_MSE (line 29) | def calc_pixel_MSE(img1, img2):
function load_config (line 32) | def load_config(filepath):
function eval_pred_physics (line 41) | def eval_pred_physics(data_filepath, pred_save_path, vid_ids, phys_vars_...
function load_data_physics (line 69) | def load_data_physics(data_filepath, vid_ids, phys_vars_list):
function eval_physics_error (line 76) | def eval_physics_error(phys_pred, phys_data, phys_vars_list):
function eval_pixel_error (line 95) | def eval_pixel_error(data_filepath, pred_save_path, vid_ids):
function main (line 117) | def main():
FILE: analysis/eval_phys_single_pendulum/__init__.py
function eval_physics (line 11) | def eval_physics(frames):
FILE: analysis/eval_phys_single_pendulum/angle_estimator.py
function seg_from_img (line 21) | def seg_from_img(img):
function fit_pendulum (line 40) | def fit_pendulum(seg):
function estimate_angle (line 74) | def estimate_angle(rect):
function obtain_angle (line 108) | def obtain_angle(img):
FILE: analysis/eval_phys_single_pendulum/physics_estimator.py
function calc_diff (line 20) | def calc_diff(th1, th2):
function calc_avrg (line 29) | def calc_avrg(th1, th2):
function normalize_angle (line 41) | def normalize_angle(theta):
function calc_velocity (line 50) | def calc_velocity(th, method='spline'):
function calc_energy (line 90) | def calc_energy(th, vel_th):
FILE: analysis/eval_regression.py
function load_config (line 12) | def load_config(filepath):
function parse_data_id (line 22) | def parse_data_id(data_id):
function physical_variables_from_data_ids (line 29) | def physical_variables_from_data_ids(phys_all, ids):
function main (line 51) | def main():
FILE: analysis/intrinsic_dimension_estimation/__init__.py
class ID_Estimator (line 4) | class ID_Estimator:
method __init__ (line 5) | def __init__(self, method='Levina_Bickel'):
method set_method (line 9) | def set_method(self, method='Levina_Bickel'):
method fit (line 15) | def fit(self, X, k_list=20, n_jobs=4):
method fit_all_methods (line 41) | def fit_all_methods(self, X, k_list=[20], n_jobs=4):
FILE: analysis/intrinsic_dimension_estimation/methods.py
function kNN (line 6) | def kNN(X, n_neighbors, n_jobs):
function Levina_Bickel (line 12) | def Levina_Bickel(X, dists, k):
function start_matlab_engine (line 19) | def start_matlab_engine():
function MiND_ML (line 26) | def MiND_ML(X, dists, k):
function MiND_KL (line 35) | def MiND_KL(X, dists, k, maxDim=30):
function DANCo (line 45) | def DANCo(X, dists, inds, k, maxDim=30):
function Hein_CD (line 56) | def Hein_CD(X):
FILE: analysis/latent_regression/regressors.py
function mlp_regress (line 8) | def mlp_regress(X_train, X_test, y_train, y_test, random_state=0):
function lin_regress (line 21) | def lin_regress(X_train, X_test, y_train, y_test):
function pca (line 29) | def pca(X_train, X_test, num_components, random_state=0):
FILE: datainfo/collect/circular_motion/make_data.py
function mkdir (line 7) | def mkdir(folder):
function coord2img (line 21) | def coord2img(x, y):
FILE: datainfo/collect/double_pendulum/convert_video.py
function mkdir (line 13) | def mkdir(folder):
function get_arguments (line 19) | def get_arguments():
function write_frames (line 30) | def write_frames(video_path, frame_path, fps, seed):
FILE: datainfo/collect/double_pendulum/equalize_background.py
function mkdir (line 15) | def mkdir(folder):
function get_arguments (line 21) | def get_arguments():
FILE: datainfo/collect/double_pendulum/split_data.py
function mkdir (line 12) | def mkdir(folder):
function get_arguments (line 18) | def get_arguments():
FILE: datainfo/collect/elastic_pendulum/make_data.py
function mkdir (line 9) | def mkdir(folder):
function engine (line 15) | def engine(rng, num_frm, fps=60):
function draw_rect (line 58) | def draw_rect(im, col, top_x, top_y, w, h, theta):
function render (line 73) | def render(theta_1, theta_2, z):
function make_data (line 95) | def make_data(data_filepath, num_seq, num_frm, seed=0):
FILE: datainfo/collect/fire/split_data.py
function mkdir (line 12) | def mkdir(folder):
function get_arguments (line 18) | def get_arguments():
FILE: datainfo/collect/lava_lamp/split_data.py
function mkdir (line 12) | def mkdir(folder):
function get_arguments (line 18) | def get_arguments():
FILE: datainfo/collect/reaction_diffusion/make_data.py
function mkdir (line 10) | def mkdir(folder):
function make_data (line 16) | def make_data(data_filepath, num_frm):
FILE: datainfo/collect/single_pendulum/make_data.py
function mkdir (line 8) | def mkdir(folder):
function engine (line 14) | def engine(rng, num_frm, fps=60):
function render (line 32) | def render(theta):
function make_data (line 42) | def make_data(data_filepath, num_seq, num_frm, seed=0):
FILE: datainfo/collect/utils/sort_vids.py
function mkdir (line 10) | def mkdir(folder):
FILE: dataset.py
class NeuralPhysDataset (line 14) | class NeuralPhysDataset(Dataset):
method __init__ (line 15) | def __init__(self, data_filepath, flag, seed, object_name="double_pend...
method get_all_filelist (line 22) | def get_all_filelist(self):
method __len__ (line 42) | def __len__(self):
method __getitem__ (line 46) | def __getitem__(self, idx):
method get_data (line 59) | def get_data(self, filepath):
class NeuralPhysLatentDynamicsDataset (line 69) | class NeuralPhysLatentDynamicsDataset(Dataset):
method __init__ (line 70) | def __init__(self, data_filepath, flag, seed, object_name="double_pend...
method get_all_filelist (line 77) | def get_all_filelist(self):
method __len__ (line 97) | def __len__(self):
method __getitem__ (line 101) | def __getitem__(self, idx):
method get_data (line 118) | def get_data(self, filepath):
FILE: eval.py
function mkdir (line 21) | def mkdir(folder):
function load_config (line 26) | def load_config(filepath):
function seed (line 34) | def seed(cfg):
function main (line 40) | def main():
function main_latentpred (line 97) | def main_latentpred():
function rename_ckpt_for_multi_models (line 144) | def rename_ckpt_for_multi_models(ckpt):
function gather_latent_from_trained_high_dim_model (line 155) | def gather_latent_from_trained_high_dim_model():
function gather_latent_from_trained_refine_model (line 253) | def gather_latent_from_trained_refine_model():
FILE: main.py
function load_config (line 15) | def load_config(filepath):
function seed (line 23) | def seed(cfg):
function main (line 29) | def main():
function main_latentpred (line 77) | def main_latentpred():
FILE: model_utils.py
function conv2d_bn_relu (line 7) | def conv2d_bn_relu(inch,outch,kernel_size,stride=1,padding=1):
function conv2d_bn_sigmoid (line 15) | def conv2d_bn_sigmoid(inch,outch,kernel_size,stride=1,padding=1):
function deconv_sigmoid (line 23) | def deconv_sigmoid(inch,outch,kernel_size,stride=1,padding=1):
function deconv_relu (line 30) | def deconv_relu(inch,outch,kernel_size,stride=1,padding=1):
class EncoderDecoder (line 40) | class EncoderDecoder(torch.nn.Module):
method __init__ (line 41) | def __init__(self, in_channels):
method encoder (line 94) | def encoder(self, x):
method decoder (line 102) | def decoder(self, x):
method forward (line 123) | def forward(self,x):
class EncoderDecoder64x1x1 (line 128) | class EncoderDecoder64x1x1(torch.nn.Module):
method __init__ (line 129) | def __init__(self, in_channels):
method encoder (line 220) | def encoder(self, x):
method decoder (line 231) | def decoder(self, x):
method forward (line 265) | def forward(self,x, reconstructed_latent, refine_latent):
class SirenLayer (line 275) | class SirenLayer(nn.Module):
method __init__ (line 276) | def __init__(self, in_f, out_f, w0=30, is_first=False, is_last=False):
method init_weights (line 285) | def init_weights(self):
method forward (line 290) | def forward(self, x):
class RefineDoublePendulumModel (line 294) | class RefineDoublePendulumModel(torch.nn.Module):
method __init__ (line 295) | def __init__(self, in_channels):
method forward (line 307) | def forward(self, x):
class RefineElasticPendulumModel (line 318) | class RefineElasticPendulumModel(torch.nn.Module):
method __init__ (line 319) | def __init__(self, in_channels):
method forward (line 331) | def forward(self, x):
class RefineReactionDiffusionModel (line 342) | class RefineReactionDiffusionModel(torch.nn.Module):
method __init__ (line 343) | def __init__(self, in_channels):
method forward (line 355) | def forward(self, x):
class RefineSwingStickNonMagneticModel (line 366) | class RefineSwingStickNonMagneticModel(torch.nn.Module):
method __init__ (line 367) | def __init__(self, in_channels):
method forward (line 379) | def forward(self, x):
class RefineSinglePendulumModel (line 390) | class RefineSinglePendulumModel(torch.nn.Module):
method __init__ (line 391) | def __init__(self, in_channels):
method forward (line 403) | def forward(self, x):
class RefineCircularMotionModel (line 415) | class RefineCircularMotionModel(torch.nn.Module):
method __init__ (line 416) | def __init__(self, in_channels):
method forward (line 428) | def forward(self, x):
class RefineAirDancerModel (line 439) | class RefineAirDancerModel(torch.nn.Module):
method __init__ (line 440) | def __init__(self, in_channels):
method forward (line 452) | def forward(self, x):
class RefineLavaLampModel (line 463) | class RefineLavaLampModel(torch.nn.Module):
method __init__ (line 464) | def __init__(self, in_channels):
method forward (line 476) | def forward(self, x):
class RefineFireModel (line 487) | class RefineFireModel(torch.nn.Module):
method __init__ (line 488) | def __init__(self, in_channels):
method forward (line 500) | def forward(self, x):
class RefineModelReLU (line 512) | class RefineModelReLU(torch.nn.Module):
method __init__ (line 513) | def __init__(self, in_channels):
method forward (line 528) | def forward(self, x):
class LatentPredModel (line 538) | class LatentPredModel(torch.nn.Module):
method __init__ (line 539) | def __init__(self, in_channels):
method forward (line 554) | def forward(self, x):
FILE: models.py
function mkdir (line 29) | def mkdir(folder):
class VisDynamicsModel (line 34) | class VisDynamicsModel(pl.LightningModule):
method __init__ (line 36) | def __init__(self,
method __build_model (line 63) | def __build_model(self):
method train_forward (line 92) | def train_forward(self, x):
method training_step (line 99) | def training_step(self, batch, batch_idx):
method validation_step (line 107) | def validation_step(self, batch, batch_idx):
method test_step (line 115) | def test_step(self, batch, batch_idx):
method test_save (line 173) | def test_save(self):
method configure_optimizers (line 183) | def configure_optimizers(self):
method paths_to_tuple (line 188) | def paths_to_tuple(self, paths):
method setup (line 195) | def setup(self, stage=None):
method train_dataloader (line 234) | def train_dataloader(self):
method val_dataloader (line 241) | def val_dataloader(self):
method test_dataloader (line 248) | def test_dataloader(self):
FILE: models_latentpred.py
function mkdir (line 31) | def mkdir(folder):
function rename_ckpt_for_multi_models (line 36) | def rename_ckpt_for_multi_models(ckpt):
class VisLatentDynamicsModel (line 44) | class VisLatentDynamicsModel(pl.LightningModule):
method __init__ (line 46) | def __init__(self,
method __build_model (line 73) | def __build_model(self):
method load_model (line 110) | def load_model(self, checkpoint_filepath):
method load_high_dim_refine_model (line 121) | def load_high_dim_refine_model(self, high_dim_checkpoint_filepath, ref...
method extract_decoder_from_refine_model (line 141) | def extract_decoder_from_refine_model(self):
method data_to_state (line 149) | def data_to_state(self, data):
method training_step (line 156) | def training_step(self, batch, batch_idx):
method validation_step (line 166) | def validation_step(self, batch, batch_idx):
method test_step (line 176) | def test_step(self, batch, batch_idx):
method configure_optimizers (line 204) | def configure_optimizers(self):
method setup (line 209) | def setup(self, stage=None):
method train_dataloader (line 226) | def train_dataloader(self):
method val_dataloader (line 233) | def val_dataloader(self):
method test_dataloader (line 240) | def test_dataloader(self):
FILE: pred.py
function mkdir (line 39) | def mkdir(folder):
function load_config (line 44) | def load_config(filepath):
function seed (line 52) | def seed(cfg):
function model_rollout (line 60) | def model_rollout():
function model_rollout_hybrid (line 213) | def model_rollout_hybrid(step):
function model_rollout_perturb (line 319) | def model_rollout_perturb(perturb_type, perturb_level):
function rename_ckpt_for_multi_models (line 480) | def rename_ckpt_for_multi_models(ckpt):
function get_data (line 490) | def get_data(filepath):
function get_data_perturb (line 498) | def get_data_perturb(filepath, perturb_type, perturb_level):
function tensor_to_img (line 527) | def tensor_to_img(out_tensor):
FILE: stability.py
function mkdir (line 19) | def mkdir(folder):
function load_config (line 24) | def load_config(filepath):
function seed (line 32) | def seed(cfg):
function get_data (line 38) | def get_data(filepath):
function main (line 47) | def main():
FILE: utils/common.py
function mkdir (line 10) | def mkdir(folder):
function create_random_data_splits (line 16) | def create_random_data_splits(seed, data_filepath, object_name, ratio=0.8):
function separate_eval_image (line 39) | def separate_eval_image(filepath):
function collect_long_term_pred_sample (line 49) | def collect_long_term_pred_sample(dataset, seed, test_vid_id, hybrid_ste...
function light_color (line 99) | def light_color(col):
function update_figure (line 106) | def update_figure(fig):
function test (line 119) | def test():
FILE: utils/dimension.py
function load_config (line 8) | def load_config(filepath):
function calculate_intrinsic_dimension_statistics (line 17) | def calculate_intrinsic_dimension_statistics(dataset, model_type='model'...
function calculate_intrinsic_dimension_statistics_all_methods (line 38) | def calculate_intrinsic_dimension_statistics_all_methods(dataset, model_...
Condensed preview — 227 files, each showing path, character count, and a content snippet. Download the .json file or copy for the full structured content (630K chars).
[
{
"path": ".gitignore",
"chars": 34,
"preview": "*.*~\n*~\n__pycache__\nscripts/logs_*"
},
{
"path": "LICENSE",
"chars": 1068,
"preview": "MIT License\n\nCopyright (c) 2021 Boyuan Chen\n\nPermission is hereby granted, free of charge, to any person obtaining a cop"
},
{
"path": "README.md",
"chars": 9877,
"preview": "# Discovering State Variables Hidden in Experimental Data\n\n[Boyuan Chen](http://boyuanchen.com/),\n[Kuang Huang](https://"
},
{
"path": "analysis/README.md",
"chars": 5193,
"preview": "\n## Physics Evaluation on Known Systems\n\nWe provide physics evaluation algorithms extracting physical variables includin"
},
{
"path": "analysis/eval_intrinsic_dimension.py",
"chars": 4019,
"preview": "import numpy as np\nimport os\nimport sys\nfrom tqdm import tqdm\nfrom PIL import Image\nimport json\nimport yaml\nimport pprin"
},
{
"path": "analysis/eval_phys_data.py",
"chars": 4210,
"preview": "import os\nimport sys\nimport cv2\nimport numpy as np\nfrom tqdm import tqdm\n\n\ndef eval_phys_data_single_pendulum(data_filep"
},
{
"path": "analysis/eval_phys_double_pendulum/__init__.py",
"chars": 1642,
"preview": "from .angle_estimator import obtain_angle\nfrom .physics_estimator import *\n\nimport numpy as np\n\n\nphys_vars_list = {'reje"
},
{
"path": "analysis/eval_phys_double_pendulum/angle_estimator.py",
"chars": 5036,
"preview": "'''\nThis script provides utility functions estimating angles of a double pendulum from image.\nStep 1. Extract each of th"
},
{
"path": "analysis/eval_phys_double_pendulum/physics_estimator.py",
"chars": 3271,
"preview": "'''\nThis script provides utility functions estimating angular velocities\nand other physical quantities from angles of do"
},
{
"path": "analysis/eval_phys_elastic_pendulum/__init__.py",
"chars": 1959,
"preview": "from .angle_estimator import obtain_angle_stretch\nfrom .physics_estimator import *\n\nimport numpy as np\n\n\nphys_vars_list "
},
{
"path": "analysis/eval_phys_elastic_pendulum/angle_estimator.py",
"chars": 5687,
"preview": "'''\nThis script provides utility functions estimating angles and stretch of a elastic double pendulum from image.\nStep 1"
},
{
"path": "analysis/eval_phys_elastic_pendulum/physics_estimator.py",
"chars": 3256,
"preview": "'''\nThis script provides utility functions estimating velocities\nand other physical quantities of elastic double pendulu"
},
{
"path": "analysis/eval_phys_long_term_pred.py",
"chars": 5106,
"preview": "\"\"\"\nEvaluate long-term prediction accuracy in physical variables.\n\"\"\"\n\nimport os\nimport sys\nimport numpy as np\nfrom scip"
},
{
"path": "analysis/eval_phys_single_pendulum/__init__.py",
"chars": 1251,
"preview": "from .angle_estimator import obtain_angle\nfrom .physics_estimator import *\n\nimport numpy as np\n\n\nphys_vars_list = {'reje"
},
{
"path": "analysis/eval_phys_single_pendulum/angle_estimator.py",
"chars": 3832,
"preview": "'''\nThis script provides utility functions estimating the angle of a single pendulum from image.\nStep 1. Extract the pen"
},
{
"path": "analysis/eval_phys_single_pendulum/physics_estimator.py",
"chars": 2490,
"preview": "'''\nThis script provides utility functions estimating angular velocities\nand other physical quantities from angles of si"
},
{
"path": "analysis/eval_regression.py",
"chars": 4601,
"preview": "import os\nimport sys\nimport numpy as np\nfrom tqdm import tqdm\nimport json\nimport yaml\nimport pprint\nfrom munch import mu"
},
{
"path": "analysis/intrinsic_dimension_estimation/__init__.py",
"chars": 2073,
"preview": "import numpy as np\nfrom .methods import *\n\nclass ID_Estimator:\n def __init__(self, method='Levina_Bickel'):\n s"
},
{
"path": "analysis/intrinsic_dimension_estimation/matlab_codes/DANCo.m",
"chars": 5447,
"preview": "function [d,kl] = DANCo(data,varargin)\n% DANCO Estmating the intrinsic dimensionality of a dataset\n%\n% function [d,kl] "
},
{
"path": "analysis/intrinsic_dimension_estimation/matlab_codes/DANCoFit.m",
"chars": 4127,
"preview": "function [d,kl] = DANCoFit(data,varargin)\n% DANCOFIT Estmating the intrinsic dimensionality of a dataset\n%\n% function ["
},
{
"path": "analysis/intrinsic_dimension_estimation/matlab_codes/DANCoTrain.m",
"chars": 4596,
"preview": "function DANCoTrain(modelfile,varargin)\n% DANCoTrain Training the DANCoFit model file.\n%\n% function DANCoTrain(modelfil"
},
{
"path": "analysis/intrinsic_dimension_estimation/matlab_codes/KNN.m",
"chars": 1814,
"preview": "function [inds,dists] = KNN(X,k,normalized)\n%KNN A multi-version knnsearch\n%\n% function [inds,dists] = KNN(X,k)\n%\n% Th"
},
{
"path": "analysis/intrinsic_dimension_estimation/matlab_codes/MLE.m",
"chars": 2601,
"preview": "function [d,ds] = MLE(data,varargin)\n%MLE Intrinsic dimensionality using the Levina's MLE technique\n%\n% function [d,ds]"
},
{
"path": "analysis/intrinsic_dimension_estimation/matlab_codes/MiND_KL.m",
"chars": 4875,
"preview": "function [d,kl] = MiND_KL(data,varargin)\n%MiND_KL Intrinsic dimensionality using the MiND_KL technique\n%\n% function [d,"
},
{
"path": "analysis/intrinsic_dimension_estimation/matlab_codes/MiND_ML.m",
"chars": 3346,
"preview": "function d = MiND_ML(data,varargin)\n%MiND_ML Intrinsic dimensionality using the MiND_ML techniques\n%\n% function d = MiN"
},
{
"path": "analysis/intrinsic_dimension_estimation/matlab_codes/demo_idEstimation.m",
"chars": 3266,
"preview": "%% Intrinsic Dimensionality (id) estimation\n%\n% In the past decade the development of automatic techniques to estimate \n"
},
{
"path": "analysis/intrinsic_dimension_estimation/matlab_codes/gauss.m",
"chars": 699,
"preview": "function func = gauss(x, sigma, mu, norm)\n% GAUSS Returns the monodimensional gaussian function\n%\n% Return the evaluat"
},
{
"path": "analysis/intrinsic_dimension_estimation/matlab_codes/html/demo_idEstimation.html",
"chars": 9843,
"preview": "\n<!DOCTYPE html\n PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\">\n<html><head>\n <meta http-equiv=\"Content-Type\" co"
},
{
"path": "analysis/intrinsic_dimension_estimation/matlab_codes/linSubspSpanOrthonormalize.m",
"chars": 2011,
"preview": "function Vo = linSubspSpanOrthonormalize(V)\n% LINSUBSPSPANORTHONORMALIZE Orthonormalizes a linear subspace span matrix."
},
{
"path": "analysis/intrinsic_dimension_estimation/matlab_codes/parseParamsNamed.m",
"chars": 1898,
"preview": "function pars = parseParamsNamed(parsCell,recurse,parsi,multi)\n% PARSEPARAMSNAMED Getting named parameters as a structu"
},
{
"path": "analysis/intrinsic_dimension_estimation/matlab_codes/private/DANCo_estimateKL.m",
"chars": 2268,
"preview": "function kl = DANCo_estimateKL(k,dHat,mu,tau,dHat_ref,mu_ref,tau_ref)\n%DANCO_ESTIMATEKL Estimating the Kullback-Leibler "
},
{
"path": "analysis/intrinsic_dimension_estimation/matlab_codes/private/DANCo_statistics.m",
"chars": 4725,
"preview": "function [isLowDim,dHat,mu,tau] = DANCo_statistics(data,k,params,force)\n%DANCO_STATISTICS Computes the statistics used b"
},
{
"path": "analysis/intrinsic_dimension_estimation/matlab_codes/randsphere.m",
"chars": 849,
"preview": "function X = randsphere(d,N,r)\n% RANDSPHERE Random points uniformly drawn from a spere with radius r\n%\n% function X = r"
},
{
"path": "analysis/intrinsic_dimension_estimation/methods.py",
"chars": 1923,
"preview": "import numpy as np\nimport os\nfrom sklearn.neighbors import NearestNeighbors\n\n\ndef kNN(X, n_neighbors, n_jobs):\n neigh"
},
{
"path": "analysis/latent_regression/__init__.py",
"chars": 25,
"preview": "from .regressors import *"
},
{
"path": "analysis/latent_regression/regressors.py",
"chars": 1371,
"preview": "import numpy as np\nfrom sklearn.preprocessing import StandardScaler\nfrom sklearn.decomposition import PCA\nfrom sklearn.n"
},
{
"path": "configs/air_dancer/latentpred/config1.yaml",
"chars": 256,
"preview": "lr: 0.01\nseed: 1\nif_cuda: True\ngamma: 0.5\nlog_dir: 'logs'\ntrain_batch: 512\nval_batch: 256\ntest_batch: 256\nnum_workers: 8"
},
{
"path": "configs/air_dancer/latentpred/config2.yaml",
"chars": 256,
"preview": "lr: 0.01\nseed: 2\nif_cuda: True\ngamma: 0.5\nlog_dir: 'logs'\ntrain_batch: 512\nval_batch: 256\ntest_batch: 256\nnum_workers: 8"
},
{
"path": "configs/air_dancer/latentpred/config3.yaml",
"chars": 256,
"preview": "lr: 0.02\nseed: 3\nif_cuda: True\ngamma: 0.5\nlog_dir: 'logs'\ntrain_batch: 512\nval_batch: 256\ntest_batch: 256\nnum_workers: 8"
},
{
"path": "configs/air_dancer/model/config1.yaml",
"chars": 255,
"preview": "lr: 0.001\nseed: 1\nif_cuda: True\ngamma: 0.5\nlog_dir: 'logs'\ntrain_batch: 512\nval_batch: 256\ntest_batch: 256\nnum_workers: "
},
{
"path": "configs/air_dancer/model/config2.yaml",
"chars": 255,
"preview": "lr: 0.001\nseed: 2\nif_cuda: True\ngamma: 0.5\nlog_dir: 'logs'\ntrain_batch: 512\nval_batch: 256\ntest_batch: 256\nnum_workers: "
},
{
"path": "configs/air_dancer/model/config3.yaml",
"chars": 255,
"preview": "lr: 0.001\nseed: 3\nif_cuda: True\ngamma: 0.5\nlog_dir: 'logs'\ntrain_batch: 512\nval_batch: 256\ntest_batch: 256\nnum_workers: "
},
{
"path": "configs/air_dancer/model64/config1.yaml",
"chars": 258,
"preview": "lr: 0.001\nseed: 1\nif_cuda: True\ngamma: 0.5\nlog_dir: 'logs'\ntrain_batch: 512\nval_batch: 256\ntest_batch: 256\nnum_workers: "
},
{
"path": "configs/air_dancer/model64/config2.yaml",
"chars": 258,
"preview": "lr: 0.001\nseed: 2\nif_cuda: True\ngamma: 0.5\nlog_dir: 'logs'\ntrain_batch: 512\nval_batch: 256\ntest_batch: 256\nnum_workers: "
},
{
"path": "configs/air_dancer/model64/config3.yaml",
"chars": 258,
"preview": "lr: 0.001\nseed: 3\nif_cuda: True\ngamma: 0.5\nlog_dir: 'logs'\ntrain_batch: 512\nval_batch: 256\ntest_batch: 256\nnum_workers: "
},
{
"path": "configs/air_dancer/refine64/config1.yaml",
"chars": 250,
"preview": "lr: 0.0006\nseed: 1\nif_cuda: True\ngamma: 0.5\nlog_dir: 'logs'\ntrain_batch: 512\nval_batch: 256\ntest_batch: 256\nnum_workers:"
},
{
"path": "configs/air_dancer/refine64/config2.yaml",
"chars": 250,
"preview": "lr: 0.0003\nseed: 2\nif_cuda: True\ngamma: 0.5\nlog_dir: 'logs'\ntrain_batch: 512\nval_batch: 256\ntest_batch: 256\nnum_workers:"
},
{
"path": "configs/air_dancer/refine64/config3.yaml",
"chars": 250,
"preview": "lr: 0.0004\nseed: 3\nif_cuda: True\ngamma: 0.5\nlog_dir: 'logs'\ntrain_batch: 512\nval_batch: 256\ntest_batch: 256\nnum_workers:"
},
{
"path": "configs/circular_motion/model/config1.yaml",
"chars": 260,
"preview": "lr: 0.001\nseed: 1\nif_cuda: True\ngamma: 0.5\nlog_dir: 'logs'\ntrain_batch: 512\nval_batch: 256\ntest_batch: 256\nnum_workers: "
},
{
"path": "configs/circular_motion/model/config2.yaml",
"chars": 260,
"preview": "lr: 0.001\nseed: 2\nif_cuda: True\ngamma: 0.5\nlog_dir: 'logs'\ntrain_batch: 512\nval_batch: 256\ntest_batch: 256\nnum_workers: "
},
{
"path": "configs/circular_motion/model/config3.yaml",
"chars": 260,
"preview": "lr: 0.001\nseed: 3\nif_cuda: True\ngamma: 0.5\nlog_dir: 'logs'\ntrain_batch: 512\nval_batch: 256\ntest_batch: 256\nnum_workers: "
},
{
"path": "configs/circular_motion/model64/config1.yaml",
"chars": 263,
"preview": "lr: 0.001\nseed: 1\nif_cuda: True\ngamma: 0.5\nlog_dir: 'logs'\ntrain_batch: 512\nval_batch: 256\ntest_batch: 256\nnum_workers: "
},
{
"path": "configs/circular_motion/model64/config2.yaml",
"chars": 263,
"preview": "lr: 0.001\nseed: 2\nif_cuda: True\ngamma: 0.5\nlog_dir: 'logs'\ntrain_batch: 512\nval_batch: 256\ntest_batch: 256\nnum_workers: "
},
{
"path": "configs/circular_motion/model64/config3.yaml",
"chars": 263,
"preview": "lr: 0.001\nseed: 3\nif_cuda: True\ngamma: 0.5\nlog_dir: 'logs'\ntrain_batch: 512\nval_batch: 256\ntest_batch: 256\nnum_workers: "
},
{
"path": "configs/circular_motion/refine64/config1.yaml",
"chars": 255,
"preview": "lr: 0.0003\nseed: 1\nif_cuda: True\ngamma: 0.5\nlog_dir: 'logs'\ntrain_batch: 512\nval_batch: 256\ntest_batch: 256\nnum_workers:"
},
{
"path": "configs/circular_motion/refine64/config2.yaml",
"chars": 255,
"preview": "lr: 0.0003\nseed: 2\nif_cuda: True\ngamma: 0.5\nlog_dir: 'logs'\ntrain_batch: 512\nval_batch: 256\ntest_batch: 256\nnum_workers:"
},
{
"path": "configs/circular_motion/refine64/config3.yaml",
"chars": 255,
"preview": "lr: 0.0003\nseed: 3\nif_cuda: True\ngamma: 0.5\nlog_dir: 'logs'\ntrain_batch: 512\nval_batch: 256\ntest_batch: 256\nnum_workers:"
},
{
"path": "configs/double_pendulum/latentpred/config1.yaml",
"chars": 261,
"preview": "lr: 0.03\nseed: 1\nif_cuda: True\ngamma: 0.5\nlog_dir: 'logs'\ntrain_batch: 512\nval_batch: 256\ntest_batch: 256\nnum_workers: 8"
},
{
"path": "configs/double_pendulum/latentpred/config2.yaml",
"chars": 261,
"preview": "lr: 0.03\nseed: 2\nif_cuda: True\ngamma: 0.5\nlog_dir: 'logs'\ntrain_batch: 512\nval_batch: 256\ntest_batch: 256\nnum_workers: 8"
},
{
"path": "configs/double_pendulum/latentpred/config3.yaml",
"chars": 261,
"preview": "lr: 0.03\nseed: 3\nif_cuda: True\ngamma: 0.5\nlog_dir: 'logs'\ntrain_batch: 512\nval_batch: 256\ntest_batch: 256\nnum_workers: 8"
},
{
"path": "configs/double_pendulum/model/config1.yaml",
"chars": 260,
"preview": "lr: 0.001\nseed: 1\nif_cuda: True\ngamma: 0.5\nlog_dir: 'logs'\ntrain_batch: 512\nval_batch: 256\ntest_batch: 256\nnum_workers: "
},
{
"path": "configs/double_pendulum/model/config2.yaml",
"chars": 260,
"preview": "lr: 0.001\nseed: 2\nif_cuda: True\ngamma: 0.5\nlog_dir: 'logs'\ntrain_batch: 512\nval_batch: 256\ntest_batch: 256\nnum_workers: "
},
{
"path": "configs/double_pendulum/model/config3.yaml",
"chars": 260,
"preview": "lr: 0.001\nseed: 3\nif_cuda: True\ngamma: 0.5\nlog_dir: 'logs'\ntrain_batch: 512\nval_batch: 256\ntest_batch: 256\nnum_workers: "
},
{
"path": "configs/double_pendulum/model64/config1.yaml",
"chars": 263,
"preview": "lr: 0.001\nseed: 1\nif_cuda: True\ngamma: 0.5\nlog_dir: 'logs'\ntrain_batch: 512\nval_batch: 256\ntest_batch: 256\nnum_workers: "
},
{
"path": "configs/double_pendulum/model64/config2.yaml",
"chars": 263,
"preview": "lr: 0.001\nseed: 2\nif_cuda: True\ngamma: 0.5\nlog_dir: 'logs'\ntrain_batch: 512\nval_batch: 256\ntest_batch: 256\nnum_workers: "
},
{
"path": "configs/double_pendulum/model64/config3.yaml",
"chars": 263,
"preview": "lr: 0.001\nseed: 3\nif_cuda: True\ngamma: 0.5\nlog_dir: 'logs'\ntrain_batch: 512\nval_batch: 256\ntest_batch: 256\nnum_workers: "
},
{
"path": "configs/double_pendulum/refine64/config1.yaml",
"chars": 255,
"preview": "lr: 0.0003\nseed: 1\nif_cuda: True\ngamma: 0.5\nlog_dir: 'logs'\ntrain_batch: 512\nval_batch: 256\ntest_batch: 256\nnum_workers:"
},
{
"path": "configs/double_pendulum/refine64/config2.yaml",
"chars": 255,
"preview": "lr: 0.0005\nseed: 2\nif_cuda: True\ngamma: 0.5\nlog_dir: 'logs'\ntrain_batch: 512\nval_batch: 256\ntest_batch: 256\nnum_workers:"
},
{
"path": "configs/double_pendulum/refine64/config3.yaml",
"chars": 255,
"preview": "lr: 0.0004\nseed: 3\nif_cuda: True\ngamma: 0.5\nlog_dir: 'logs'\ntrain_batch: 256\nval_batch: 256\ntest_batch: 256\nnum_workers:"
},
{
"path": "configs/elastic_pendulum/latentpred/config1.yaml",
"chars": 262,
"preview": "lr: 0.02\nseed: 1\nif_cuda: True\ngamma: 0.5\nlog_dir: 'logs'\ntrain_batch: 512\nval_batch: 256\ntest_batch: 256\nnum_workers: 8"
},
{
"path": "configs/elastic_pendulum/latentpred/config2.yaml",
"chars": 262,
"preview": "lr: 0.02\nseed: 2\nif_cuda: True\ngamma: 0.5\nlog_dir: 'logs'\ntrain_batch: 512\nval_batch: 256\ntest_batch: 256\nnum_workers: 8"
},
{
"path": "configs/elastic_pendulum/latentpred/config3.yaml",
"chars": 262,
"preview": "lr: 0.01\nseed: 3\nif_cuda: True\ngamma: 0.5\nlog_dir: 'logs'\ntrain_batch: 512\nval_batch: 256\ntest_batch: 256\nnum_workers: 8"
},
{
"path": "configs/elastic_pendulum/model/config1.yaml",
"chars": 261,
"preview": "lr: 0.001\nseed: 1\nif_cuda: True\ngamma: 0.5\nlog_dir: 'logs'\ntrain_batch: 512\nval_batch: 256\ntest_batch: 256\nnum_workers: "
},
{
"path": "configs/elastic_pendulum/model/config2.yaml",
"chars": 261,
"preview": "lr: 0.001\nseed: 2\nif_cuda: True\ngamma: 0.5\nlog_dir: 'logs'\ntrain_batch: 512\nval_batch: 256\ntest_batch: 256\nnum_workers: "
},
{
"path": "configs/elastic_pendulum/model/config3.yaml",
"chars": 261,
"preview": "lr: 0.001\nseed: 3\nif_cuda: True\ngamma: 0.5\nlog_dir: 'logs'\ntrain_batch: 512\nval_batch: 256\ntest_batch: 256\nnum_workers: "
},
{
"path": "configs/elastic_pendulum/model64/config1.yaml",
"chars": 264,
"preview": "lr: 0.001\nseed: 1\nif_cuda: True\ngamma: 0.5\nlog_dir: 'logs'\ntrain_batch: 512\nval_batch: 256\ntest_batch: 256\nnum_workers: "
},
{
"path": "configs/elastic_pendulum/model64/config2.yaml",
"chars": 264,
"preview": "lr: 0.001\nseed: 2\nif_cuda: True\ngamma: 0.5\nlog_dir: 'logs'\ntrain_batch: 512\nval_batch: 256\ntest_batch: 256\nnum_workers: "
},
{
"path": "configs/elastic_pendulum/model64/config3.yaml",
"chars": 264,
"preview": "lr: 0.001\nseed: 3\nif_cuda: True\ngamma: 0.5\nlog_dir: 'logs'\ntrain_batch: 512\nval_batch: 256\ntest_batch: 256\nnum_workers: "
},
{
"path": "configs/elastic_pendulum/refine64/config1.yaml",
"chars": 256,
"preview": "lr: 0.0007\nseed: 1\nif_cuda: True\ngamma: 0.5\nlog_dir: 'logs'\ntrain_batch: 512\nval_batch: 256\ntest_batch: 256\nnum_workers:"
},
{
"path": "configs/elastic_pendulum/refine64/config2.yaml",
"chars": 256,
"preview": "lr: 0.0004\nseed: 2\nif_cuda: True\ngamma: 0.5\nlog_dir: 'logs'\ntrain_batch: 512\nval_batch: 256\ntest_batch: 256\nnum_workers:"
},
{
"path": "configs/elastic_pendulum/refine64/config3.yaml",
"chars": 256,
"preview": "lr: 0.0002\nseed: 3\nif_cuda: True\ngamma: 0.5\nlog_dir: 'logs'\ntrain_batch: 256\nval_batch: 256\ntest_batch: 256\nnum_workers:"
},
{
"path": "configs/fire/latentpred/config1.yaml",
"chars": 251,
"preview": "lr: 0.008\nseed: 1\nif_cuda: True\ngamma: 0.5\nlog_dir: 'logs'\ntrain_batch: 512\nval_batch: 256\ntest_batch: 256\nnum_workers: "
},
{
"path": "configs/fire/latentpred/config2.yaml",
"chars": 250,
"preview": "lr: 0.02\nseed: 2\nif_cuda: True\ngamma: 0.5\nlog_dir: 'logs'\ntrain_batch: 512\nval_batch: 256\ntest_batch: 256\nnum_workers: 8"
},
{
"path": "configs/fire/latentpred/config3.yaml",
"chars": 251,
"preview": "lr: 0.009\nseed: 3\nif_cuda: True\ngamma: 0.5\nlog_dir: 'logs'\ntrain_batch: 512\nval_batch: 256\ntest_batch: 256\nnum_workers: "
},
{
"path": "configs/fire/model/config1.yaml",
"chars": 249,
"preview": "lr: 0.001\nseed: 1\nif_cuda: True\ngamma: 0.5\nlog_dir: 'logs'\ntrain_batch: 512\nval_batch: 256\ntest_batch: 256\nnum_workers: "
},
{
"path": "configs/fire/model/config2.yaml",
"chars": 249,
"preview": "lr: 0.001\nseed: 2\nif_cuda: True\ngamma: 0.5\nlog_dir: 'logs'\ntrain_batch: 512\nval_batch: 256\ntest_batch: 256\nnum_workers: "
},
{
"path": "configs/fire/model/config3.yaml",
"chars": 249,
"preview": "lr: 0.001\nseed: 3\nif_cuda: True\ngamma: 0.5\nlog_dir: 'logs'\ntrain_batch: 512\nval_batch: 256\ntest_batch: 256\nnum_workers: "
},
{
"path": "configs/fire/model64/config1.yaml",
"chars": 252,
"preview": "lr: 0.001\nseed: 1\nif_cuda: True\ngamma: 0.5\nlog_dir: 'logs'\ntrain_batch: 512\nval_batch: 256\ntest_batch: 256\nnum_workers: "
},
{
"path": "configs/fire/model64/config2.yaml",
"chars": 252,
"preview": "lr: 0.001\nseed: 2\nif_cuda: True\ngamma: 0.5\nlog_dir: 'logs'\ntrain_batch: 512\nval_batch: 256\ntest_batch: 256\nnum_workers: "
},
{
"path": "configs/fire/model64/config3.yaml",
"chars": 252,
"preview": "lr: 0.001\nseed: 3\nif_cuda: True\ngamma: 0.5\nlog_dir: 'logs'\ntrain_batch: 512\nval_batch: 256\ntest_batch: 256\nnum_workers: "
},
{
"path": "configs/fire/refine64/config1.yaml",
"chars": 244,
"preview": "lr: 0.0007\nseed: 1\nif_cuda: True\ngamma: 0.5\nlog_dir: 'logs'\ntrain_batch: 512\nval_batch: 256\ntest_batch: 256\nnum_workers:"
},
{
"path": "configs/fire/refine64/config2.yaml",
"chars": 244,
"preview": "lr: 0.0006\nseed: 2\nif_cuda: True\ngamma: 0.5\nlog_dir: 'logs'\ntrain_batch: 512\nval_batch: 256\ntest_batch: 256\nnum_workers:"
},
{
"path": "configs/fire/refine64/config3.yaml",
"chars": 244,
"preview": "lr: 0.0007\nseed: 3\nif_cuda: True\ngamma: 0.5\nlog_dir: 'logs'\ntrain_batch: 512\nval_batch: 256\ntest_batch: 256\nnum_workers:"
},
{
"path": "configs/lava_lamp/latentpred/config1.yaml",
"chars": 256,
"preview": "lr: 0.008\nseed: 1\nif_cuda: True\ngamma: 0.5\nlog_dir: 'logs'\ntrain_batch: 512\nval_batch: 256\ntest_batch: 256\nnum_workers: "
},
{
"path": "configs/lava_lamp/latentpred/config2.yaml",
"chars": 256,
"preview": "lr: 0.009\nseed: 2\nif_cuda: True\ngamma: 0.5\nlog_dir: 'logs'\ntrain_batch: 512\nval_batch: 256\ntest_batch: 256\nnum_workers: "
},
{
"path": "configs/lava_lamp/latentpred/config3.yaml",
"chars": 255,
"preview": "lr: 0.01\nseed: 3\nif_cuda: True\ngamma: 0.5\nlog_dir: 'logs'\ntrain_batch: 512\nval_batch: 256\ntest_batch: 256\nnum_workers: 8"
},
{
"path": "configs/lava_lamp/model/config1.yaml",
"chars": 254,
"preview": "lr: 0.001\nseed: 1\nif_cuda: True\ngamma: 0.5\nlog_dir: 'logs'\ntrain_batch: 512\nval_batch: 256\ntest_batch: 256\nnum_workers: "
},
{
"path": "configs/lava_lamp/model/config2.yaml",
"chars": 254,
"preview": "lr: 0.001\nseed: 2\nif_cuda: True\ngamma: 0.5\nlog_dir: 'logs'\ntrain_batch: 512\nval_batch: 256\ntest_batch: 256\nnum_workers: "
},
{
"path": "configs/lava_lamp/model/config3.yaml",
"chars": 254,
"preview": "lr: 0.001\nseed: 3\nif_cuda: True\ngamma: 0.5\nlog_dir: 'logs'\ntrain_batch: 512\nval_batch: 256\ntest_batch: 256\nnum_workers: "
},
{
"path": "configs/lava_lamp/model64/config1.yaml",
"chars": 257,
"preview": "lr: 0.001\nseed: 1\nif_cuda: True\ngamma: 0.5\nlog_dir: 'logs'\ntrain_batch: 512\nval_batch: 256\ntest_batch: 256\nnum_workers: "
},
{
"path": "configs/lava_lamp/model64/config2.yaml",
"chars": 257,
"preview": "lr: 0.001\nseed: 2\nif_cuda: True\ngamma: 0.5\nlog_dir: 'logs'\ntrain_batch: 512\nval_batch: 256\ntest_batch: 256\nnum_workers: "
},
{
"path": "configs/lava_lamp/model64/config3.yaml",
"chars": 257,
"preview": "lr: 0.001\nseed: 3\nif_cuda: True\ngamma: 0.5\nlog_dir: 'logs'\ntrain_batch: 512\nval_batch: 256\ntest_batch: 256\nnum_workers: "
},
{
"path": "configs/lava_lamp/refine64/config1.yaml",
"chars": 249,
"preview": "lr: 0.0006\nseed: 1\nif_cuda: True\ngamma: 0.5\nlog_dir: 'logs'\ntrain_batch: 512\nval_batch: 256\ntest_batch: 256\nnum_workers:"
},
{
"path": "configs/lava_lamp/refine64/config2.yaml",
"chars": 249,
"preview": "lr: 0.0004\nseed: 2\nif_cuda: True\ngamma: 0.5\nlog_dir: 'logs'\ntrain_batch: 512\nval_batch: 256\ntest_batch: 256\nnum_workers:"
},
{
"path": "configs/lava_lamp/refine64/config3.yaml",
"chars": 249,
"preview": "lr: 0.0005\nseed: 3\nif_cuda: True\ngamma: 0.5\nlog_dir: 'logs'\ntrain_batch: 512\nval_batch: 256\ntest_batch: 256\nnum_workers:"
},
{
"path": "configs/reaction_diffusion/latentpred/config1.yaml",
"chars": 264,
"preview": "lr: 0.01\nseed: 1\nif_cuda: True\ngamma: 0.5\nlog_dir: 'logs'\ntrain_batch: 512\nval_batch: 256\ntest_batch: 256\nnum_workers: 8"
},
{
"path": "configs/reaction_diffusion/latentpred/config2.yaml",
"chars": 264,
"preview": "lr: 0.03\nseed: 2\nif_cuda: True\ngamma: 0.5\nlog_dir: 'logs'\ntrain_batch: 512\nval_batch: 256\ntest_batch: 256\nnum_workers: 8"
},
{
"path": "configs/reaction_diffusion/latentpred/config3.yaml",
"chars": 264,
"preview": "lr: 0.01\nseed: 3\nif_cuda: True\ngamma: 0.5\nlog_dir: 'logs'\ntrain_batch: 512\nval_batch: 256\ntest_batch: 256\nnum_workers: 8"
},
{
"path": "configs/reaction_diffusion/model/config1.yaml",
"chars": 263,
"preview": "lr: 0.001\nseed: 1\nif_cuda: True\ngamma: 0.5\nlog_dir: 'logs'\ntrain_batch: 512\nval_batch: 256\ntest_batch: 256\nnum_workers: "
},
{
"path": "configs/reaction_diffusion/model/config2.yaml",
"chars": 263,
"preview": "lr: 0.001\nseed: 2\nif_cuda: True\ngamma: 0.5\nlog_dir: 'logs'\ntrain_batch: 512\nval_batch: 256\ntest_batch: 256\nnum_workers: "
},
{
"path": "configs/reaction_diffusion/model/config3.yaml",
"chars": 263,
"preview": "lr: 0.001\nseed: 3\nif_cuda: True\ngamma: 0.5\nlog_dir: 'logs'\ntrain_batch: 512\nval_batch: 256\ntest_batch: 256\nnum_workers: "
},
{
"path": "configs/reaction_diffusion/model64/config1.yaml",
"chars": 266,
"preview": "lr: 0.001\nseed: 1\nif_cuda: True\ngamma: 0.5\nlog_dir: 'logs'\ntrain_batch: 512\nval_batch: 256\ntest_batch: 256\nnum_workers: "
},
{
"path": "configs/reaction_diffusion/model64/config2.yaml",
"chars": 266,
"preview": "lr: 0.001\nseed: 2\nif_cuda: True\ngamma: 0.5\nlog_dir: 'logs'\ntrain_batch: 512\nval_batch: 256\ntest_batch: 256\nnum_workers: "
},
{
"path": "configs/reaction_diffusion/model64/config3.yaml",
"chars": 266,
"preview": "lr: 0.001\nseed: 3\nif_cuda: True\ngamma: 0.5\nlog_dir: 'logs'\ntrain_batch: 512\nval_batch: 256\ntest_batch: 256\nnum_workers: "
},
{
"path": "configs/reaction_diffusion/refine64/config1.yaml",
"chars": 258,
"preview": "lr: 0.0004\nseed: 1\nif_cuda: True\ngamma: 0.5\nlog_dir: 'logs'\ntrain_batch: 512\nval_batch: 256\ntest_batch: 256\nnum_workers:"
},
{
"path": "configs/reaction_diffusion/refine64/config2.yaml",
"chars": 258,
"preview": "lr: 0.0003\nseed: 2\nif_cuda: True\ngamma: 0.5\nlog_dir: 'logs'\ntrain_batch: 512\nval_batch: 256\ntest_batch: 256\nnum_workers:"
},
{
"path": "configs/reaction_diffusion/refine64/config3.yaml",
"chars": 258,
"preview": "lr: 0.0003\nseed: 3\nif_cuda: True\ngamma: 0.5\nlog_dir: 'logs'\ntrain_batch: 256\nval_batch: 256\ntest_batch: 256\nnum_workers:"
},
{
"path": "configs/single_pendulum/latentpred/config1.yaml",
"chars": 262,
"preview": "lr: 0.005\nseed: 1\nif_cuda: True\ngamma: 0.5\nlog_dir: 'logs'\ntrain_batch: 512\nval_batch: 256\ntest_batch: 256\nnum_workers: "
},
{
"path": "configs/single_pendulum/latentpred/config2.yaml",
"chars": 261,
"preview": "lr: 0.01\nseed: 2\nif_cuda: True\ngamma: 0.5\nlog_dir: 'logs'\ntrain_batch: 512\nval_batch: 256\ntest_batch: 256\nnum_workers: 8"
},
{
"path": "configs/single_pendulum/latentpred/config3.yaml",
"chars": 261,
"preview": "lr: 0.02\nseed: 3\nif_cuda: True\ngamma: 0.5\nlog_dir: 'logs'\ntrain_batch: 512\nval_batch: 256\ntest_batch: 256\nnum_workers: 8"
},
{
"path": "configs/single_pendulum/model/config1.yaml",
"chars": 260,
"preview": "lr: 0.001\nseed: 1\nif_cuda: True\ngamma: 0.5\nlog_dir: 'logs'\ntrain_batch: 512\nval_batch: 256\ntest_batch: 256\nnum_workers: "
},
{
"path": "configs/single_pendulum/model/config2.yaml",
"chars": 260,
"preview": "lr: 0.001\nseed: 2\nif_cuda: True\ngamma: 0.5\nlog_dir: 'logs'\ntrain_batch: 512\nval_batch: 256\ntest_batch: 256\nnum_workers: "
},
{
"path": "configs/single_pendulum/model/config3.yaml",
"chars": 260,
"preview": "lr: 0.001\nseed: 3\nif_cuda: True\ngamma: 0.5\nlog_dir: 'logs'\ntrain_batch: 512\nval_batch: 256\ntest_batch: 256\nnum_workers: "
},
{
"path": "configs/single_pendulum/model64/config1.yaml",
"chars": 263,
"preview": "lr: 0.001\nseed: 1\nif_cuda: True\ngamma: 0.5\nlog_dir: 'logs'\ntrain_batch: 512\nval_batch: 256\ntest_batch: 256\nnum_workers: "
},
{
"path": "configs/single_pendulum/model64/config2.yaml",
"chars": 263,
"preview": "lr: 0.001\nseed: 2\nif_cuda: True\ngamma: 0.5\nlog_dir: 'logs'\ntrain_batch: 512\nval_batch: 256\ntest_batch: 256\nnum_workers: "
},
{
"path": "configs/single_pendulum/model64/config3.yaml",
"chars": 263,
"preview": "lr: 0.001\nseed: 3\nif_cuda: True\ngamma: 0.5\nlog_dir: 'logs'\ntrain_batch: 512\nval_batch: 256\ntest_batch: 256\nnum_workers: "
},
{
"path": "configs/single_pendulum/refine64/config1.yaml",
"chars": 255,
"preview": "lr: 0.0003\nseed: 1\nif_cuda: True\ngamma: 0.5\nlog_dir: 'logs'\ntrain_batch: 512\nval_batch: 256\ntest_batch: 256\nnum_workers:"
},
{
"path": "configs/single_pendulum/refine64/config2.yaml",
"chars": 255,
"preview": "lr: 0.0003\nseed: 2\nif_cuda: True\ngamma: 0.5\nlog_dir: 'logs'\ntrain_batch: 512\nval_batch: 256\ntest_batch: 256\nnum_workers:"
},
{
"path": "configs/single_pendulum/refine64/config3.yaml",
"chars": 255,
"preview": "lr: 0.0004\nseed: 3\nif_cuda: True\ngamma: 0.5\nlog_dir: 'logs'\ntrain_batch: 512\nval_batch: 256\ntest_batch: 256\nnum_workers:"
},
{
"path": "configs/swingstick_magnetic/model/config1.yaml",
"chars": 264,
"preview": "lr: 0.001\nseed: 1\nif_cuda: True\ngamma: 0.5\nlog_dir: 'logs'\ntrain_batch: 512\nval_batch: 256\ntest_batch: 256\nnum_workers: "
},
{
"path": "configs/swingstick_magnetic/model/config2.yaml",
"chars": 264,
"preview": "lr: 0.001\nseed: 2\nif_cuda: True\ngamma: 0.5\nlog_dir: 'logs'\ntrain_batch: 512\nval_batch: 256\ntest_batch: 256\nnum_workers: "
},
{
"path": "configs/swingstick_magnetic/model/config3.yaml",
"chars": 264,
"preview": "lr: 0.001\nseed: 3\nif_cuda: True\ngamma: 0.5\nlog_dir: 'logs'\ntrain_batch: 512\nval_batch: 256\ntest_batch: 256\nnum_workers: "
},
{
"path": "configs/swingstick_magnetic/model64/config1.yaml",
"chars": 267,
"preview": "lr: 0.001\nseed: 1\nif_cuda: True\ngamma: 0.5\nlog_dir: 'logs'\ntrain_batch: 512\nval_batch: 256\ntest_batch: 256\nnum_workers: "
},
{
"path": "configs/swingstick_magnetic/model64/config2.yaml",
"chars": 267,
"preview": "lr: 0.001\nseed: 2\nif_cuda: True\ngamma: 0.5\nlog_dir: 'logs'\ntrain_batch: 512\nval_batch: 256\ntest_batch: 256\nnum_workers: "
},
{
"path": "configs/swingstick_magnetic/model64/config3.yaml",
"chars": 267,
"preview": "lr: 0.001\nseed: 3\nif_cuda: True\ngamma: 0.5\nlog_dir: 'logs'\ntrain_batch: 512\nval_batch: 256\ntest_batch: 256\nnum_workers: "
},
{
"path": "configs/swingstick_magnetic/refine64/config1.yaml",
"chars": 258,
"preview": "lr: 0.001\nseed: 1\nif_cuda: True\ngamma: 0.5\nlog_dir: 'logs'\ntrain_batch: 512\nval_batch: 256\ntest_batch: 256\nnum_workers: "
},
{
"path": "configs/swingstick_magnetic/refine64/config2.yaml",
"chars": 258,
"preview": "lr: 0.001\nseed: 2\nif_cuda: True\ngamma: 0.5\nlog_dir: 'logs'\ntrain_batch: 512\nval_batch: 256\ntest_batch: 256\nnum_workers: "
},
{
"path": "configs/swingstick_magnetic/refine64/config3.yaml",
"chars": 258,
"preview": "lr: 0.001\nseed: 3\nif_cuda: True\ngamma: 0.5\nlog_dir: 'logs'\ntrain_batch: 512\nval_batch: 256\ntest_batch: 256\nnum_workers: "
},
{
"path": "configs/swingstick_non_magnetic/latentpred/config1.yaml",
"chars": 269,
"preview": "lr: 0.02\nseed: 1\nif_cuda: True\ngamma: 0.5\nlog_dir: 'logs'\ntrain_batch: 512\nval_batch: 256\ntest_batch: 256\nnum_workers: 8"
},
{
"path": "configs/swingstick_non_magnetic/latentpred/config2.yaml",
"chars": 269,
"preview": "lr: 0.03\nseed: 2\nif_cuda: True\ngamma: 0.5\nlog_dir: 'logs'\ntrain_batch: 512\nval_batch: 256\ntest_batch: 256\nnum_workers: 8"
},
{
"path": "configs/swingstick_non_magnetic/latentpred/config3.yaml",
"chars": 269,
"preview": "lr: 0.01\nseed: 3\nif_cuda: True\ngamma: 0.5\nlog_dir: 'logs'\ntrain_batch: 512\nval_batch: 256\ntest_batch: 256\nnum_workers: 8"
},
{
"path": "configs/swingstick_non_magnetic/model/config1.yaml",
"chars": 268,
"preview": "lr: 0.001\nseed: 1\nif_cuda: True\ngamma: 0.5\nlog_dir: 'logs'\ntrain_batch: 512\nval_batch: 256\ntest_batch: 256\nnum_workers: "
},
{
"path": "configs/swingstick_non_magnetic/model/config2.yaml",
"chars": 268,
"preview": "lr: 0.001\nseed: 2\nif_cuda: True\ngamma: 0.5\nlog_dir: 'logs'\ntrain_batch: 512\nval_batch: 256\ntest_batch: 256\nnum_workers: "
},
{
"path": "configs/swingstick_non_magnetic/model/config3.yaml",
"chars": 268,
"preview": "lr: 0.001\nseed: 3\nif_cuda: True\ngamma: 0.5\nlog_dir: 'logs'\ntrain_batch: 512\nval_batch: 256\ntest_batch: 256\nnum_workers: "
},
{
"path": "configs/swingstick_non_magnetic/model64/config1.yaml",
"chars": 271,
"preview": "lr: 0.001\nseed: 1\nif_cuda: True\ngamma: 0.5\nlog_dir: 'logs'\ntrain_batch: 512\nval_batch: 256\ntest_batch: 256\nnum_workers: "
},
{
"path": "configs/swingstick_non_magnetic/model64/config2.yaml",
"chars": 271,
"preview": "lr: 0.001\nseed: 2\nif_cuda: True\ngamma: 0.5\nlog_dir: 'logs'\ntrain_batch: 512\nval_batch: 256\ntest_batch: 256\nnum_workers: "
},
{
"path": "configs/swingstick_non_magnetic/model64/config3.yaml",
"chars": 271,
"preview": "lr: 0.001\nseed: 3\nif_cuda: True\ngamma: 0.5\nlog_dir: 'logs'\ntrain_batch: 512\nval_batch: 256\ntest_batch: 256\nnum_workers: "
},
{
"path": "configs/swingstick_non_magnetic/refine64/config1.yaml",
"chars": 263,
"preview": "lr: 0.0005\nseed: 1\nif_cuda: True\ngamma: 0.5\nlog_dir: 'logs'\ntrain_batch: 512\nval_batch: 256\ntest_batch: 256\nnum_workers:"
},
{
"path": "configs/swingstick_non_magnetic/refine64/config2.yaml",
"chars": 263,
"preview": "lr: 0.0001\nseed: 2\nif_cuda: True\ngamma: 0.5\nlog_dir: 'logs'\ntrain_batch: 512\nval_batch: 256\ntest_batch: 256\nnum_workers:"
},
{
"path": "configs/swingstick_non_magnetic/refine64/config3.yaml",
"chars": 263,
"preview": "lr: 0.0004\nseed: 3\nif_cuda: True\ngamma: 0.5\nlog_dir: 'logs'\ntrain_batch: 512\nval_batch: 256\ntest_batch: 256\nnum_workers:"
},
{
"path": "datainfo/README.md",
"chars": 640,
"preview": "## Data Collection\n\n- single_pendulum, elastic_pendulum, reaction_diffusion, circular_motion: simulation codes to genera"
},
{
"path": "datainfo/air_dancer/data_split_dict_1.json",
"chars": 364,
"preview": "{\n \"test\": [\n 2,\n 18,\n 4\n ],\n \"val\": [\n 15,\n 3,\n 8\n ],\n \"train\""
},
{
"path": "datainfo/air_dancer/data_split_dict_2.json",
"chars": 364,
"preview": "{\n \"test\": [\n 24,\n 2,\n 1\n ],\n \"val\": [\n 9,\n 5,\n 11\n ],\n \"train\""
},
{
"path": "datainfo/air_dancer/data_split_dict_3.json",
"chars": 364,
"preview": "{\n \"test\": [\n 17,\n 18,\n 7\n ],\n \"val\": [\n 19,\n 11,\n 4\n ],\n \"trai"
},
{
"path": "datainfo/circular_motion/data_split_dict_1.json",
"chars": 14338,
"preview": "{\n \"test\": [\n 524,\n 1032,\n 960,\n 907,\n 977,\n 840,\n 877,\n 802,"
},
{
"path": "datainfo/circular_motion/data_split_dict_2.json",
"chars": 14338,
"preview": "{\n \"test\": [\n 24,\n 688,\n 255,\n 176,\n 368,\n 371,\n 58,\n 32,\n "
},
{
"path": "datainfo/circular_motion/data_split_dict_3.json",
"chars": 14338,
"preview": "{\n \"test\": [\n 887,\n 659,\n 395,\n 532,\n 890,\n 471,\n 385,\n 386,\n"
},
{
"path": "datainfo/collect/circular_motion/make_data.py",
"chars": 1479,
"preview": "import numpy as np\nimport os\nfrom tqdm import tqdm\nimport shutil\nfrom PIL import Image, ImageDraw\n\ndef mkdir(folder):\n "
},
{
"path": "datainfo/collect/double_pendulum/README.md",
"chars": 565,
"preview": "## Double Pendulum Data Collection\n\nSuppose the raw videos recording the double pendulum motion are stored in ```./visph"
},
{
"path": "datainfo/collect/double_pendulum/convert_video.py",
"chars": 2239,
"preview": "import cv2\nimport os\nimport shutil\nfrom tqdm import tqdm\nimport argparse\nimport random\nimport time\n\n## This script is fo"
},
{
"path": "datainfo/collect/double_pendulum/equalize_background.py",
"chars": 2853,
"preview": "import cv2\nimport os\nimport shutil\nfrom tqdm import tqdm\nimport argparse\nimport numpy as np\n\n'''\nThis script equalizes b"
},
{
"path": "datainfo/collect/double_pendulum/split_data.py",
"chars": 1531,
"preview": "import os\nimport shutil\nfrom tqdm import tqdm\nimport argparse\n\n'''\nThis script splits each sequence, which corresponds t"
},
{
"path": "datainfo/collect/elastic_pendulum/make_data.py",
"chars": 3857,
"preview": "import os\nimport shutil\nimport numpy as np\nfrom tqdm import tqdm\nfrom PIL import Image, ImageDraw\nfrom scipy import lina"
},
{
"path": "datainfo/collect/fire/split_data.py",
"chars": 2314,
"preview": "import os\nimport shutil\nfrom tqdm import tqdm\nimport argparse\n\n'''\nThis script splits each sequence, which corresponds t"
},
{
"path": "datainfo/collect/lava_lamp/split_data.py",
"chars": 2105,
"preview": "import os\nimport shutil\nfrom tqdm import tqdm\nimport argparse\n\n'''\nThis script splits each sequence, which corresponds t"
},
{
"path": "datainfo/collect/reaction_diffusion/make_data.py",
"chars": 947,
"preview": "import os\nimport shutil\nfrom tqdm import tqdm\nimport numpy as np\nimport scipy.io as sio\nfrom PIL import Image\nfrom matpl"
},
{
"path": "datainfo/collect/reaction_diffusion/reaction_diffusion.m",
"chars": 2262,
"preview": "clear all; close all; clc\n\n% lambda-omega reaction-diffusion system\n% u_t = lam(A) u - ome(A) v + d1*(u_xx + u_yy) = 0\n"
},
{
"path": "datainfo/collect/reaction_diffusion/reaction_diffusion_rhs.m",
"chars": 438,
"preview": "function rhs=reaction_diffusion_rhs(t,uvt,dummy,K22,d1,d2,beta,n,N);\n\n% Calculate u and v terms\nut=reshape((uvt(1:N)),n,"
},
{
"path": "datainfo/collect/single_pendulum/make_data.py",
"chars": 1665,
"preview": "import os\nimport shutil\nimport numpy as np\nfrom tqdm import tqdm\nfrom PIL import Image\nfrom scipy.integrate import solve"
},
{
"path": "datainfo/collect/utils/sort_vids.py",
"chars": 1807,
"preview": "\n\nimport os\nimport shutil\nimport numpy as np\nfrom tqdm import tqdm\n\n\n\ndef mkdir(folder):\n if os.path.exists(folder):\n"
},
{
"path": "datainfo/double_pendulum/data_split_dict_1.json",
"chars": 14338,
"preview": "{\n \"test\": [\n 524,\n 1032,\n 960,\n 907,\n 977,\n 840,\n 877,\n 802,"
},
{
"path": "datainfo/double_pendulum/data_split_dict_2.json",
"chars": 14338,
"preview": "{\n \"test\": [\n 24,\n 688,\n 255,\n 176,\n 368,\n 371,\n 58,\n 32,\n "
},
{
"path": "datainfo/double_pendulum/data_split_dict_3.json",
"chars": 14338,
"preview": "{\n \"test\": [\n 887,\n 659,\n 395,\n 532,\n 890,\n 471,\n 385,\n 386,\n"
},
{
"path": "datainfo/elastic_pendulum/data_split_dict_1.json",
"chars": 15752,
"preview": "{\n \"test\": [\n 187,\n 370,\n 362,\n 470,\n 57,\n 938,\n 678,\n 3,\n "
},
{
"path": "datainfo/elastic_pendulum/data_split_dict_2.json",
"chars": 15752,
"preview": "{\n \"test\": [\n 789,\n 3,\n 1071,\n 376,\n 321,\n 261,\n 523,\n 764,\n "
},
{
"path": "datainfo/elastic_pendulum/data_split_dict_3.json",
"chars": 15752,
"preview": "{\n \"test\": [\n 1194,\n 644,\n 1184,\n 23,\n 694,\n 620,\n 1067,\n 115"
},
{
"path": "datainfo/fire/data_split_dict_1.json",
"chars": 12939,
"preview": "{\n \"test\": [\n 248,\n 491,\n 35,\n 873,\n 603,\n 402,\n 517,\n 866,\n "
},
{
"path": "datainfo/fire/data_split_dict_2.json",
"chars": 12939,
"preview": "{\n \"test\": [\n 465,\n 677,\n 921,\n 956,\n 851,\n 527,\n 512,\n 510,\n"
},
{
"path": "datainfo/fire/data_split_dict_3.json",
"chars": 12939,
"preview": "{\n \"test\": [\n 712,\n 959,\n 987,\n 286,\n 876,\n 29,\n 698,\n 344,\n "
},
{
"path": "datainfo/lava_lamp/data_split_dict_1.json",
"chars": 7310,
"preview": "{\n \"test\": [\n 408,\n 380,\n 248,\n 491,\n 35,\n 402,\n 511,\n 290,\n "
},
{
"path": "datainfo/lava_lamp/data_split_dict_2.json",
"chars": 7310,
"preview": "{\n \"test\": [\n 462,\n 460,\n 465,\n 523,\n 512,\n 510,\n 285,\n 501,\n"
},
{
"path": "datainfo/lava_lamp/data_split_dict_3.json",
"chars": 7310,
"preview": "{\n \"test\": [\n 425,\n 324,\n 216,\n 106,\n 334,\n 167,\n 286,\n 29,\n "
},
{
"path": "datainfo/reaction_diffusion/data_split_dict_1.json",
"chars": 1252,
"preview": "{\n \"test\": [\n 83,\n 60,\n 57,\n 63,\n 15,\n 32,\n 8,\n 97,\n 7"
},
{
"path": "datainfo/reaction_diffusion/data_split_dict_2.json",
"chars": 1252,
"preview": "{\n \"test\": [\n 77,\n 32,\n 39,\n 85,\n 94,\n 21,\n 46,\n 10,\n "
},
{
"path": "datainfo/reaction_diffusion/data_split_dict_3.json",
"chars": 1252,
"preview": "{\n \"test\": [\n 8,\n 74,\n 80,\n 60,\n 77,\n 47,\n 16,\n 69,\n 7"
},
{
"path": "datainfo/single_pendulum/data_split_dict_1.json",
"chars": 15752,
"preview": "{\n \"test\": [\n 187,\n 370,\n 362,\n 470,\n 57,\n 938,\n 678,\n 3,\n "
},
{
"path": "datainfo/single_pendulum/data_split_dict_2.json",
"chars": 15752,
"preview": "{\n \"test\": [\n 789,\n 3,\n 1071,\n 376,\n 321,\n 261,\n 523,\n 764,\n "
},
{
"path": "datainfo/single_pendulum/data_split_dict_3.json",
"chars": 15752,
"preview": "{\n \"test\": [\n 1194,\n 644,\n 1184,\n 23,\n 694,\n 620,\n 1067,\n 115"
},
{
"path": "datainfo/swingstick_magnetic/data_split_dict_1.json",
"chars": 316,
"preview": "{\n \"test\": [\n 2,\n 18,\n 4\n ],\n \"val\": [\n 3,\n 8\n ],\n \"train\": [\n "
},
{
"path": "datainfo/swingstick_magnetic/data_split_dict_2.json",
"chars": 316,
"preview": "{\n \"test\": [\n 20,\n 2,\n 1\n ],\n \"val\": [\n 5,\n 11\n ],\n \"train\": [\n "
},
{
"path": "datainfo/swingstick_magnetic/data_split_dict_3.json",
"chars": 316,
"preview": "{\n \"test\": [\n 17,\n 18,\n 7\n ],\n \"val\": [\n 11,\n 4\n ],\n \"train\": [\n "
},
{
"path": "datainfo/swingstick_non_magnetic/data_split_dict_1.json",
"chars": 1060,
"preview": "{\n \"test\": [\n 48,\n 60,\n 57,\n 63,\n 15,\n 32,\n 8,\n 72,\n 1"
},
{
"path": "datainfo/swingstick_non_magnetic/data_split_dict_2.json",
"chars": 1060,
"preview": "{\n \"test\": [\n 4,\n 27,\n 32,\n 39,\n 21,\n 46,\n 10,\n 11,\n 7"
},
{
"path": "datainfo/swingstick_non_magnetic/data_split_dict_3.json",
"chars": 1060,
"preview": "{\n \"test\": [\n 8,\n 74,\n 60,\n 77,\n 47,\n 16,\n 69,\n 75,\n 3"
},
{
"path": "dataset.py",
"chars": 4619,
"preview": "\nimport os\nimport sys\nimport json\nimport glob\nimport torch\nimport itertools\nimport numpy as np\nfrom PIL import Image\nfro"
},
{
"path": "eval.py",
"chars": 16277,
"preview": "\n\nimport os\nimport sys\nimport glob\nimport yaml\nimport torch\nimport pprint\nimport shutil\nimport numpy as np\nfrom tqdm imp"
},
{
"path": "main.py",
"chars": 4609,
"preview": "\nimport os\nimport sys\nimport yaml\nimport torch\nimport pprint\nfrom munch import munchify\nfrom models import VisDynamicsMo"
},
{
"path": "model_utils.py",
"chars": 19423,
"preview": "\nimport torch\nimport numpy as np\nimport torch.nn as nn\nimport torch.nn.functional as F\n\ndef conv2d_bn_relu(inch,outch,ke"
},
{
"path": "models.py",
"chars": 13939,
"preview": "\nimport os\nimport torch\nimport shutil\nimport numpy as np\nfrom torch import nn\nimport pytorch_lightning as pl\nimport torc"
},
{
"path": "models_latentpred.py",
"chars": 11935,
"preview": "\nimport os\nimport glob\nimport torch\nimport shutil\nimport numpy as np\nfrom torch import nn\nimport pytorch_lightning as pl"
}
]
// ... and 27 more files (download for full content)
About this extraction
This page contains the full source code of the BoyuanChen/neural-state-variables GitHub repository, extracted and formatted as plain text for AI agents and large language models (LLMs). The extraction includes 227 files (570.0 KB), approximately 176.0k tokens, and a symbol index with 220 extracted functions, classes, methods, constants, and types. Use this with OpenClaw, Claude, ChatGPT, Cursor, Windsurf, or any other AI tool that accepts text input. You can copy the full output to your clipboard or download it as a .txt file.
Extracted by GitExtract — free GitHub repo to text converter for AI. Built by Nikandr Surkov.