indpensim-bench 0.1.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- indpensim_bench-0.1.0/LICENSE +202 -0
- indpensim_bench-0.1.0/MANIFEST.in +4 -0
- indpensim_bench-0.1.0/PKG-INFO +90 -0
- indpensim_bench-0.1.0/PYPI_README.md +54 -0
- indpensim_bench-0.1.0/README.md +309 -0
- indpensim_bench-0.1.0/configs/beta_vae_latent_lp_pi_lstm.yaml +65 -0
- indpensim_bench-0.1.0/configs/beta_vae_liquid_regime_ablation.yaml +70 -0
- indpensim_bench-0.1.0/configs/beta_vae_lp_pi_lstm.yaml +64 -0
- indpensim_bench-0.1.0/configs/beta_vae_lstm.yaml +60 -0
- indpensim_bench-0.1.0/configs/beta_vae_lstm_regime_ablation.yaml +63 -0
- indpensim_bench-0.1.0/configs/beta_vae_mamba.yaml +60 -0
- indpensim_bench-0.1.0/configs/beta_vae_mamba_regime_ablation.yaml +64 -0
- indpensim_bench-0.1.0/configs/beta_vae_pi_lstm.yaml +55 -0
- indpensim_bench-0.1.0/configs/cdae_pi_lstm.yaml +69 -0
- indpensim_bench-0.1.0/configs/cdae_pi_lstm_regime_ablation.yaml +66 -0
- indpensim_bench-0.1.0/configs/cdae_process_pi_lstm.yaml +70 -0
- indpensim_bench-0.1.0/configs/cvae_lstm_vanilla.yaml +61 -0
- indpensim_bench-0.1.0/configs/cvae_pi_lstm.yaml +69 -0
- indpensim_bench-0.1.0/configs/cvae_pi_lstm_seq5.yaml +63 -0
- indpensim_bench-0.1.0/configs/delta_cdae_pi_lstm.yaml +66 -0
- indpensim_bench-0.1.0/configs/neural_ode.yaml +37 -0
- indpensim_bench-0.1.0/configs/pca_pi_lstm.yaml +78 -0
- indpensim_bench-0.1.0/configs/pi_lstm.yaml +46 -0
- indpensim_bench-0.1.0/configs/pls_pi_lstm.yaml +80 -0
- indpensim_bench-0.1.0/configs/pls_pi_lstm_regime_ablation.yaml +67 -0
- indpensim_bench-0.1.0/configs/process_pi_lstm.yaml +65 -0
- indpensim_bench-0.1.0/evaluate.py +468 -0
- indpensim_bench-0.1.0/pyproject.toml +41 -0
- indpensim_bench-0.1.0/python/indpensim_bench/__init__.py +2 -0
- indpensim_bench-0.1.0/python/indpensim_bench/algorithms/__init__.py +79 -0
- indpensim_bench-0.1.0/python/indpensim_bench/algorithms/base.py +427 -0
- indpensim_bench-0.1.0/python/indpensim_bench/algorithms/beta_vae_latent_lp_pi_lstm.py +132 -0
- indpensim_bench-0.1.0/python/indpensim_bench/algorithms/beta_vae_liquid.py +122 -0
- indpensim_bench-0.1.0/python/indpensim_bench/algorithms/beta_vae_lp_pi_lstm.py +111 -0
- indpensim_bench-0.1.0/python/indpensim_bench/algorithms/beta_vae_lstm.py +28 -0
- indpensim_bench-0.1.0/python/indpensim_bench/algorithms/beta_vae_mamba.py +118 -0
- indpensim_bench-0.1.0/python/indpensim_bench/algorithms/beta_vae_pi_lstm.py +29 -0
- indpensim_bench-0.1.0/python/indpensim_bench/algorithms/cdae_pi_lstm.py +458 -0
- indpensim_bench-0.1.0/python/indpensim_bench/algorithms/cdae_process_pi_lstm.py +391 -0
- indpensim_bench-0.1.0/python/indpensim_bench/algorithms/cvae_pi_lstm.py +452 -0
- indpensim_bench-0.1.0/python/indpensim_bench/algorithms/delta_cdae_pi_lstm.py +440 -0
- indpensim_bench-0.1.0/python/indpensim_bench/algorithms/neural_ode.py +279 -0
- indpensim_bench-0.1.0/python/indpensim_bench/algorithms/pca_pi_lstm.py +477 -0
- indpensim_bench-0.1.0/python/indpensim_bench/algorithms/pi_lstm.py +367 -0
- indpensim_bench-0.1.0/python/indpensim_bench/algorithms/pls_pi_lstm.py +482 -0
- indpensim_bench-0.1.0/python/indpensim_bench/algorithms/process_pi_lstm.py +341 -0
- indpensim_bench-0.1.0/python/indpensim_bench/autoencoder/__init__.py +0 -0
- indpensim_bench-0.1.0/python/indpensim_bench/autoencoder/beta_schedule.py +209 -0
- indpensim_bench-0.1.0/python/indpensim_bench/autoencoder/model.py +575 -0
- indpensim_bench-0.1.0/python/indpensim_bench/config.py +93 -0
- indpensim_bench-0.1.0/python/indpensim_bench/configs/__init__.py +1 -0
- indpensim_bench-0.1.0/python/indpensim_bench/configs/beta_vae_latent_lp_pi_lstm.yaml +65 -0
- indpensim_bench-0.1.0/python/indpensim_bench/configs/beta_vae_liquid_regime_ablation.yaml +70 -0
- indpensim_bench-0.1.0/python/indpensim_bench/configs/beta_vae_lp_pi_lstm.yaml +64 -0
- indpensim_bench-0.1.0/python/indpensim_bench/configs/beta_vae_lstm.yaml +60 -0
- indpensim_bench-0.1.0/python/indpensim_bench/configs/beta_vae_lstm_regime_ablation.yaml +63 -0
- indpensim_bench-0.1.0/python/indpensim_bench/configs/beta_vae_mamba.yaml +60 -0
- indpensim_bench-0.1.0/python/indpensim_bench/configs/beta_vae_mamba_regime_ablation.yaml +64 -0
- indpensim_bench-0.1.0/python/indpensim_bench/configs/beta_vae_pi_lstm.yaml +55 -0
- indpensim_bench-0.1.0/python/indpensim_bench/configs/cdae_pi_lstm.yaml +69 -0
- indpensim_bench-0.1.0/python/indpensim_bench/configs/cdae_pi_lstm_regime_ablation.yaml +66 -0
- indpensim_bench-0.1.0/python/indpensim_bench/configs/cdae_process_pi_lstm.yaml +70 -0
- indpensim_bench-0.1.0/python/indpensim_bench/configs/cvae_lstm_vanilla.yaml +61 -0
- indpensim_bench-0.1.0/python/indpensim_bench/configs/cvae_pi_lstm.yaml +69 -0
- indpensim_bench-0.1.0/python/indpensim_bench/configs/cvae_pi_lstm_seq5.yaml +63 -0
- indpensim_bench-0.1.0/python/indpensim_bench/configs/delta_cdae_pi_lstm.yaml +66 -0
- indpensim_bench-0.1.0/python/indpensim_bench/configs/neural_ode.yaml +37 -0
- indpensim_bench-0.1.0/python/indpensim_bench/configs/pca_pi_lstm.yaml +78 -0
- indpensim_bench-0.1.0/python/indpensim_bench/configs/pi_lstm.yaml +46 -0
- indpensim_bench-0.1.0/python/indpensim_bench/configs/pls_pi_lstm.yaml +80 -0
- indpensim_bench-0.1.0/python/indpensim_bench/configs/pls_pi_lstm_regime_ablation.yaml +67 -0
- indpensim_bench-0.1.0/python/indpensim_bench/configs/process_pi_lstm.yaml +65 -0
- indpensim_bench-0.1.0/python/indpensim_bench/data/__init__.py +7 -0
- indpensim_bench-0.1.0/python/indpensim_bench/data/beta_vae_encoder.py +124 -0
- indpensim_bench-0.1.0/python/indpensim_bench/data/cdae_encoder.py +239 -0
- indpensim_bench-0.1.0/python/indpensim_bench/data/cvae_encoder.py +237 -0
- indpensim_bench-0.1.0/python/indpensim_bench/data/dataset.py +279 -0
- indpensim_bench-0.1.0/python/indpensim_bench/data/pca_encoder.py +237 -0
- indpensim_bench-0.1.0/python/indpensim_bench/data/pls_encoder.py +195 -0
- indpensim_bench-0.1.0/python/indpensim_bench/data/rotation_wrapper.py +38 -0
- indpensim_bench-0.1.0/python/indpensim_bench/evaluation/__init__.py +2 -0
- indpensim_bench-0.1.0/python/indpensim_bench/evaluation/metrics.py +82 -0
- indpensim_bench-0.1.0/python/indpensim_bench/latent_norm.py +93 -0
- indpensim_bench-0.1.0/python/indpensim_bench/models/__init__.py +3 -0
- indpensim_bench-0.1.0/python/indpensim_bench/models/beta_vae_latent_lp.py +193 -0
- indpensim_bench-0.1.0/python/indpensim_bench/models/beta_vae_liquid.py +149 -0
- indpensim_bench-0.1.0/python/indpensim_bench/models/beta_vae_mamba.py +163 -0
- indpensim_bench-0.1.0/python/indpensim_bench/models/cdae_pi_lstm.py +199 -0
- indpensim_bench-0.1.0/python/indpensim_bench/models/delta_cdae_pi_lstm.py +169 -0
- indpensim_bench-0.1.0/python/indpensim_bench/models/latent_ode.py +530 -0
- indpensim_bench-0.1.0/python/indpensim_bench/models/neural_cde.py +541 -0
- indpensim_bench-0.1.0/python/indpensim_bench/models/neural_ode.py +124 -0
- indpensim_bench-0.1.0/python/indpensim_bench/models/pi_lstm.py +167 -0
- indpensim_bench-0.1.0/python/indpensim_bench/physics/__init__.py +2 -0
- indpensim_bench-0.1.0/python/indpensim_bench/physics/losses.py +342 -0
- indpensim_bench-0.1.0/python/indpensim_bench/visualization/__init__.py +6 -0
- indpensim_bench-0.1.0/python/indpensim_bench/visualization/plots.py +206 -0
- indpensim_bench-0.1.0/python/indpensim_bench.egg-info/PKG-INFO +90 -0
- indpensim_bench-0.1.0/python/indpensim_bench.egg-info/SOURCES.txt +192 -0
- indpensim_bench-0.1.0/python/indpensim_bench.egg-info/dependency_links.txt +1 -0
- indpensim_bench-0.1.0/python/indpensim_bench.egg-info/requires.txt +25 -0
- indpensim_bench-0.1.0/python/indpensim_bench.egg-info/top_level.txt +1 -0
- indpensim_bench-0.1.0/requirements.txt +176 -0
- indpensim_bench-0.1.0/run_seeds.py +1545 -0
- indpensim_bench-0.1.0/scripts/analyze_latent_norm.py +59 -0
- indpensim_bench-0.1.0/scripts/analyze_rotation.py +85 -0
- indpensim_bench-0.1.0/scripts/baseline_temporal_poly.py +356 -0
- indpensim_bench-0.1.0/scripts/benchmark_summary.py +492 -0
- indpensim_bench-0.1.0/scripts/beta_sweep.py +214 -0
- indpensim_bench-0.1.0/scripts/beta_sweep_e2e.py +1327 -0
- indpensim_bench-0.1.0/scripts/beta_sweep_eval_extended.py +502 -0
- indpensim_bench-0.1.0/scripts/beta_sweep_viz.py +84 -0
- indpensim_bench-0.1.0/scripts/compute_pr_k95_sweep.py +175 -0
- indpensim_bench-0.1.0/scripts/compute_sap.py +205 -0
- indpensim_bench-0.1.0/scripts/cvae_jit_ft.py +1359 -0
- indpensim_bench-0.1.0/scripts/eval_bvae_z52.py +454 -0
- indpensim_bench-0.1.0/scripts/evaluate_dci.py +701 -0
- indpensim_bench-0.1.0/scripts/evaluate_mig.py +597 -0
- indpensim_bench-0.1.0/scripts/latent_correlation.py +640 -0
- indpensim_bench-0.1.0/scripts/latent_geometry.py +285 -0
- indpensim_bench-0.1.0/scripts/latent_interpolation.py +594 -0
- indpensim_bench-0.1.0/scripts/latent_smoothness.py +507 -0
- indpensim_bench-0.1.0/scripts/latent_stress_test.py +888 -0
- indpensim_bench-0.1.0/scripts/latent_trajectory.py +350 -0
- indpensim_bench-0.1.0/scripts/latent_umap.py +555 -0
- indpensim_bench-0.1.0/scripts/multi_seed_train.py +511 -0
- indpensim_bench-0.1.0/scripts/pca_baseline.py +826 -0
- indpensim_bench-0.1.0/scripts/plot_bvae_lstm_fault.py +265 -0
- indpensim_bench-0.1.0/scripts/plot_pr_scaled.py +38 -0
- indpensim_bench-0.1.0/scripts/pls_baseline.py +762 -0
- indpensim_bench-0.1.0/scripts/pls_pca_baseline_k64.py +459 -0
- indpensim_bench-0.1.0/scripts/protocol2_eval.py +711 -0
- indpensim_bench-0.1.0/scripts/run_all_seeds.py +565 -0
- indpensim_bench-0.1.0/scripts/run_latent_norm.py +74 -0
- indpensim_bench-0.1.0/scripts/shap_ablation.py +712 -0
- indpensim_bench-0.1.0/scripts/shap_analysis.py +1088 -0
- indpensim_bench-0.1.0/scripts/shap_temporal_profile.py +346 -0
- indpensim_bench-0.1.0/scripts/svr_baseline.py +814 -0
- indpensim_bench-0.1.0/scripts/train_autoencoder.py +871 -0
- indpensim_bench-0.1.0/scripts/train_bvae_mlp.py +582 -0
- indpensim_bench-0.1.0/scripts/train_capacity_vae_lstm.py +671 -0
- indpensim_bench-0.1.0/scripts/train_latent_ode.py +855 -0
- indpensim_bench-0.1.0/scripts/train_neural_cde.py +915 -0
- indpensim_bench-0.1.0/scripts/train_sindyc.py +1031 -0
- indpensim_bench-0.1.0/scripts/vae_jitl.py +951 -0
- indpensim_bench-0.1.0/setup.cfg +4 -0
- indpensim_bench-0.1.0/src/__init__.py +1 -0
- indpensim_bench-0.1.0/src/algorithms/__init__.py +79 -0
- indpensim_bench-0.1.0/src/algorithms/base.py +427 -0
- indpensim_bench-0.1.0/src/algorithms/beta_vae_latent_lp_pi_lstm.py +132 -0
- indpensim_bench-0.1.0/src/algorithms/beta_vae_liquid.py +122 -0
- indpensim_bench-0.1.0/src/algorithms/beta_vae_lp_pi_lstm.py +111 -0
- indpensim_bench-0.1.0/src/algorithms/beta_vae_lstm.py +28 -0
- indpensim_bench-0.1.0/src/algorithms/beta_vae_mamba.py +118 -0
- indpensim_bench-0.1.0/src/algorithms/beta_vae_pi_lstm.py +29 -0
- indpensim_bench-0.1.0/src/algorithms/cdae_pi_lstm.py +458 -0
- indpensim_bench-0.1.0/src/algorithms/cdae_process_pi_lstm.py +391 -0
- indpensim_bench-0.1.0/src/algorithms/cvae_pi_lstm.py +452 -0
- indpensim_bench-0.1.0/src/algorithms/delta_cdae_pi_lstm.py +440 -0
- indpensim_bench-0.1.0/src/algorithms/neural_ode.py +279 -0
- indpensim_bench-0.1.0/src/algorithms/pca_pi_lstm.py +477 -0
- indpensim_bench-0.1.0/src/algorithms/pi_lstm.py +367 -0
- indpensim_bench-0.1.0/src/algorithms/pls_pi_lstm.py +482 -0
- indpensim_bench-0.1.0/src/algorithms/process_pi_lstm.py +341 -0
- indpensim_bench-0.1.0/src/autoencoder/__init__.py +0 -0
- indpensim_bench-0.1.0/src/autoencoder/beta_schedule.py +209 -0
- indpensim_bench-0.1.0/src/autoencoder/model.py +575 -0
- indpensim_bench-0.1.0/src/config.py +93 -0
- indpensim_bench-0.1.0/src/data/__init__.py +7 -0
- indpensim_bench-0.1.0/src/data/beta_vae_encoder.py +127 -0
- indpensim_bench-0.1.0/src/data/cdae_encoder.py +242 -0
- indpensim_bench-0.1.0/src/data/cvae_encoder.py +240 -0
- indpensim_bench-0.1.0/src/data/dataset.py +279 -0
- indpensim_bench-0.1.0/src/data/pca_encoder.py +240 -0
- indpensim_bench-0.1.0/src/data/pls_encoder.py +198 -0
- indpensim_bench-0.1.0/src/data/rotation_wrapper.py +38 -0
- indpensim_bench-0.1.0/src/evaluation/__init__.py +2 -0
- indpensim_bench-0.1.0/src/evaluation/metrics.py +82 -0
- indpensim_bench-0.1.0/src/latent_norm.py +93 -0
- indpensim_bench-0.1.0/src/models/__init__.py +3 -0
- indpensim_bench-0.1.0/src/models/beta_vae_latent_lp.py +193 -0
- indpensim_bench-0.1.0/src/models/beta_vae_liquid.py +149 -0
- indpensim_bench-0.1.0/src/models/beta_vae_mamba.py +163 -0
- indpensim_bench-0.1.0/src/models/cdae_pi_lstm.py +199 -0
- indpensim_bench-0.1.0/src/models/delta_cdae_pi_lstm.py +169 -0
- indpensim_bench-0.1.0/src/models/latent_ode.py +530 -0
- indpensim_bench-0.1.0/src/models/neural_cde.py +541 -0
- indpensim_bench-0.1.0/src/models/neural_ode.py +124 -0
- indpensim_bench-0.1.0/src/models/pi_lstm.py +167 -0
- indpensim_bench-0.1.0/src/physics/__init__.py +2 -0
- indpensim_bench-0.1.0/src/physics/losses.py +342 -0
- indpensim_bench-0.1.0/src/visualization/__init__.py +6 -0
- indpensim_bench-0.1.0/src/visualization/plots.py +206 -0
- indpensim_bench-0.1.0/train.py +635 -0
|
@@ -0,0 +1,202 @@
|
|
|
1
|
+
|
|
2
|
+
Apache License
|
|
3
|
+
Version 2.0, January 2004
|
|
4
|
+
http://www.apache.org/licenses/
|
|
5
|
+
|
|
6
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
7
|
+
|
|
8
|
+
1. Definitions.
|
|
9
|
+
|
|
10
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
11
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
12
|
+
|
|
13
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
14
|
+
the copyright owner that is granting the License.
|
|
15
|
+
|
|
16
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
17
|
+
other entities that control, are controlled by, or are under common
|
|
18
|
+
control with that entity. For the purposes of this definition,
|
|
19
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
20
|
+
direction or management of such entity, whether by contract or
|
|
21
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
22
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
23
|
+
|
|
24
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
25
|
+
exercising permissions granted by this License.
|
|
26
|
+
|
|
27
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
28
|
+
including but not limited to software source code, documentation
|
|
29
|
+
source, and configuration files.
|
|
30
|
+
|
|
31
|
+
"Object" form shall mean any form resulting from mechanical
|
|
32
|
+
transformation or translation of a Source form, including but
|
|
33
|
+
not limited to compiled object code, generated documentation,
|
|
34
|
+
and conversions to other media types.
|
|
35
|
+
|
|
36
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
37
|
+
Object form, made available under the License, as indicated by a
|
|
38
|
+
copyright notice that is included in or attached to the work
|
|
39
|
+
(an example is provided in the Appendix below).
|
|
40
|
+
|
|
41
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
42
|
+
form, that is based on (or derived from) the Work and for which the
|
|
43
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
44
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
45
|
+
of this License, Derivative Works shall not include works that remain
|
|
46
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
47
|
+
the Work and Derivative Works thereof.
|
|
48
|
+
|
|
49
|
+
"Contribution" shall mean any work of authorship, including
|
|
50
|
+
the original version of the Work and any modifications or additions
|
|
51
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
52
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
53
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
54
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
55
|
+
means any form of electronic, verbal, or written communication sent
|
|
56
|
+
to the Licensor or its representatives, including but not limited to
|
|
57
|
+
communication on electronic mailing lists, source code control systems,
|
|
58
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
59
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
60
|
+
excluding communication that is conspicuously marked or otherwise
|
|
61
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
62
|
+
|
|
63
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
64
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
65
|
+
subsequently incorporated within the Work.
|
|
66
|
+
|
|
67
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
68
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
69
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
70
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
71
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
72
|
+
Work and such Derivative Works in Source or Object form.
|
|
73
|
+
|
|
74
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
75
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
76
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
77
|
+
(except as stated in this section) patent license to make, have made,
|
|
78
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
79
|
+
where such license applies only to those patent claims licensable
|
|
80
|
+
by such Contributor that are necessarily infringed by their
|
|
81
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
82
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
83
|
+
institute patent litigation against any entity (including a
|
|
84
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
85
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
86
|
+
or contributory patent infringement, then any patent licenses
|
|
87
|
+
granted to You under this License for that Work shall terminate
|
|
88
|
+
as of the date such litigation is filed.
|
|
89
|
+
|
|
90
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
91
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
92
|
+
modifications, and in Source or Object form, provided that You
|
|
93
|
+
meet the following conditions:
|
|
94
|
+
|
|
95
|
+
(a) You must give any other recipients of the Work or
|
|
96
|
+
Derivative Works a copy of this License; and
|
|
97
|
+
|
|
98
|
+
(b) You must cause any modified files to carry prominent notices
|
|
99
|
+
stating that You changed the files; and
|
|
100
|
+
|
|
101
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
102
|
+
that You distribute, all copyright, patent, trademark, and
|
|
103
|
+
attribution notices from the Source form of the Work,
|
|
104
|
+
excluding those notices that do not pertain to any part of
|
|
105
|
+
the Derivative Works; and
|
|
106
|
+
|
|
107
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
108
|
+
distribution, then any Derivative Works that You distribute must
|
|
109
|
+
include a readable copy of the attribution notices contained
|
|
110
|
+
within such NOTICE file, excluding those notices that do not
|
|
111
|
+
pertain to any part of the Derivative Works, in at least one
|
|
112
|
+
of the following places: within a NOTICE text file distributed
|
|
113
|
+
as part of the Derivative Works; within the Source form or
|
|
114
|
+
documentation, if provided along with the Derivative Works; or,
|
|
115
|
+
within a display generated by the Derivative Works, if and
|
|
116
|
+
wherever such third-party notices normally appear. The contents
|
|
117
|
+
of the NOTICE file are for informational purposes only and
|
|
118
|
+
do not modify the License. You may add Your own attribution
|
|
119
|
+
notices within Derivative Works that You distribute, alongside
|
|
120
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
121
|
+
that such additional attribution notices cannot be construed
|
|
122
|
+
as modifying the License.
|
|
123
|
+
|
|
124
|
+
You may add Your own copyright statement to Your modifications and
|
|
125
|
+
may provide additional or different license terms and conditions
|
|
126
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
127
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
128
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
129
|
+
the conditions stated in this License.
|
|
130
|
+
|
|
131
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
132
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
133
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
134
|
+
this License, without any additional terms or conditions.
|
|
135
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
136
|
+
the terms of any separate license agreement you may have executed
|
|
137
|
+
with Licensor regarding such Contributions.
|
|
138
|
+
|
|
139
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
140
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
141
|
+
except as required for reasonable and customary use in describing the
|
|
142
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
143
|
+
|
|
144
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
145
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
146
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
147
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
148
|
+
implied, including, without limitation, any warranties or conditions
|
|
149
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
150
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
151
|
+
appropriateness of using or redistributing the Work and assume any
|
|
152
|
+
risks associated with Your exercise of permissions under this License.
|
|
153
|
+
|
|
154
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
155
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
156
|
+
unless required by applicable law (such as deliberate and grossly
|
|
157
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
158
|
+
liable to You for damages, including any direct, indirect, special,
|
|
159
|
+
incidental, or consequential damages of any character arising as a
|
|
160
|
+
result of this License or out of the use or inability to use the
|
|
161
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
162
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
163
|
+
other commercial damages or losses), even if such Contributor
|
|
164
|
+
has been advised of the possibility of such damages.
|
|
165
|
+
|
|
166
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
167
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
168
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
169
|
+
or other liability obligations and/or rights consistent with this
|
|
170
|
+
License. However, in accepting such obligations, You may act only
|
|
171
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
172
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
173
|
+
defend, and hold each Contributor harmless for any liability
|
|
174
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
175
|
+
of your accepting any such warranty or additional liability.
|
|
176
|
+
|
|
177
|
+
END OF TERMS AND CONDITIONS
|
|
178
|
+
|
|
179
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
180
|
+
|
|
181
|
+
To apply the Apache License to your work, attach the following
|
|
182
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
183
|
+
replaced with your own identifying information. (Don't include
|
|
184
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
185
|
+
comment syntax for the file format. We also recommend that a
|
|
186
|
+
file or class name and description of purpose be included on the
|
|
187
|
+
same "printed page" as the copyright notice for easier
|
|
188
|
+
identification within third-party archives.
|
|
189
|
+
|
|
190
|
+
Copyright [yyyy] [name of copyright owner]
|
|
191
|
+
|
|
192
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
193
|
+
you may not use this file except in compliance with the License.
|
|
194
|
+
You may obtain a copy of the License at
|
|
195
|
+
|
|
196
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
197
|
+
|
|
198
|
+
Unless required by applicable law or agreed to in writing, software
|
|
199
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
200
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
201
|
+
See the License for the specific language governing permissions and
|
|
202
|
+
limitations under the License.
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: indpensim_bench
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: Raman latent compression and out-of-distribution penicillin soft-sensor models
|
|
5
|
+
License-Expression: Apache-2.0
|
|
6
|
+
Project-URL: Repository, https://github.com/Gab404/Latent_Compression_OOD_Soft_Sensor
|
|
7
|
+
Project-URL: Issues, https://github.com/Gab404/Latent_Compression_OOD_Soft_Sensor/issues
|
|
8
|
+
Classifier: Development Status :: 3 - Alpha
|
|
9
|
+
Classifier: Programming Language :: Python :: 3
|
|
10
|
+
Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
|
|
11
|
+
Requires-Python: >=3.10
|
|
12
|
+
Description-Content-Type: text/markdown
|
|
13
|
+
License-File: LICENSE
|
|
14
|
+
Requires-Dist: numpy>=1.24
|
|
15
|
+
Requires-Dist: pandas>=2.0
|
|
16
|
+
Requires-Dist: scipy>=1.10
|
|
17
|
+
Requires-Dist: scikit-learn>=1.3
|
|
18
|
+
Requires-Dist: torch>=2.4
|
|
19
|
+
Requires-Dist: torchdiffeq>=0.2.5
|
|
20
|
+
Requires-Dist: PyYAML>=6
|
|
21
|
+
Requires-Dist: joblib>=1.3
|
|
22
|
+
Requires-Dist: matplotlib>=3.7
|
|
23
|
+
Requires-Dist: tqdm>=4.65
|
|
24
|
+
Provides-Extra: liquid
|
|
25
|
+
Requires-Dist: ncps>=1.0.1; extra == "liquid"
|
|
26
|
+
Provides-Extra: mamba
|
|
27
|
+
Requires-Dist: mamba-ssm>=2.2; extra == "mamba"
|
|
28
|
+
Requires-Dist: causal-conv1d>=1.5; extra == "mamba"
|
|
29
|
+
Provides-Extra: cde
|
|
30
|
+
Requires-Dist: torchcde>=0.2.5; extra == "cde"
|
|
31
|
+
Provides-Extra: analysis
|
|
32
|
+
Requires-Dist: shap>=0.45; extra == "analysis"
|
|
33
|
+
Requires-Dist: seaborn>=0.13; extra == "analysis"
|
|
34
|
+
Requires-Dist: pysindy>=2; extra == "analysis"
|
|
35
|
+
Dynamic: license-file
|
|
36
|
+
|
|
37
|
+
# Latent Compression OOD Soft Sensor
|
|
38
|
+
|
|
39
|
+
Research models for predicting penicillin and biomass from Raman spectra on
|
|
40
|
+
IndPenSim V3: frozen CDAE/CVAE/beta-VAE/PCA/PLS encoders and physics-informed
|
|
41
|
+
LSTM models, with neural ODE and optional Mamba and liquid variants.
|
|
42
|
+
|
|
43
|
+
## Install
|
|
44
|
+
|
|
45
|
+
```bash
|
|
46
|
+
pip install indpensim_bench
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
Python 3.10 or later is required. Install the PyTorch build appropriate for your
|
|
50
|
+
hardware if you need a specific CUDA runtime. Optional variants:
|
|
51
|
+
|
|
52
|
+
```bash
|
|
53
|
+
pip install "indpensim_bench[liquid]"
|
|
54
|
+
pip install "indpensim_bench[cde]"
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
The `mamba` extra requires a compatible CUDA/Linux build environment.
|
|
58
|
+
|
|
59
|
+
## Library usage
|
|
60
|
+
|
|
61
|
+
```python
|
|
62
|
+
from indpensim_bench.config import Config
|
|
63
|
+
from indpensim_bench.algorithms import get_algorithm
|
|
64
|
+
from importlib.resources import files
|
|
65
|
+
|
|
66
|
+
config_path = files("indpensim_bench").joinpath(
|
|
67
|
+
"configs/beta_vae_pi_lstm.yaml"
|
|
68
|
+
)
|
|
69
|
+
cfg = Config.from_yaml(config_path)
|
|
70
|
+
algorithm_class = get_algorithm("beta_vae_pi_lstm")
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
Configuration paths for datasets and checkpoints must be adapted to your local
|
|
74
|
+
files. The dataset, trained checkpoints and fitted scalers are not included.
|
|
75
|
+
Obtain IndPenSim V3 separately from
|
|
76
|
+
[the dataset provider](http://www.industrialpenicillinsimulation.com/).
|
|
77
|
+
|
|
78
|
+
## Reproduce the benchmark
|
|
79
|
+
|
|
80
|
+
The wheel provides the Python library. The source distribution also includes
|
|
81
|
+
the original `src/`, `train.py`, `evaluate.py`, `run_seeds.py`, `scripts/`,
|
|
82
|
+
configuration files and the full benchmark README. Extract the source archive
|
|
83
|
+
and run these workflows from its root using the original README instructions.
|
|
84
|
+
The original requirements file records the research environment; installing
|
|
85
|
+
the library uses the smaller dependency list in `pyproject.toml`.
|
|
86
|
+
|
|
87
|
+
Existing checkpoints serialized with imports under `src` should be loaded from
|
|
88
|
+
the original research source tree; automatic checkpoint migration is not provided.
|
|
89
|
+
|
|
90
|
+
[Source repository and full documentation](https://github.com/Gab404/Latent_Compression_OOD_Soft_Sensor)
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
# Latent Compression OOD Soft Sensor
|
|
2
|
+
|
|
3
|
+
Research models for predicting penicillin and biomass from Raman spectra on
|
|
4
|
+
IndPenSim V3: frozen CDAE/CVAE/beta-VAE/PCA/PLS encoders and physics-informed
|
|
5
|
+
LSTM models, with neural ODE and optional Mamba and liquid variants.
|
|
6
|
+
|
|
7
|
+
## Install
|
|
8
|
+
|
|
9
|
+
```bash
|
|
10
|
+
pip install indpensim_bench
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
Python 3.10 or later is required. Install the PyTorch build appropriate for your
|
|
14
|
+
hardware if you need a specific CUDA runtime. Optional variants:
|
|
15
|
+
|
|
16
|
+
```bash
|
|
17
|
+
pip install "indpensim_bench[liquid]"
|
|
18
|
+
pip install "indpensim_bench[cde]"
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
The `mamba` extra requires a compatible CUDA/Linux build environment.
|
|
22
|
+
|
|
23
|
+
## Library usage
|
|
24
|
+
|
|
25
|
+
```python
|
|
26
|
+
from indpensim_bench.config import Config
|
|
27
|
+
from indpensim_bench.algorithms import get_algorithm
|
|
28
|
+
from importlib.resources import files
|
|
29
|
+
|
|
30
|
+
config_path = files("indpensim_bench").joinpath(
|
|
31
|
+
"configs/beta_vae_pi_lstm.yaml"
|
|
32
|
+
)
|
|
33
|
+
cfg = Config.from_yaml(config_path)
|
|
34
|
+
algorithm_class = get_algorithm("beta_vae_pi_lstm")
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
Configuration paths for datasets and checkpoints must be adapted to your local
|
|
38
|
+
files. The dataset, trained checkpoints and fitted scalers are not included.
|
|
39
|
+
Obtain IndPenSim V3 separately from
|
|
40
|
+
[the dataset provider](http://www.industrialpenicillinsimulation.com/).
|
|
41
|
+
|
|
42
|
+
## Reproduce the benchmark
|
|
43
|
+
|
|
44
|
+
The wheel provides the Python library. The source distribution also includes
|
|
45
|
+
the original `src/`, `train.py`, `evaluate.py`, `run_seeds.py`, `scripts/`,
|
|
46
|
+
configuration files and the full benchmark README. Extract the source archive
|
|
47
|
+
and run these workflows from its root using the original README instructions.
|
|
48
|
+
The original requirements file records the research environment; installing
|
|
49
|
+
the library uses the smaller dependency list in `pyproject.toml`.
|
|
50
|
+
|
|
51
|
+
Existing checkpoints serialized with imports under `src` should be loaded from
|
|
52
|
+
the original research source tree; automatic checkpoint migration is not provided.
|
|
53
|
+
|
|
54
|
+
[Source repository and full documentation](https://github.com/Gab404/Latent_Compression_OOD_Soft_Sensor)
|
|
@@ -0,0 +1,309 @@
|
|
|
1
|
+
# ReaKt-v2 — Penicillin Soft-Sensor Benchmark
|
|
2
|
+
|
|
3
|
+
Benchmark comparing model architectures as soft-sensors for online penicillin prediction
|
|
4
|
+
from Raman spectra on **IndPenSim V3** (100 batches, 2,001 Raman channels).
|
|
5
|
+
|
|
6
|
+
Core pipeline: **frozen Raman encoder** (CDAE / CVAE / β-VAE / PCA / PLS → latent z)
|
|
7
|
+
→ **PI-LSTM** (z sequence → Penicillin g/L, physics-informed loss).
|
|
8
|
+
|
|
9
|
+
---
|
|
10
|
+
|
|
11
|
+
## Setup
|
|
12
|
+
|
|
13
|
+
```bash
|
|
14
|
+
python3.10 -m venv .venv && source .venv/bin/activate
|
|
15
|
+
pip install -r requirements.txt
|
|
16
|
+
```
|
|
17
|
+
|
|
18
|
+
Place `100_Batches_IndPenSim_V3.csv` in the project root (not tracked — download from
|
|
19
|
+
[industrialpenicillinsimulation.com](http://www.industrialpenicillinsimulation.com/)).
|
|
20
|
+
|
|
21
|
+
Scripts under `scripts/` need the project root on `PYTHONPATH`:
|
|
22
|
+
```bash
|
|
23
|
+
PYTHONPATH=. python scripts/<script>.py
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
---
|
|
27
|
+
|
|
28
|
+
## Quick Reference
|
|
29
|
+
|
|
30
|
+
| Goal | Command |
|
|
31
|
+
|---|---|
|
|
32
|
+
| Train one model | `python train.py --model beta_vae_pi_lstm` |
|
|
33
|
+
| Evaluate a checkpoint | `python evaluate.py --model beta_vae_pi_lstm` |
|
|
34
|
+
| Multi-seed benchmark (5 seeds, both protocols) | `python run_seeds.py --model beta_vae_pi_lstm` |
|
|
35
|
+
| Train a Raman encoder from scratch | `PYTHONPATH=. python scripts/train_autoencoder.py --model beta_vae` |
|
|
36
|
+
| β sweep (encoder + LSTM per β) | `PYTHONPATH=. python scripts/beta_sweep_e2e.py` |
|
|
37
|
+
| Static baselines (PLS, PCA-PCR) | `PYTHONPATH=. python scripts/pls_pca_baseline_k64.py` |
|
|
38
|
+
| JIT fine-tuning adaptation | `PYTHONPATH=. python scripts/cvae_jit_ft.py --model beta_vae` |
|
|
39
|
+
| Local-PLS adaptation (VAE-JITL) | `PYTHONPATH=. python scripts/vae_jitl.py` |
|
|
40
|
+
|
|
41
|
+
---
|
|
42
|
+
|
|
43
|
+
## 1. Single Training Run — `train.py`
|
|
44
|
+
|
|
45
|
+
```bash
|
|
46
|
+
python train.py --model beta_vae_pi_lstm # seed=42, configs/<model>.yaml
|
|
47
|
+
python train.py --model beta_vae_pi_lstm --seed 123 # checkpoint auto-renamed *_s123.pt
|
|
48
|
+
python train.py --model cdae_pi_lstm --epochs 50 --device cpu
|
|
49
|
+
python train.py --model beta_vae_pi_lstm --regime-ablation # train R1, test R2
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
| Flag | Description |
|
|
53
|
+
|---|---|
|
|
54
|
+
| `--model NAME` | Required. See [Models](#models) for the full list. |
|
|
55
|
+
| `--seed N` | Overrides seed; renames checkpoint to `*_s{N}.pt`. |
|
|
56
|
+
| `--epochs N` | Overrides `n_epochs` from the YAML config. |
|
|
57
|
+
| `--ckpt PATH` / `--config PATH` | Override output checkpoint / input config. |
|
|
58
|
+
| `--device cpu/cuda` | Force device (default: auto-detect). |
|
|
59
|
+
| `--regime-ablation` | Train on R1 (batches 1–30), test on R2 (31–60). |
|
|
60
|
+
| `--no-early-stopping` | Run all epochs, ignore early-stopping patience. |
|
|
61
|
+
| `--no-plots` | Skip saving prediction/history plots. |
|
|
62
|
+
| `--raman-ckpt` / `--raman-scaler` | Point to a specific (e.g. per-seed) frozen encoder instead of the config default. |
|
|
63
|
+
|
|
64
|
+
What it does: loads `configs/<model>.yaml` → sets seeds → loads CSV & splits batches →
|
|
65
|
+
encodes Raman spectra (if applicable) → builds per-batch sliding windows → trains with
|
|
66
|
+
early stopping + annealed physics loss → evaluates on val/test → saves checkpoint
|
|
67
|
+
(weights + embedded config + metrics) and plots.
|
|
68
|
+
|
|
69
|
+
---
|
|
70
|
+
|
|
71
|
+
## 2. Single Evaluation — `evaluate.py`
|
|
72
|
+
|
|
73
|
+
```bash
|
|
74
|
+
python evaluate.py --model beta_vae_pi_lstm # default checkpoint
|
|
75
|
+
python evaluate.py --model beta_vae_pi_lstm --seed 123 # resolves *_s123.pt
|
|
76
|
+
python evaluate.py --model all --plots # every checkpoint on disk
|
|
77
|
+
```
|
|
78
|
+
|
|
79
|
+
| Flag | Description |
|
|
80
|
+
|---|---|
|
|
81
|
+
| `--model NAME/all` | Model to evaluate (default: `all`). |
|
|
82
|
+
| `--seed N` | Resolves `*_s{N}.pt`. |
|
|
83
|
+
| `--ckpt PATH` | Custom checkpoint path. |
|
|
84
|
+
| `--plots` / `--scatter PATH` | Save prediction grids / scatter comparison. |
|
|
85
|
+
| `--regime-ablation --test-regime 2/3` | Evaluate on R2 or R3 instead of the fault set. |
|
|
86
|
+
|
|
87
|
+
---
|
|
88
|
+
|
|
89
|
+
## 3. Multi-Seed Benchmark — `run_seeds.py`
|
|
90
|
+
|
|
91
|
+
Trains and evaluates across multiple seeds, both protocols, and aggregates mean ± std.
|
|
92
|
+
|
|
93
|
+
```bash
|
|
94
|
+
python run_seeds.py --model beta_vae_pi_lstm # 5 default seeds, both protocols
|
|
95
|
+
python run_seeds.py --model beta_vae_pi_lstm --seeds 42 123 456 # custom seeds
|
|
96
|
+
python run_seeds.py --model beta_vae_pi_lstm --protocol 1 # one protocol only
|
|
97
|
+
python run_seeds.py --model all --device cuda # every model, sequential
|
|
98
|
+
python run_seeds.py --model beta_vae_pi_lstm --eval-only # re-aggregate only
|
|
99
|
+
python run_seeds.py --model beta_vae_pi_lstm --skip-existing --parallel 1 # resume, avoid GPU/RAM OOM
|
|
100
|
+
```
|
|
101
|
+
|
|
102
|
+
| Flag | Description |
|
|
103
|
+
|---|---|
|
|
104
|
+
| `--model NAME/all` | Single model or every registered model + adaptation variant. |
|
|
105
|
+
| `--protocol 1/2/both` | 1 = train R1–R3, test R4 (fault). 2 = train R1 only, test R4 (also reports R2/R3). |
|
|
106
|
+
| `--seeds N [N ...]` / `--n-seeds N` | Explicit list, or count of default seeds (42, 123, 456, 789, 1024). |
|
|
107
|
+
| `--epochs N` / `--device` | Override epochs / force device. |
|
|
108
|
+
| `--skip-existing` | Resume: skip seeds with existing checkpoints. |
|
|
109
|
+
| `--eval-only` | No training, just aggregate existing checkpoints/caches. |
|
|
110
|
+
| `--parallel N` | Concurrent GPU jobs (default 4). **Lower this (1–2) for adaptation models** (`*_jit_ft`, `vae_jitl`) — each JIT-FT job loads a full encoder + LSTM + K-NN window DB and 4+ in parallel can OOM a small GPU/host. |
|
|
111
|
+
| `--out-dir PATH` | Custom output root (default `outputs/seed_sweep/<model>`). |
|
|
112
|
+
|
|
113
|
+
Adaptation models (`beta_vae_jit_ft`, `cvae_jit_ft`, `vae_jitl`) are trained in Phase 1/2
|
|
114
|
+
(their base LSTM + encoder), then Phase 3 runs the on-the-fly adaptation script per seed —
|
|
115
|
+
no extra flags needed, just pass the model name like any other.
|
|
116
|
+
|
|
117
|
+
**Output**: `outputs/seed_sweep/<model>/`
|
|
118
|
+
```
|
|
119
|
+
summary.csv # mean ± std / NRMSE% / Δ% per protocol
|
|
120
|
+
p{1,2}/checkpoints/<model>_s{seed}.pt
|
|
121
|
+
p{1,2}/encoders/{type}_s{seed}.pt + {type}_scaler_s{seed}.joblib # per-seed Raman encoder, if applicable
|
|
122
|
+
p{1,2}/seed_{seed}.log
|
|
123
|
+
```
|
|
124
|
+
|
|
125
|
+
---
|
|
126
|
+
|
|
127
|
+
## 4. Raman Encoders — `scripts/train_autoencoder.py`
|
|
128
|
+
|
|
129
|
+
Trains a CDAE / CVAE / β-VAE encoder from scratch (independent of any LSTM).
|
|
130
|
+
|
|
131
|
+
```bash
|
|
132
|
+
PYTHONPATH=. python scripts/train_autoencoder.py --model beta_vae \
|
|
133
|
+
--max-beta 0.005 --anneal-schedule linear --anneal-epochs 100 --anneal-delay 20
|
|
134
|
+
PYTHONPATH=. python scripts/train_autoencoder.py --model cvae --beta 1.0
|
|
135
|
+
PYTHONPATH=. python scripts/train_autoencoder.py --model cdae --noise-std 0.1
|
|
136
|
+
```
|
|
137
|
+
|
|
138
|
+
Key flags: `--model {cdae,cvae,beta_vae,beta_vae_light}`, `--latent-dim` (default 64),
|
|
139
|
+
`--max-beta` / `--anneal-schedule {linear,cyclical}` / `--anneal-epochs` / `--anneal-delay`
|
|
140
|
+
(β-VAE only), `--regime-ablation` (train on R1 only), `--seed`, `--ckpt` / `--scaler`.
|
|
141
|
+
|
|
142
|
+
Static baselines (PCA / PLS) use dedicated scripts with a similar CLI:
|
|
143
|
+
`scripts/pca_baseline.py`, `scripts/pls_baseline.py`, `scripts/pls_pca_baseline_k64.py`
|
|
144
|
+
(the 64-component joint sweep used for the benchmark table), `scripts/svr_baseline.py`.
|
|
145
|
+
|
|
146
|
+
---
|
|
147
|
+
|
|
148
|
+
## 5. β Sweep — `scripts/beta_sweep_e2e.py`
|
|
149
|
+
|
|
150
|
+
End-to-end sweep: trains a β-VAE encoder **and** its PI-LSTM for each β value, evaluates
|
|
151
|
+
on R1val/R2/R3/Fault, and reports the U-curve (reconstruction vs. disentanglement trade-off).
|
|
152
|
+
|
|
153
|
+
```bash
|
|
154
|
+
PYTHONPATH=. python scripts/beta_sweep_e2e.py # default 8-point log grid
|
|
155
|
+
PYTHONPATH=. python scripts/beta_sweep_e2e.py --betas 0.001 0.005 0.05 1.0
|
|
156
|
+
PYTHONPATH=. python scripts/beta_sweep_e2e.py --skip-trained --out-dir outputs/my_sweep
|
|
157
|
+
PYTHONPATH=. python scripts/beta_sweep_e2e.py --plots-only # reuse existing sweep_results.json
|
|
158
|
+
```
|
|
159
|
+
|
|
160
|
+
`--skip-trained` resumes a sweep by reusing checkpoints already on disk per β
|
|
161
|
+
(`checkpoints/<tag>/{vae.pt,vae_scaler.joblib,lstm.pt}`) — only evaluation is re-run, so
|
|
162
|
+
metrics always reflect the current code. For long sweeps, launch detached:
|
|
163
|
+
```bash
|
|
164
|
+
nohup .venv/bin/python -u scripts/beta_sweep_e2e.py > outputs/sweep.log 2>&1 &
|
|
165
|
+
```
|
|
166
|
+
|
|
167
|
+
---
|
|
168
|
+
|
|
169
|
+
## 6. On-the-Fly Adaptation (JIT-FT / VAE-JITL)
|
|
170
|
+
|
|
171
|
+
Two local-adaptation variants on top of a **frozen** global PI-LSTM:
|
|
172
|
+
|
|
173
|
+
- **JIT-FT** (`scripts/cvae_jit_ft.py`): retrieves the K nearest training windows by
|
|
174
|
+
symmetric-KL distance in latent space, briefly fine-tunes a cloned copy of the global
|
|
175
|
+
LSTM on them, predicts, then discards the clone.
|
|
176
|
+
- **VAE-JITL** (`scripts/vae_jitl.py`): same K-NN retrieval but fits a fresh **local PLS**
|
|
177
|
+
regression per query instead of fine-tuning a neural net — more robust, slightly higher
|
|
178
|
+
bias.
|
|
179
|
+
|
|
180
|
+
```bash
|
|
181
|
+
PYTHONPATH=. python scripts/cvae_jit_ft.py --model beta_vae --K 150 \
|
|
182
|
+
--global-ckpt outputs/seed_sweep/beta_vae_pi_lstm/p1/checkpoints/beta_vae_pi_lstm_s42.pt \
|
|
183
|
+
--cvae-ckpt outputs/seed_sweep/beta_vae_pi_lstm/p1/encoders/beta_vae_s42.pt \
|
|
184
|
+
--cvae-scaler outputs/seed_sweep/beta_vae_pi_lstm/p1/encoders/beta_vae_scaler_s42.joblib
|
|
185
|
+
|
|
186
|
+
PYTHONPATH=. python scripts/vae_jitl.py --K 500 --local-model pls --n-components 10
|
|
187
|
+
```
|
|
188
|
+
|
|
189
|
+
> **Important**: `--cvae-ckpt`/`--cvae-scaler` (or `--ckpt`/`--scaler` for `vae_jitl.py`)
|
|
190
|
+
> **must** match the exact encoder the `--global-ckpt` LSTM was trained with — its `feat`
|
|
191
|
+
> scaler is calibrated to that encoder's latent range. `run_seeds.py` resolves this
|
|
192
|
+
> automatically per seed; when calling the scripts directly, always pass matching paths.
|
|
193
|
+
|
|
194
|
+
Other useful flags (`cvae_jit_ft.py`): `--local-epochs` / `--local-lr` (fine-tune budget,
|
|
195
|
+
default 8 steps @ 2e-5), `--confidence-threshold` (skip fine-tuning when the K-NN distance
|
|
196
|
+
is low, 0 = always fine-tune), `--regime-ablation` (R1-only DB, evaluates R2/R3/Fault),
|
|
197
|
+
`--rebuild-db` (invalidate a stale `.npz` window cache).
|
|
198
|
+
|
|
199
|
+
---
|
|
200
|
+
|
|
201
|
+
## 7. Protocol 2 Standalone Eval — `scripts/protocol2_eval.py`
|
|
202
|
+
|
|
203
|
+
No CLI flags — runs a fixed battery of static baselines + JIT-FT variants on the R1-only
|
|
204
|
+
(Protocol 2) split and prints a comparison table. Edit the script's constants to change
|
|
205
|
+
checkpoints/encoders.
|
|
206
|
+
|
|
207
|
+
```bash
|
|
208
|
+
PYTHONPATH=. python scripts/protocol2_eval.py
|
|
209
|
+
```
|
|
210
|
+
|
|
211
|
+
---
|
|
212
|
+
|
|
213
|
+
## Models
|
|
214
|
+
|
|
215
|
+
| Model | Config | Input | Notes |
|
|
216
|
+
|---|---|---|---|
|
|
217
|
+
| `beta_vae_pi_lstm` | `beta_vae_pi_lstm.yaml` | 64-dim μ, frozen β-VAE | Main model |
|
|
218
|
+
| `cvae_pi_lstm` | `cvae_pi_lstm.yaml` | 64-dim μ, frozen CVAE | |
|
|
219
|
+
| `cdae_pi_lstm` | `cdae_pi_lstm.yaml` | 64-dim z, frozen CDAE | |
|
|
220
|
+
| `pca_pi_lstm` / `pls_pi_lstm` | `pca_pi_lstm.yaml` / `pls_pi_lstm.yaml` | 4-dim linear Raman latents | Static baselines |
|
|
221
|
+
| `pi_lstm` / `process_pi_lstm` | `pi_lstm.yaml` | 23 raw process features | No Raman encoder |
|
|
222
|
+
| `neural_ode` | `neural_ode.yaml` | 23 process features | Continuous-time |
|
|
223
|
+
| `beta_vae_lstm` | `beta_vae_lstm.yaml` | 64-dim μ | Vanilla LSTM (no physics loss) |
|
|
224
|
+
| `beta_vae_liquid`, `beta_vae_mamba`, `beta_vae_lp_pi_lstm`, `beta_vae_latent_lp_pi_lstm`, `delta_cdae_pi_lstm`, `cdae_process_pi_lstm` | matching `.yaml` | various | Architecture ablations |
|
|
225
|
+
| `beta_vae_jit_ft`, `cvae_jit_ft`, `vae_jitl` | — (run via `scripts/`) | same latents | On-the-fly adaptation, see §6 |
|
|
226
|
+
|
|
227
|
+
Architecture: 2-layer LSTM(64) → LayerNorm → Linear(64→32)+LeakyReLU → Linear(32→1)+Sigmoid.
|
|
228
|
+
Physics loss: `dP = k_prod * r_net * dt`, λ annealed 0 → 0.1 over epochs 30–110.
|
|
229
|
+
|
|
230
|
+
---
|
|
231
|
+
|
|
232
|
+
## Evaluation Protocol
|
|
233
|
+
|
|
234
|
+
- **Protocol 1**: Train on R1–R3 (batches 0–89, 80/20 random split → 72 train / 18 val). Test on R4 (fault, 90–99).
|
|
235
|
+
- **Protocol 2 (regime ablation)**: Train on R1 only (batches 0–29 → 24 train / 6 val). Test on R4 (also reports R2/R3 generalization).
|
|
236
|
+
- **Metrics**: RMSE, MAE, R² computed at sparse offline measurement points only (~20/batch, ~200 total), in **g/L**.
|
|
237
|
+
- **NRMSE%**: RMSE / 8.481 g/L (mean sparse-point penicillin concentration) × 100.
|
|
238
|
+
- **Δ%**: (Test RMSE − Val RMSE) / Val RMSE × 100 — generalization gap.
|
|
239
|
+
|
|
240
|
+
---
|
|
241
|
+
|
|
242
|
+
## Layout
|
|
243
|
+
|
|
244
|
+
```
|
|
245
|
+
train.py / evaluate.py / run_seeds.py Core pipeline entry points (only Python files at repo root)
|
|
246
|
+
|
|
247
|
+
configs/<model>.yaml One YAML per model (data/model/training sections)
|
|
248
|
+
|
|
249
|
+
scripts/ Everything else: training variants, sweeps, adaptation,
|
|
250
|
+
analysis. All run from the repo root:
|
|
251
|
+
`PYTHONPATH=. python scripts/<script>.py`
|
|
252
|
+
train_autoencoder.py Train CDAE / CVAE / β-VAE encoder
|
|
253
|
+
pca_baseline.py, pls_baseline.py, svr_baseline.py, pls_pca_baseline_k64.py
|
|
254
|
+
beta_sweep_e2e.py End-to-end β sweep (encoder + LSTM)
|
|
255
|
+
cvae_jit_ft.py, vae_jitl.py On-the-fly adaptation
|
|
256
|
+
protocol2_eval.py Fixed P2 comparison table
|
|
257
|
+
multi_seed_train.py, run_all_seeds.py End-to-end multi-seed retraining (encoder+LSTM)
|
|
258
|
+
benchmark_summary.py Aggregate all results into one table
|
|
259
|
+
train_latent_ode.py, train_neural_cde.py, train_sindyc.py, train_bvae_mlp.py, train_capacity_vae_lstm.py
|
|
260
|
+
Alternative temporal-model baselines
|
|
261
|
+
shap_*.py, latent_*.py, evaluate_dci.py, evaluate_mig.py, compute_sap.py, eval_bvae_z52.py,
|
|
262
|
+
analyze_rotation.py, analyze_latent_norm.py, latent_geometry.py, compute_pr_k95_sweep.py,
|
|
263
|
+
beta_sweep_viz.py, plot_pr_scaled.py Interpretability / latent-space analysis (ad hoc, standalone)
|
|
264
|
+
run_control.sh, run_rotate.sh, run_lstm_seeds.sh, run_fixed_epochs.sh, run_beta_sweep.sh,
|
|
265
|
+
run_ncde_ablations.sh Shell orchestration for the scripts above (multi-seed loops)
|
|
266
|
+
|
|
267
|
+
src/
|
|
268
|
+
config.py YAML -> Config object
|
|
269
|
+
latent_norm.py Optional latent-scaling intervention (used by train.py)
|
|
270
|
+
autoencoder/ CDAE_Raman, CVAE_Raman, BetaVAE_Raman
|
|
271
|
+
data/ Dataset + per-encoder-type loaders
|
|
272
|
+
models/ nn.Module definitions
|
|
273
|
+
algorithms/ fit / evaluate / save / load per model (REGISTRY)
|
|
274
|
+
physics/ Mass-balance physics-loss terms
|
|
275
|
+
evaluation/ compute_metrics (RMSE, MAE, R2)
|
|
276
|
+
visualization/ Training-history + prediction plots
|
|
277
|
+
|
|
278
|
+
checkpoints/ Saved weights (not tracked by git)
|
|
279
|
+
outputs/ All generated results, logs, and plots — nothing is
|
|
280
|
+
ever written outside this directory (or checkpoints/)
|
|
281
|
+
seed_sweep/ run_seeds.py results
|
|
282
|
+
seed_sweep_beta/ run_beta_sweep.sh results (β sweep via run_seeds.py)
|
|
283
|
+
beta_sweep_e2e/ beta_sweep_e2e.py results
|
|
284
|
+
full_rotate_experiments_v2/, _v3/ run_rotate.sh / run_lstm_seeds.sh results
|
|
285
|
+
latent_norm_experiments/ run_latent_norm.py results
|
|
286
|
+
benchmark/ Final comparison table
|
|
287
|
+
```
|
|
288
|
+
|
|
289
|
+
> **Convention**: every script, regardless of where it lives (`scripts/` or root), is meant to be
|
|
290
|
+
> invoked **from the repository root** so that relative paths (dataset CSV, `outputs/`,
|
|
291
|
+
> `checkpoints/`) resolve correctly — e.g. `PYTHONPATH=. python scripts/latent_geometry.py`,
|
|
292
|
+
> not `cd scripts && python latent_geometry.py`.
|
|
293
|
+
|
|
294
|
+
---
|
|
295
|
+
|
|
296
|
+
## Reproducibility
|
|
297
|
+
|
|
298
|
+
- Default seed: 42 (controls train/val split, weight init, data shuffling).
|
|
299
|
+
- Use `run_seeds.py` with ≥5 seeds to report mean ± std.
|
|
300
|
+
- Checkpoints embed the full config + metrics for traceability.
|
|
301
|
+
- cuDNN non-determinism may cause ±1% run-to-run variation on GPU.
|
|
302
|
+
- Each adaptation-model evaluation re-encodes Raman spectra with the **exact** encoder
|
|
303
|
+
the evaluated LSTM was trained with (see §6) — mixing encoders across seeds silently
|
|
304
|
+
inflates test RMSE by 10–100x without raising an error, so always double-check
|
|
305
|
+
`--cvae-ckpt`/`--cvae-scaler` (or let `run_seeds.py` resolve them automatically).
|
|
306
|
+
|
|
307
|
+
---
|
|
308
|
+
|
|
309
|
+
*Internal project — ReaKt / Genopole. Not for redistribution.*
|