Latent ATTEntive Neural Processes for Quasar Light Curves with parametric recovery
Project description
QNPy_Latte
Latent ATTEntive Neural Processes for Quasar Light Curves with parametric recovery
By Aman Nadimpalli Raju, Andjelka Kovacevic, Marina Pavlovic, Dragana Ilic, Iva Cvorovic-Hajdinjak (SER-SAG-S1 team)
Introduction
Many of the secrets of quasars lie hidden within their variations. Analysis of quasar light curves can unlock some of these secrets, giving a holistic view of the region around the central black hole engine, as well as properties of the black hole. However, studying quasar variability itself is a challenge. The stochastic nature of the variations, coupled with the need for short cadence observations over a long period, make analysis difficult.
The LSST (Legacy Survey of Space and Time) will provide a plethora of quasar light curves, with short cadence observations throughout its 10 year run. However, there will be seasonal gaps in the observations, to keep up with the LSST goal of surveying the entire Chilean night sky. In order to utilize the LSST data for variational analysis, it is imperitive to model this data to fill in these gaps. To process the amount of data coming in, any such model should be non-parametric, computational inexpensive, data-driven, and capable of interpolation. We also would like to draw insights from the hidden layers of these models. Thus, we utilize Latent Attentive Neural Processes (AttnLNPs).
As part of the Serbian In-Kind software contribution to the LSST team (SER-SAG-S1), we present the QNPy Latte package to model and determine parameters (especially the transfer function) of quasar light curves. This work has been done by the guest student Aman N. Raju as part of his masters thesis and presented at the following:
Parts of this thesis have been presented as:
• “A Deep Learning Approach for Understanding Quasar Light Curves in the Legacy Survey of Space and Time" - Symposium Mathematics and Applica- tion, Faculty of Mathematics, University of Belgrade, 2023
• “QNPy and QhX Workshop” - LSST AGN Science Collaboration Quarterly Report, March 2024
• “Attentive Latent Neural Processes for modeling Quasar Variability in the LSST” - LSST TVS Colloquium, 21st May 2024
• “Pay Attention: Neural Processes with Latent Spaces and Attention to model Quasar Light Curves for the LSST” - XIII SAW, Astronomical Society “Ruđer Bošković", 18th May 2024
• “UPGRADING QNPY: MODELLING QUASAR LIGHT CURVES IN LARGE SURVEYS” - VI Conference on Active Galactic Nuclei and Gravitational Lensing, Zlatibor Mt., Serbia, June 02-06, 2024
• “Connecting the Dots: Attentive Latent Neural Processes” - 2nd MASS Summer School, Nice, France, July 2024 (First Prize 180s Thesis Talk)
• “LSST SER-SAG-S1: upgrade of QNPy package” - Catching supermassive black holes with Rubin-LSST: Towards novel insights and discoveries into AGN science, Torino, Italy, July 22nd-25th 2024
Furthermore, this repository will be used in the paper, Raju et. al. 2024 (in prep).
Latent Attentive Neural Processes
At SER-SAG-S1, we have used Conditonal Neural Processes (CNPs) to model quasar light curves (see QNPy). However, CNPs suffer from issues with underfitting and produce poor samples. Thus, the addition of attentive mechanisms and a latent path allow for an upgraded model.
The AttnLNP has two paths. One path is the deterministic path that operates similarly to CNPs to create a representation of the light curve. The input data (observation time and magnitudes) are encoded using a multilayer perceptron (MLP) to create a representation for each point. With the addition of self-attention, the points that are more important are weighted more highly in the representation. Then, the representations are used with the input and target times to create a attention weighted representation for each target time, allowing for flexible representations that can adapt to different datapoints.
The latent path operates similarly. However, the representations are simply averaged to create a global representation. This representation is passed through another MLP to generate a multidimensional gaussian latent space that can be sampled from. The latent space samples are combined with the determinstic representation to generate a combined representation for each target point in the light curve. These combined representations are passed through an MLP decoder to generate a predicted magnitude at each target time.
Original implementation from (https://arxiv.org/abs/1901.05761)[Kim et al. 2019]
In our model, we also include the possibility to encode the input and target times with an LSTM RNN layer in order to better reconstruct the quasar light curves as detailed in (https://arxiv.org/abs/1910.09323)[Qin et. al. 2019]
Self Organizing Maps
Just like QNPy, we incorporate Self Organizing Maps (SOMs) (see into our models to cluster the light curves before modelling. This serves a two-fold purpose. The dataset can be partitioned for quicker modelling and the resulting clusters are more balanced topologically than unclustered light curves. SOMs are an unsupervised model that can be customized to generate many clusters and easily updated to include new data without having to retrain the entire model.
SOMs are composed of a grid of nodes that assign a best matching unit (BMU) to each of the input points (in this case, light curves). Then it updates the BMU to move closer to the datapoint at a rate specified by the learning rate and the neighborhood function that controls the updating of the nodes around the BMU. Thus, the entire SOM node is trained on the input data and every datapoint can have a BMU. These BMUs can be clusters themselves or they can be grouped together by density analysis to generate larger but fewer clusters.
Our SOMs are based on the minisom package and follow the same implementation as QNPy. Through the use of SOMs, AttnLNPs and RNNs, we hope to create a multimodal approach to analyzing light curves.
Prediction of Parameters
Similar to Park et. al. 2021, we use the hidden representation of the light curve to infer parameters. We specifically include the ability to reconstructe the transfer function of the quasar, informing us of the properties of the region around the central black hole engine. We do this through attaching an MLP to the model either during training, or on an already trained model and train the model on theoretical transfer functions.
Thus, we are able to not just perform reconstruction of the light curve itself, but also analyze key properties about the system driving the quasar in a purely data-driven manner.
Installation
To install QNPy_Latte, use:
pip install QNPy_Latte
Requirements
Similar to QNPy, we use a requirements.txt file with all the dependencies that need to be satisfied before you can use it as a standalone package. To install all requirements at once, navigate to the directory where you downloaded your package (where the requirements.txt file is) and run:
pip install -r requirements.txt
You are now ready to use the QNPy_Latte package.
Special note 1:
If you have python >3.9 on your local machine you will encounter some requirements conflicts with torch and numpy versions. In this case, we recomend creating a virtual enviroment using conda:
conda create -n myenv python=3.9
then you have to activate the virtual enviroment:
conda activate "The name of your virtual enviroment"
After virtual enviroment is activated you can install QNPy_Latte and the requirements.txt file in your newly created enviroment as described above.
Special note 2:
On windows machines, users have trouble with the pytorch installation. Thus, delete the torch line in the requirements file and install the as described above. Then, install pytorch manually (Choose the command based upon your CUDA/CPU) in your new enviornment:
# CUDA 11.6
pip install torch==1.13.0+cu116 torchvision==0.14.0+cu116 torchaudio==0.13.0 --extra-index-url https://download.pytorch.org/whl/cu116
# CUDA 11.7
pip install torch==1.13.0+cu117 torchvision==0.14.0+cu117 torchaudio==0.13.0 --extra-index-url https://download.pytorch.org/whl/cu117
# CPU only
pip install torch==1.13.0+cpu torchvision==0.14.0+cpu torchaudio==0.13.0 --extra-index-url https://download.pytorch.org/whl/cpu
Tutorial Notebooks and Scripts
The associated GitHub contains tutorial notebooks and scripts that utilize the QNPy package to conduct the clustering and modelling of light curves. Please visit Our GitHub for more.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file qnpy_latte-0.0.1.tar.gz.
File metadata
- Download URL: qnpy_latte-0.0.1.tar.gz
- Upload date:
- Size: 36.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.13.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
9718649d18ad58f03bbde88a3ae1fe06ce401fbb407cf6ea870f9e4eafd424e0
|
|
| MD5 |
ccd322649e2b6a6792cfa505459067c2
|
|
| BLAKE2b-256 |
bad6aaad15d7c54566492fc0f8b6914caf1d91da8780e527cd97f1e30be578da
|
File details
Details for the file QNPy_Latte-0.0.1-py3-none-any.whl.
File metadata
- Download URL: QNPy_Latte-0.0.1-py3-none-any.whl
- Upload date:
- Size: 34.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.13.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
9a5a7f00611f3ef875221464e4aaa813a1efd2ef8dfedca4f2d5f0d71ab8dc6a
|
|
| MD5 |
b198ed2b10964bd263b972a783fbe67d
|
|
| BLAKE2b-256 |
e9eba02a6ba5b3a40df4f25d3e343e61a6006c3f5c225664c553e45568f07154
|