wavedl 1.4.6__py3-none-any.whl → 1.5.1__py3-none-any.whl
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.
- wavedl/__init__.py +1 -1
- wavedl/hpo.py +9 -1
- wavedl/models/vit.py +21 -0
- wavedl/test.py +28 -5
- wavedl/train.py +122 -15
- wavedl/utils/__init__.py +11 -0
- wavedl/utils/config.py +10 -0
- wavedl/utils/constraints.py +470 -0
- wavedl/utils/cross_validation.py +12 -2
- wavedl/utils/data.py +26 -7
- wavedl/utils/metrics.py +49 -2
- {wavedl-1.4.6.dist-info → wavedl-1.5.1.dist-info}/METADATA +122 -19
- {wavedl-1.4.6.dist-info → wavedl-1.5.1.dist-info}/RECORD +17 -16
- {wavedl-1.4.6.dist-info → wavedl-1.5.1.dist-info}/LICENSE +0 -0
- {wavedl-1.4.6.dist-info → wavedl-1.5.1.dist-info}/WHEEL +0 -0
- {wavedl-1.4.6.dist-info → wavedl-1.5.1.dist-info}/entry_points.txt +0 -0
- {wavedl-1.4.6.dist-info → wavedl-1.5.1.dist-info}/top_level.txt +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.2
|
|
2
2
|
Name: wavedl
|
|
3
|
-
Version: 1.
|
|
3
|
+
Version: 1.5.1
|
|
4
4
|
Summary: A Scalable Deep Learning Framework for Wave-Based Inverse Problems
|
|
5
5
|
Author: Ductho Le
|
|
6
6
|
License: MIT
|
|
@@ -99,6 +99,7 @@ The framework handles the engineering challenges of large-scale deep learning
|
|
|
99
99
|
|
|
100
100
|
## ✨ Features
|
|
101
101
|
|
|
102
|
+
<div align="center">
|
|
102
103
|
<table width="100%">
|
|
103
104
|
<tr>
|
|
104
105
|
<td width="50%" valign="top">
|
|
@@ -113,14 +114,12 @@ Train on datasets larger than RAM:
|
|
|
113
114
|
</td>
|
|
114
115
|
<td width="50%" valign="top">
|
|
115
116
|
|
|
116
|
-
**🧠
|
|
117
|
+
**🧠 Models? We've Got Options**
|
|
117
118
|
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
```
|
|
123
|
-
Design your model. Register with one line.
|
|
119
|
+
38 architectures, ready to go:
|
|
120
|
+
- CNNs, ResNets, ViTs, EfficientNets...
|
|
121
|
+
- All adapted for regression
|
|
122
|
+
- [Add your own](#adding-custom-models) in one line
|
|
124
123
|
|
|
125
124
|
</td>
|
|
126
125
|
</tr>
|
|
@@ -137,12 +136,12 @@ Multi-GPU training without the pain:
|
|
|
137
136
|
</td>
|
|
138
137
|
<td width="50%" valign="top">
|
|
139
138
|
|
|
140
|
-
|
|
139
|
+
**🔬 Physics-Constrained Training**
|
|
141
140
|
|
|
142
|
-
|
|
143
|
-
-
|
|
144
|
-
-
|
|
145
|
-
-
|
|
141
|
+
Make your model respect the laws:
|
|
142
|
+
- Enforce bounds, positivity, equations
|
|
143
|
+
- Simple expression syntax or Python
|
|
144
|
+
- [Custom constraints](#physical-constraints) for various laws
|
|
146
145
|
|
|
147
146
|
</td>
|
|
148
147
|
</tr>
|
|
@@ -191,6 +190,7 @@ Deploy models anywhere:
|
|
|
191
190
|
</td>
|
|
192
191
|
</tr>
|
|
193
192
|
</table>
|
|
193
|
+
</div>
|
|
194
194
|
|
|
195
195
|
---
|
|
196
196
|
|
|
@@ -279,6 +279,10 @@ python -m wavedl.test --checkpoint <checkpoint_folder> --data_path <test_data> \
|
|
|
279
279
|
# Export model to ONNX for deployment (LabVIEW, MATLAB, C++, etc.)
|
|
280
280
|
python -m wavedl.test --checkpoint <checkpoint_folder> --data_path <test_data> \
|
|
281
281
|
--export onnx --export_path <output_file.onnx>
|
|
282
|
+
|
|
283
|
+
# For 3D volumes with small depth (e.g., 8×128×128), override auto-detection
|
|
284
|
+
python -m wavedl.test --checkpoint <checkpoint_folder> --data_path <test_data> \
|
|
285
|
+
--input_channels 1
|
|
282
286
|
```
|
|
283
287
|
|
|
284
288
|
**Output:**
|
|
@@ -374,6 +378,7 @@ WaveDL/
|
|
|
374
378
|
│ └── utils/ # Utilities
|
|
375
379
|
│ ├── data.py # Memory-mapped data pipeline
|
|
376
380
|
│ ├── metrics.py # R², Pearson, visualization
|
|
381
|
+
│ ├── constraints.py # Physical constraints for training
|
|
377
382
|
│ ├── distributed.py # DDP synchronization
|
|
378
383
|
│ ├── losses.py # Loss function factory
|
|
379
384
|
│ ├── optimizers.py # Optimizer factory
|
|
@@ -383,7 +388,7 @@ WaveDL/
|
|
|
383
388
|
├── configs/ # YAML config templates
|
|
384
389
|
├── examples/ # Ready-to-run examples
|
|
385
390
|
├── notebooks/ # Jupyter notebooks
|
|
386
|
-
├── unit_tests/ # Pytest test suite (
|
|
391
|
+
├── unit_tests/ # Pytest test suite (725 tests)
|
|
387
392
|
│
|
|
388
393
|
├── pyproject.toml # Package config, dependencies
|
|
389
394
|
├── CHANGELOG.md # Version history
|
|
@@ -727,6 +732,104 @@ seed: 2025
|
|
|
727
732
|
|
|
728
733
|
</details>
|
|
729
734
|
|
|
735
|
+
<details>
|
|
736
|
+
<summary><b>Physical Constraints</b> — Enforce Physics During Training</summary>
|
|
737
|
+
|
|
738
|
+
Add penalty terms to the loss function to enforce physical laws:
|
|
739
|
+
|
|
740
|
+
```
|
|
741
|
+
Total Loss = Data Loss + weight × penalty(violation)
|
|
742
|
+
```
|
|
743
|
+
|
|
744
|
+
### Expression Constraints
|
|
745
|
+
|
|
746
|
+
```bash
|
|
747
|
+
# Positivity
|
|
748
|
+
--constraint "y0 > 0"
|
|
749
|
+
|
|
750
|
+
# Bounds
|
|
751
|
+
--constraint "y0 >= 0" "y0 <= 1"
|
|
752
|
+
|
|
753
|
+
# Equations (penalize deviations from zero)
|
|
754
|
+
--constraint "y2 - y0 * y1"
|
|
755
|
+
|
|
756
|
+
# Input-dependent constraints
|
|
757
|
+
--constraint "y0 - 2*x[0]"
|
|
758
|
+
|
|
759
|
+
# Multiple constraints with different weights
|
|
760
|
+
--constraint "y0 > 0" "y1 - y2" --constraint_weight 0.1 1.0
|
|
761
|
+
```
|
|
762
|
+
|
|
763
|
+
### Custom Python Constraints
|
|
764
|
+
|
|
765
|
+
For complex physics (matrix operations, implicit equations):
|
|
766
|
+
|
|
767
|
+
```python
|
|
768
|
+
# my_constraint.py
|
|
769
|
+
import torch
|
|
770
|
+
|
|
771
|
+
def constraint(pred, inputs=None):
|
|
772
|
+
"""
|
|
773
|
+
Args:
|
|
774
|
+
pred: (batch, num_outputs)
|
|
775
|
+
inputs: (batch, features) or (batch, C, H, W) or (batch, C, D, H, W)
|
|
776
|
+
Returns:
|
|
777
|
+
(batch,) — violation per sample (0 = satisfied)
|
|
778
|
+
"""
|
|
779
|
+
# Outputs (same for all data types)
|
|
780
|
+
y0, y1, y2 = pred[:, 0], pred[:, 1], pred[:, 2]
|
|
781
|
+
|
|
782
|
+
# Inputs — Tabular: (batch, features)
|
|
783
|
+
# x0 = inputs[:, 0] # Feature 0
|
|
784
|
+
# x_sum = inputs.sum(dim=1) # Sum all features
|
|
785
|
+
|
|
786
|
+
# Inputs — Images: (batch, C, H, W)
|
|
787
|
+
# pixel = inputs[:, 0, 3, 5] # Pixel at (3,5), channel 0
|
|
788
|
+
# img_mean = inputs.mean(dim=(1,2,3)) # Mean over C,H,W
|
|
789
|
+
|
|
790
|
+
# Inputs — 3D Volumes: (batch, C, D, H, W)
|
|
791
|
+
# voxel = inputs[:, 0, 2, 3, 5] # Voxel at (2,3,5), channel 0
|
|
792
|
+
|
|
793
|
+
# Example constraints:
|
|
794
|
+
# return y2 - y0 * y1 # Wave equation
|
|
795
|
+
# return y0 - 2 * inputs[:, 0] # Output = 2×input
|
|
796
|
+
# return inputs[:, 0, 3, 5] * y0 + inputs[:, 0, 6, 7] * y1 # Mixed
|
|
797
|
+
|
|
798
|
+
return y0 - y1 * y2
|
|
799
|
+
```
|
|
800
|
+
|
|
801
|
+
```bash
|
|
802
|
+
--constraint_file my_constraint.py --constraint_weight 1.0
|
|
803
|
+
```
|
|
804
|
+
|
|
805
|
+
---
|
|
806
|
+
|
|
807
|
+
### Reference
|
|
808
|
+
|
|
809
|
+
| Argument | Default | Description |
|
|
810
|
+
|----------|---------|-------------|
|
|
811
|
+
| `--constraint` | — | Expression(s): `"y0 > 0"`, `"y0 - y1*y2"` |
|
|
812
|
+
| `--constraint_file` | — | Python file with `constraint(pred, inputs)` |
|
|
813
|
+
| `--constraint_weight` | `0.1` | Penalty weight(s) |
|
|
814
|
+
| `--constraint_reduction` | `mse` | `mse` (squared) or `mae` (linear) |
|
|
815
|
+
|
|
816
|
+
#### Expression Syntax
|
|
817
|
+
|
|
818
|
+
| Variable | Meaning |
|
|
819
|
+
|----------|---------|
|
|
820
|
+
| `y0`, `y1`, ... | Model outputs |
|
|
821
|
+
| `x[0]`, `x[1]`, ... | Input values (1D tabular) |
|
|
822
|
+
| `x[i,j]`, `x[i,j,k]` | Input values (2D/3D: images, volumes) |
|
|
823
|
+
| `x_mean`, `x_sum`, `x_max`, `x_min`, `x_std` | Input aggregates |
|
|
824
|
+
|
|
825
|
+
**Operators:** `+`, `-`, `*`, `/`, `**`, `>`, `<`, `>=`, `<=`, `==`
|
|
826
|
+
|
|
827
|
+
**Functions:** `sin`, `cos`, `exp`, `log`, `sqrt`, `sigmoid`, `softplus`, `tanh`, `relu`, `abs`
|
|
828
|
+
|
|
829
|
+
</details>
|
|
830
|
+
|
|
831
|
+
|
|
832
|
+
|
|
730
833
|
<details>
|
|
731
834
|
<summary><b>Hyperparameter Search (HPO)</b></summary>
|
|
732
835
|
|
|
@@ -766,7 +869,7 @@ accelerate launch -m wavedl.train --data_path train.npz --model cnn --lr 3.2e-4
|
|
|
766
869
|
| Schedulers | [all 8](#learning-rate-schedulers) | `--schedulers X Y` |
|
|
767
870
|
| Losses | [all 6](#loss-functions) | `--losses X Y` |
|
|
768
871
|
| Learning rate | 1e-5 → 1e-2 | (always searched) |
|
|
769
|
-
| Batch size |
|
|
872
|
+
| Batch size | 16, 32, 64, 128 | (always searched) |
|
|
770
873
|
|
|
771
874
|
**Quick Mode** (`--quick`):
|
|
772
875
|
- Uses minimal defaults: cnn + adamw + plateau + mse
|
|
@@ -938,12 +1041,12 @@ The `examples/` folder contains a **complete, ready-to-run example** for **mater
|
|
|
938
1041
|
```bash
|
|
939
1042
|
# Run inference on the example data
|
|
940
1043
|
python -m wavedl.test --checkpoint ./examples/elastic_cnn_example/best_checkpoint \
|
|
941
|
-
--data_path ./examples/elastic_cnn_example/
|
|
1044
|
+
--data_path ./examples/elastic_cnn_example/Test_data_500.mat \
|
|
942
1045
|
--plot --save_predictions --output_dir ./examples/elastic_cnn_example/test_results
|
|
943
1046
|
|
|
944
1047
|
# Export to ONNX (already included as model.onnx)
|
|
945
1048
|
python -m wavedl.test --checkpoint ./examples/elastic_cnn_example/best_checkpoint \
|
|
946
|
-
--data_path ./examples/elastic_cnn_example/
|
|
1049
|
+
--data_path ./examples/elastic_cnn_example/Test_data_500.mat \
|
|
947
1050
|
--export onnx --export_path ./examples/elastic_cnn_example/model.onnx
|
|
948
1051
|
```
|
|
949
1052
|
|
|
@@ -952,7 +1055,7 @@ python -m wavedl.test --checkpoint ./examples/elastic_cnn_example/best_checkpoin
|
|
|
952
1055
|
| File | Description |
|
|
953
1056
|
|------|-------------|
|
|
954
1057
|
| `best_checkpoint/` | Pre-trained CNN checkpoint |
|
|
955
|
-
| `
|
|
1058
|
+
| `Test_data_500.mat` | 500 sample test set (500×500 dispersion curves → *h*, √(*E*/ρ), *ν*) |
|
|
956
1059
|
| `model.onnx` | ONNX export with embedded de-normalization |
|
|
957
1060
|
| `training_history.csv` | Epoch-by-epoch training metrics (loss, R², LR, etc.) |
|
|
958
1061
|
| `training_curves.png` | Training/validation loss and learning rate plot |
|
|
@@ -963,7 +1066,7 @@ python -m wavedl.test --checkpoint ./examples/elastic_cnn_example/best_checkpoin
|
|
|
963
1066
|
|
|
964
1067
|
<p align="center">
|
|
965
1068
|
<img src="examples/elastic_cnn_example/training_curves.png" alt="Training curves" width="600"><br>
|
|
966
|
-
<em>Training and validation loss over
|
|
1069
|
+
<em>Training and validation loss over 227 epochs with <code>onecycle</code> learning rate schedule</em>
|
|
967
1070
|
</p>
|
|
968
1071
|
|
|
969
1072
|
**Inference Results:**
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
wavedl/__init__.py,sha256=
|
|
1
|
+
wavedl/__init__.py,sha256=9RY06pDbdsRrjTpxRYGYMTMZl7jB6-Tm-elfcPtvY3Y,1177
|
|
2
2
|
wavedl/hpc.py,sha256=-iOjjKkXPcV_quj4vAsMBJN_zWKtD1lMRfIZZBhyGms,8756
|
|
3
|
-
wavedl/hpo.py,sha256=
|
|
4
|
-
wavedl/test.py,sha256=
|
|
5
|
-
wavedl/train.py,sha256=
|
|
3
|
+
wavedl/hpo.py,sha256=DGCGyt2yhr3WAifAuljhE26gg07CHdaQW4wpDaTKbyo,14968
|
|
4
|
+
wavedl/test.py,sha256=WIHG3HWT-uF399FQApPpxjggBVFn59cC54HAL4990QU,38550
|
|
5
|
+
wavedl/train.py,sha256=P14r46X-A2wBqZ6dxL8Fv6PADDgt_wdNzbDryvznBkA,54458
|
|
6
6
|
wavedl/models/__init__.py,sha256=lfSohEnAUztO14nuwayMJhPjpgySzRN3jGiyAUuBmAU,3206
|
|
7
7
|
wavedl/models/_template.py,sha256=J_D8taSPmV8lBaucN_vU-WiG98iFr7CJrZVNNX_Tdts,4600
|
|
8
8
|
wavedl/models/base.py,sha256=T9iDF9IQM2MYucG_ggQd31rieUkB2fob-nkHyNIl2ak,7337
|
|
@@ -19,19 +19,20 @@ wavedl/models/resnet3d.py,sha256=C7CL4XeSnRlIBuwf5Ei-z183uzIBObrXfkM9Iwuc5e0,874
|
|
|
19
19
|
wavedl/models/swin.py,sha256=p-okfq3Qm4_neJTxCcMzoHoVzC0BHW3BMnbpr_Ri2U0,13224
|
|
20
20
|
wavedl/models/tcn.py,sha256=RtY13QpFHqz72b4ultv2lStCIDxfvjySVe5JaTx_GaM,12601
|
|
21
21
|
wavedl/models/unet.py,sha256=LqIXhasdBygwP7SZNNmiW1bHMPaJTVBpaeHtPgEHkdU,7790
|
|
22
|
-
wavedl/models/vit.py,sha256=
|
|
23
|
-
wavedl/utils/__init__.py,sha256=
|
|
24
|
-
wavedl/utils/config.py,sha256=
|
|
25
|
-
wavedl/utils/
|
|
26
|
-
wavedl/utils/
|
|
22
|
+
wavedl/models/vit.py,sha256=68o9nNjkftvHFArAPupU2ew5e5yCsI2AYaT9TQinVMk,12075
|
|
23
|
+
wavedl/utils/__init__.py,sha256=s5R9bRmJ8GNcJrD3OSAOXzwZJIXZbdYrAkZnus11sVQ,3300
|
|
24
|
+
wavedl/utils/config.py,sha256=jGW-K7AYB6zrD2BfVm2XPnSY9rbfL_EkM4bwxhBLuwM,10859
|
|
25
|
+
wavedl/utils/constraints.py,sha256=Pof5hzeTSGsPY_E6Sc8iMQDaXc_zfEasQI2tCszk_gw,17614
|
|
26
|
+
wavedl/utils/cross_validation.py,sha256=tXiBOY1T7eyO9FwOcxvOkPlhMDdm5rCH1TGDPE-jZak,17961
|
|
27
|
+
wavedl/utils/data.py,sha256=11N7Y6w5PYUSBcGANIB1P8JOapqPrVHjTj9CuUeTLac,49172
|
|
27
28
|
wavedl/utils/distributed.py,sha256=7wQ3mRjkp_xjPSxDWMnBf5dSkAGUaTzntxbz0BhC5v0,4145
|
|
28
29
|
wavedl/utils/losses.py,sha256=5762M-TBC_hz6uyj1NPbU1vZeFOJQq7fR3-j7OygJRo,7254
|
|
29
|
-
wavedl/utils/metrics.py,sha256=
|
|
30
|
+
wavedl/utils/metrics.py,sha256=EJmJvF7gACQsUoKYldlladN_SbnRiuE-Smj0eSnbraQ,39394
|
|
30
31
|
wavedl/utils/optimizers.py,sha256=PyIkJ_hRhFi_Fio81Gy5YQNhcME0JUUEl8OTSyu-0RA,6323
|
|
31
32
|
wavedl/utils/schedulers.py,sha256=e6Sf0yj8VOqkdwkUHLMyUfGfHKTX4NMr-zfgxWqCTYI,7659
|
|
32
|
-
wavedl-1.
|
|
33
|
-
wavedl-1.
|
|
34
|
-
wavedl-1.
|
|
35
|
-
wavedl-1.
|
|
36
|
-
wavedl-1.
|
|
37
|
-
wavedl-1.
|
|
33
|
+
wavedl-1.5.1.dist-info/LICENSE,sha256=cEUCvcvH-9BT9Y-CNGY__PwWONCKu9zsoIqWA-NeHJ4,1066
|
|
34
|
+
wavedl-1.5.1.dist-info/METADATA,sha256=pzrIe4ZaDrRRGPIFlgQayG9L_k2q2g8TBP_puOQoTio,45512
|
|
35
|
+
wavedl-1.5.1.dist-info/WHEEL,sha256=beeZ86-EfXScwlR_HKu4SllMC9wUEj_8Z_4FJ3egI2w,91
|
|
36
|
+
wavedl-1.5.1.dist-info/entry_points.txt,sha256=f1RNDkXFZwBzrBzTMFocJ6xhfTvTmaEDTi5YyDEUaF8,140
|
|
37
|
+
wavedl-1.5.1.dist-info/top_level.txt,sha256=ccneUt3D5Qzbh3bsBSSrq9bqrhGiogcWKY24ZC4Q6Xw,7
|
|
38
|
+
wavedl-1.5.1.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|