zonca commited on
Commit
0bf7896
Β·
verified Β·
1 Parent(s): 2ee90d7

Model card: Test 3 v3 (2.18%), flag v2 Test 3/4 as superseded, fix upstream repo links

Browse files
Files changed (1) hide show
  1. README.md +51 -7
README.md CHANGED
@@ -10,11 +10,18 @@ tags:
10
  library_name: pytorch
11
  ---
12
 
 
 
 
 
 
 
 
13
  # torch-harmonics-healpix
14
 
15
- Spectral CNN models for CMB parameter estimation on the HEALPix sphere, bridging [torch-harmonics](https://github.com/Philippe7427/torch-harmonics) with HEALPix maps.
16
 
17
- These models reproduce and improve upon the benchmarks from [Krachmalnicoff & Tomasi (2019)](https://arxiv.org/abs/1902.04083), which originally used the pixel-space [NNhealpix](https://github.com/NToulis/nnhealpix) architecture.
18
 
19
  **Source code:** `https://github.com/zonca/torch-harmonics-healpix`
20
 
@@ -24,15 +31,20 @@ These models reproduce and improve upon the benchmarks from [Krachmalnicoff & To
24
  |-------|------|------|-------|--------|-------|--------|
25
  | SpectralCNN T1 | `models/test1_v2_fix_noise0.pt` | β„“_peak estimation | T map | β„“_peak | 1.27% | 6.4M |
26
  | SpectralCNN T2 | `models/test2_v2_fix_fsky1.0.pt` | β„“_Ep / β„“_Bp estimation | Q, U, mask | [β„“_Ep, β„“_Bp] | 1.69% / 1.53% | 9.8M |
27
- | SpectralCNN T3 | `models/test3_v2_fix.pt` | Ο„ estimation | Q, U, mask | Ο„ | 3.76% | 9.8M |
 
 
 
 
 
28
 
29
  ## Architecture
30
 
31
  **SpectralCNN** performs convolution in harmonic space instead of pixel space:
32
 
33
- 1. **HEALPix β†’ Equiangular** resampling (bilinear interpolation)
34
  2. **SHT** (Spherical Harmonic Transform) via torch-harmonics
35
- 3. **Learned spectral weights** β€” complex-valued 1Γ—1 convolutions on (β„“, m) coefficients
36
  4. **ISHT** (Inverse SHT) back to pixel space
37
  5. **Equiangular β†’ HEALPix** resampling
38
 
@@ -88,7 +100,7 @@ uv venv .venv --python 3.11
88
  source .venv/bin/activate
89
  uv pip install torch==2.6.0 torchvision==0.21.0 --index-url https://download.pytorch.org/whl/cu124
90
  uv pip install torch-harmonics==0.8.0 --no-deps
91
- uv pip install healpy h5py scipy huggingface_hub
92
  uv pip install -e "git+https://github.com/zonca/torch-harmonics-healpix#egg=torch-harmonics-healpix"
93
  ```
94
 
@@ -130,7 +142,39 @@ input_tensor = torch.from_numpy(
130
  with torch.no_grad():
131
  prediction = model(input_tensor)
132
 
133
- print(f"Predicted parameter: {prediction.item():.4f}")
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
134
  ```
135
 
136
  ## Training
 
10
  library_name: pytorch
11
  ---
12
 
13
+ > **⚠️ Pipeline notice (2026-07):** the **Test 4** weights below were trained
14
+ > with the v2 pipeline, which generated maps from CAMB D_β„“ instead of C_β„“
15
+ > amplitudes (missing `raw_cl=True`); they reproduce the superseded v2 numbers
16
+ > only. **Test 3 now has a corrected v3 checkpoint** (`models/test3_v3.pt`,
17
+ > Ο„ error 2.18%); `models/test3_v2_fix.pt` is kept for provenance only.
18
+ > Test 1 and Test 2 weights do not use CAMB and are unaffected.
19
+
20
  # torch-harmonics-healpix
21
 
22
+ Spectral CNN models for CMB parameter estimation on the HEALPix sphere, bridging [torch-harmonics](https://github.com/NVIDIA/torch-harmonics) with HEALPix maps.
23
 
24
+ These models reproduce and improve upon the benchmarks from [Krachmalnicoff & Tomasi (2019)](https://arxiv.org/abs/1902.04083), which originally used the pixel-space [NNhealpix](https://github.com/ai4cmb/NNhealpix) architecture.
25
 
26
  **Source code:** `https://github.com/zonca/torch-harmonics-healpix`
27
 
 
31
  |-------|------|------|-------|--------|-------|--------|
32
  | SpectralCNN T1 | `models/test1_v2_fix_noise0.pt` | β„“_peak estimation | T map | β„“_peak | 1.27% | 6.4M |
33
  | SpectralCNN T2 | `models/test2_v2_fix_fsky1.0.pt` | β„“_Ep / β„“_Bp estimation | Q, U, mask | [β„“_Ep, β„“_Bp] | 1.69% / 1.53% | 9.8M |
34
+ | **SpectralCNN T3 (v3)** | `models/test3_v3.pt` | Ο„ estimation | Q, U, mask | Ο„ | **2.18%** | 9.8M |
35
+ | SpectralCNN T3 (v2, superseded) | `models/test3_v2_fix.pt` | Ο„ estimation | Q, U, mask | Ο„ | 3.76% (D_β„“ bug) | 9.8M |
36
+ | SpectralCNN T4 | `models/test4_fsky1.0_noise0.pt` | r/Ο„ estimation (f_sky=1.0, Οƒ=0) | Q, U, mask | [log(r+1e-4), Ο„] | TBD | 9.8M |
37
+ | SpectralCNN T4 | `models/test4_fsky1.0_noise6.pt` | r/Ο„ estimation (f_sky=1.0, Οƒ=6) | Q, U, mask | [log(r+1e-4), Ο„] | TBD | 9.8M |
38
+ | SpectralCNN T4 | `models/test4_fsky0.1_noise0.pt` | r/Ο„ estimation (f_sky=0.1, Οƒ=0) | Q, U, mask | [log(r+1e-4), Ο„] | TBD | 9.8M |
39
+ | SpectralCNN T4 | `models/test4_fsky0.1_noise6.pt` | r/Ο„ estimation (f_sky=0.1, Οƒ=6) | Q, U, mask | [log(r+1e-4), Ο„] | TBD | 9.8M |
40
 
41
  ## Architecture
42
 
43
  **SpectralCNN** performs convolution in harmonic space instead of pixel space:
44
 
45
+ 1. **HEALPix β†’ Equiangular** resampling (nearest-neighbor interpolation)
46
  2. **SHT** (Spherical Harmonic Transform) via torch-harmonics
47
+ 3. **Learned spectral weights** β€” learned complex-valued spectral weights via einsum on (β„“, m) coefficients
48
  4. **ISHT** (Inverse SHT) back to pixel space
49
  5. **Equiangular β†’ HEALPix** resampling
50
 
 
100
  source .venv/bin/activate
101
  uv pip install torch==2.6.0 torchvision==0.21.0 --index-url https://download.pytorch.org/whl/cu124
102
  uv pip install torch-harmonics==0.8.0 --no-deps
103
+ uv pip install healpy astropy scipy huggingface_hub
104
  uv pip install -e "git+https://github.com/zonca/torch-harmonics-healpix#egg=torch-harmonics-healpix"
105
  ```
106
 
 
142
  with torch.no_grad():
143
  prediction = model(input_tensor)
144
 
145
+ print(f"Predicted parameter: {prediction[0, 0].item():.4f}")
146
+ ```
147
+
148
+ ### Test 4 β€” Joint r/Ο„ estimation
149
+
150
+ ```python
151
+ # Test 4: Joint r/Ο„ estimation (Simons Observatory)
152
+ model = SpectralCNN(
153
+ in_channels=3, # Q, U, mask
154
+ out_channels=2, # [log(r + 1e-4), Ο„]
155
+ nside=16,
156
+ hidden_channels=32,
157
+ num_blocks=3, # Note: 3 blocks (not 4 like Tests 2/3)
158
+ inpaint=True, # True for f_sky < 1.0
159
+ )
160
+
161
+ model_path = hf_hub_download(
162
+ repo_id="zonca/torch-harmonics-healpix",
163
+ filename="models/test4_fsky0.1_noise6.pt",
164
+ )
165
+ state_dict = torch.load(model_path, map_location="cpu")
166
+ model.load_state_dict(state_dict)
167
+ model.eval()
168
+
169
+ # Run inference
170
+ with torch.no_grad():
171
+ prediction = model(input_tensor) # shape: [1, 2]
172
+
173
+ import numpy as np
174
+ log_r = prediction[0, 0].item()
175
+ tau = prediction[0, 1].item()
176
+ r_estimate = np.exp(log_r) - 1e-4
177
+ print(f"Predicted r: {r_estimate:.6f}, Ο„: {tau:.4f}")
178
  ```
179
 
180
  ## Training