delight-synth / README.md
AlanMontanares's picture
Five fold models
7fdaf1d
|
Raw History Blame Contribute Delete
3.88 kB
---
library_name: pytorch
tags:
- astronomy
- supernovae
- transients
- pan-starrs
- cnn
- pytorch
- host-galaxy-identification
datasets:
- PRISM-Astro/h2f_delight_radius_norm_p4
- PRISM-Astro/h2f_delight_test
---
# DELIGHT-Synth
The DELIGHT model (Förster et al. 2022) trained without any real label: the hosts of the DELIGHT training sample, each with synthetic transient positions drawn uniformly in area within three effective radii of its PS1 r-band Sersic ellipse; the number of positions per host, n = max[1, round((R_e / 8 arcsec)^4)], grows with its size (12,610 positions for 7,093 hosts, most hosts with a single one). It locates the host galaxy of a transient from PS1 r-band stamps centred on the transient.
## Model
- Backbone: the DELIGHT convolutional backbone (Förster et al. 2022), shared by the five stamp levels.
- Input: PS1 stamps of 30 x 30 pixels at five levels (0.25 arcsec per pixel at level 0, doubling at each level), band(s) r.
- Output: the host offset (x, y).
The host offset is predicted in level-0 pixels of 0.25 arcsec from the stamp centre. Each prediction is the average of the eight rotations and flips of the stamp, transformed back to the original orientation. M is the mean of min(r, 1), with r the residual distance in units of the host's SEP ellipse scaled by three (semi-axes A = 3a, B = 3b); RMSE_d is the root mean square of the residual distance.
## Training data and cross-validation
Trained on [PRISM-Astro/h2f_delight_radius_norm_p4](https://huggingface.co/datasets/PRISM-Astro/h2f_delight_radius_norm_p4) with five-fold cross-validation: there is
one model per fold, trained on the other four folds and validated on its own fold. The host locators are tested on the real host-transient pairs of [PRISM-Astro/h2f_delight_test](https://huggingface.co/datasets/PRISM-Astro/h2f_delight_test).
For each fold we keep the checkpoint of the epoch with the lowest validation M.
## Validation results
Validation metrics of each fold model on its own validation fold (synthetic transient positions for the models trained on synthetic labels, real hand-labelled pairs for DELIGHT-Real).
| Fold | Epoch | Step | M | RMSE_d (arcsec) |
|---|---|---|---|---|
| 1 | 31 | 7812 | 0.07335 | 1.811 |
| 2 | 31 | 7812 | 0.08089 | 1.815 |
| 3 | 39 | 10023 | 0.07726 | 1.472 |
| 4 | 33 | 7986 | 0.07834 | 1.955 |
| 5 | 36 | 9324 | 0.07808 | 1.228 |
| **Mean ± std** | | | 0.07758 ± 0.00244 | 1.656 ± 0.267 |
## Files
```
config.yaml Hydra configuration of the run (model, dataset, training arguments)
selection.json checkpoint, epoch, step and validation metrics of each fold
fold_k/model.safetensors
fold_k/trainer_state.json
```
## Usage
Access is gated: request access on this page and log in (`huggingface-cli login` or `HF_TOKEN`) before downloading.
```python
from hydra.utils import instantiate
from huggingface_hub import hf_hub_download
from omegaconf import OmegaConf
from safetensors.torch import load_file
repo = "PRISM-Astro/delight-synth"
cfg = OmegaConf.load(hf_hub_download(repo, "config.yaml"))
model = instantiate(cfg.model, _convert_="partial") # needs the PRISM package
model.load_state_dict(load_file(hf_hub_download(repo, "fold_1/model.safetensors")))
model.eval()
```
`config.yaml` is the Hydra configuration of the run, with `dataset.fold_idx: null`; the model of `fold_k` was
trained on the other four folds of the dataset's `fold` column and validated on fold k. All fold models were trained
with an effective batch of 40 stamps (per-device batch times the number of GPUs, which varied between folds), so the
per-device batch size in the file does not apply to every fold.
The input stamps must be preprocessed as in training (band selection and order, inverse hyperbolic sine of the
g band when it is used, five levels); see `prism.dataset` and `scripts/inferencia_test.py` in the code.