Contrastive Astromer: Two-Stage Contrastive Representation Learning for Astronomical Light Curve Classification
Organizations: School of Engineering and Applied Sciences, Harvard University, Cambridge, MA, 02138, USA · Department of Computer Science, Universidad de Concepción, Edmundo Larenas 219, Concepción, Chile
Abstract
Large astronomical surveys collect abundant light curves, but reliable class labels remain scarce. ASTROMER 2 learns from unlabeled light curves by reconstructing masked observations, yet this objective does not explicitly encourage class separation in a compact representation of each light curve. We introduce Contrastive Astromer, a two-stage approach that makes these representations more useful for classification without changing the ASTROMER 2 encoder architecture. First, unsupervised contrastive learning on single-band MACHO light curves brings together representations of augmented views of the same object. Supervised contrastive learning, supported by an auxiliary classification loss, then uses a separate labeled Alcock sample to strengthen class discrimination. We evaluate the resulting representations by freezing the encoder and training a separate classifier. On a held-out set of 600 objects, this classifier achieves a macro-F1 of 0.7943 with 500 labeled examples per class, exceeding our reproduction of the ASTROMER 2 finetune-and-classify pipeline by 5.10 percentage points. With downstream classifier training budgets of 20 and 100 examples per class, macro-F1 reaches 0.7078 and 0.7704, respectively, also surpassing this baseline. Embedding-space analyses further show that supervised adaptation improves local class consistency and global class separation. These results show that contrastive adaptation makes pretrained light-curve representations more effective for classification and more informative about the structure of variability classes.
Figures & tables
| Stage 1 | Stage 2 | |||
| Augmentation operator | Probability | Strength / parameter | Probability | Strength / parameter |
| Time jitter | Maximum shift: times time range | Maximum shift: times time range | ||
| Amplitude scaling | Scale range: | Scale range: | ||
| Amplitude shift | Shift range: | Shift range: | ||
| Gaussian magnitude noise | Noise level: | Noise level: | ||
| Random observation masking | Drop probability: | Drop probability: | ||
| Partition | Objects | Per class | Role |
| Stage 2 pool | 17,294 | class-imbalanced | representation learning |
| Downstream CV pool | 3,000 | 500 | five-fold selection |
| Final holdout | 600 | 100 | one-time testing |
| Total | 20,894 | — | — |
| Stage | Dataset and split | Labels used? | Encoder updated? | Projection/ classifier head | Purpose |
| Stage 1 | MACHO; no objects overlapping with Alcock | No | Yes | Projection head trained | Unsupervised contrastive representation learning |
| Stage 2 | 17,294-object Alcock representation pool | Yes | Yes | Projection head and auxiliary classifier trained | Supervised contrastive learning |
| CV and selection | 3,000-object pool; five folds; Alcock20/100/500 | Yes | No | Pooled- MLP head trained per run | Select one Stage 1 checkpoint using validation only |
| Final evaluation | Setting-specific training pool; 600-object holdout | Yes | No | Final MLP head retrained | Report holdout performance |
| Setting | Stage 1 (unsupervised contrastive) | Stage 2 (supervised contrastive) | Downstream classifier head |
| Data split | MACHO; no objects overlapping with Alcock | 17,294-object Alcock pool | 3,000-object CV pool; 600-object holdout |
| Input window | 200 observations | 200 observations | central 200-observation window |
| Encoder | updated | updated | frozen |
| Objective | InfoNCE / NT-Xent | supervised contrastive + auxiliary CE | sparse categorical cross-entropy |
| Optimizer | Adam | Adam | Adam |
| Learning rate |
| Model / Pipeline | Alcock20 | Alcock100 | Alcock500 |
| Official ASTROMER 2 finetune-and-classify | |||
| Original ASTROMER 2 encoder pooled- | |||
| Stage 1, epoch 47 (independently selected) | |||
| Stage 1, epoch 33 (matched initialization) | |||
| Stage 2 (from Stage 1, epoch 33) |
| Class | Precision | Recall | F1 | Support |
| Cep_0 | 0.8977 | 0.7900 | 0.8404 | 100 |
| Cep_1 | 0.6484 | 0.8300 | 0.7281 | 100 |
| EC | 0.7912 | 0.7200 | 0.7539 | 100 |
| LPV | 0.8353 | 0.7100 | 0.7676 | 100 |
| RRab | 0.8367 | 0.8200 | 0.8283 | 100 |
| RRc | 0.8091 | 0.8900 | 0.8476 | 100 |
| Encoder | k-NN macro-F1 | Inter/intra ratio | Silhouette coefficient |
| Original ASTROMER 2 | 0.4926 | 1.5267 | -0.1008 |
| Stage 1, epoch 33 | 0.7133 | 1.2038 | 0.0101 |
| Stage 2 from epoch 33 | 0.7462 | 1.7577 | 0.0926 |
Appendix figures & tables1 asset
Supplementary material from the paper’s appendix.
Appendix
| Method | Configuration |
| Sampling | 500 objects per class sampled without replacement from 20,894 unique Alcock objects; 3,000 objects total; random seed 42. |
| Preprocessing | StandardScaler fitted independently to each encoder’s 3,000 sampled embeddings. |
| PCA | Two components; random seed 42. |
| t-SNE | Two components; perplexity 30; PCA initialization; automatic learning rate; random seed 42. |
| UMAP | Two components; 15 nearest neighbors; minimum distance 0.1; Euclidean distance; random seed 42. |
Contrastive Learning
Contrastive learning trains representations by bringing related examples together and separating unrelated ones for recognition, retrieval, and transfer.
See all 335 papers