delight-real / README.md
AlanMontanares's picture
Five fold models
4642bfa
|
Raw History Blame Contribute Delete
3.58 kB
---
library_name: pytorch
tags:
- astronomy
- supernovae
- transients
- pan-starrs
- cnn
- pytorch
- host-galaxy-identification
datasets:
- PRISM-Astro/h2f_delight_train
- PRISM-Astro/h2f_delight_test
---
# DELIGHT-Real
The DELIGHT model (Förster et al. 2022) trained with the real, hand-labelled host-transient pairs of the DELIGHT training sample. 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_train](https://huggingface.co/datasets/PRISM-Astro/h2f_delight_train) 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 | 36 | 5292 | 0.06338 | 2.146 |
| 2 | 31 | 4588 | 0.06000 | 2.357 |
| 3 | 32 | 4736 | 0.05946 | 1.718 |
| 4 | 38 | 5624 | 0.06700 | 2.617 |
| 5 | 37 | 5439 | 0.06177 | 1.691 |
| **Mean ± std** | | | 0.06232 ± 0.00272 | 2.106 ± 0.360 |
## 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-real"
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.