Skip to content

Tiinnaa/conditional-inn-project

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

15 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Conditional Invertible Neural Network (cINN) Project

This project implements a Conditional Invertible Neural Network (cINN) designed for modeling complex relationships between input features and target outputs. The architecture includes a condition network, coupling subnet constructors, and a main cINN model wrapper.

Project Structure

conditional-inn-project
├── src
│   ├── cINN_cnn.py          # Implementation of the cINN architecture
│   ├── data
│   │   └── dataprep.py      # Data preparation functions
│   ├── models
│   │   └── conditional_inn.py # Definition of the ConditionalINN class
│   ├── train.py             # Training script for the cINN model
│   └── types
│       └── index.py         # Custom types and interfaces
├── requirements.txt          # Project dependencies
└── README.md                 # Project documentation

Setup Instructions

  1. Clone the repository:

    git clone <repository-url>
    cd conditional-inn-project
    
  2. Install the required dependencies:

    pip install -r requirements.txt
    

Usage

To train the cINN model, run the following command:

python src/train.py

Make sure to prepare your dataset and adjust the data loading parameters in src/train.py as needed.

Realistic Conditioning Experiment

The current src/testcinn.py experiment conditions on Ux, Uy, Depth, and Pressure change, then predicts X, Dip, Poisson ratio, Shear Modulus, Biot's coefficient, Offset, Thickness, and Width.

Run from the repository root:

python src/testcinn.py

Outputs are saved into timestamped folders under src/cinn_results/.

For a quick server smoke test before a full run:

CINN_EPOCHS=1 CINN_MAX_ROWS=256 CINN_COVERAGE_K=2 CINN_POSTERIOR_SAMPLES_EVAL=8 CINN_POSTERIOR_SAMPLES_PLOT=32 python src/testcinn.py

Multi-Point Synthetic Dataset

Each scenario retains the approved parameter distributions and stores Ux and Uy in metres at 2,001 common positions from -10 km to +10 km. Depth and Pressure change are stored as known conditioning values; the other seven physical parameters are stored as inversion targets. The analytical solution is included directly in this repository, so no external solver script is called.

Small validation run:

python src/synthetic_data_multipoint.py --n-scenarios 4 --chunk-size 2

When --output-dir is omitted, the run is written to a timestamped directory under src/multipoint_data/. For a named larger server run:

python src/synthetic_data_multipoint.py \
  --n-scenarios 10000 \
  --chunk-size 100 \
  --output-dir /path/to/multipoint_10k

Run it in tmux and keep a terminal log:

tmux new -s multipoint
python src/synthetic_data_multipoint.py \
  --n-scenarios 10000 \
  --chunk-size 100 \
  --output-dir /path/to/multipoint_10k 2>&1 | tee multipoint_10k.log

Detach with Ctrl-b, then d. Reconnect later with:

tmux attach -t multipoint

Multi-Point cINN Training

Train one cINN from every NPZ chunk listed by a completed dataset manifest:

python src/testcinn_multipoint.py \
  --data-dir src/multipoint_data/20260622_153845

The script loads all scenarios into CPU memory, splits by scenario, encodes the full Ux/Uy profiles with a 1D CNN, and conditions the cINN on the profile features plus Depth and Pressure change. Results are written to timestamped directories under src/cinn_results_multipoint/.

Shear modulus uses the synthetic prior support of 0.1-20 GPa and is displayed in GPa in posterior figures. Checkpoints created before this bounded transform must not be reused; retrain from the existing NPZ dataset. Dataset regeneration is not required.

Each run also reports condition-shuffle and posterior-contraction diagnostics. A positive shuffled-minus-correct NLL indicates that the cINN uses its conditioning input. A posterior/prior 68% width ratio below one indicates information gain; values near one indicate little posterior contraction. These quantities are diagnostics, not hard identifiability thresholds.

Dataset distribution figures compare the scenario-level training and validation parameter distributions, summarize Ux/Uy profile envelopes and peak amplitudes, and show the training-split Pearson correlation matrix. Figures are saved as 300 dpi PNG and vector PDF files in the timestamped result directory.

Run a small CPU smoke experiment before starting a full server job:

python src/testcinn_multipoint.py \
  --data-dir src/multipoint_data/20260622_153845 \
  --epochs 1 \
  --max-scenarios 32 \
  --posterior-samples-plot 32 \
  --posterior-samples-eval 8 \
  --coverage-scenarios 2 \
  --num-blocks 2 \
  --device cpu

License

This project is licensed under the MIT License. See the LICENSE file for more details.

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages