This repository contains the implementation of two models for classifying images of gravitational lenses using PyTorch. The first model employs a standard ResNet-18 architecture, while the second model enhances the ResNet-18 with a physics-informed neural network (PINN) that incorporates the gravitational lensing equation.
NOTE: You can find the detailed implementation of Self-supervised learning in this repo: SSL_results
Build a model for classifying images into lenses using PyTorch or Keras. The model should be trained and validated using a suitable approach to achieve high accuracy.
I utilized ResNet-18 for this task due to its ability to capture intricate patterns and features in the data, leading to better generalization and higher accuracy. The model was trained using 5-fold cross-validation, with each fold consisting of 5 epochs on a dataset of 30,000 training images and 7,500 test images.
The model achieved an ROC-AUC score of 0.99 on the test data.
You can find the detailed implementation and results of this approach in the following Jupyter notebook: ResNet-18 Approach
Build a model for classifying images into lenses using PyTorch or Keras. The architecture should take the form of a physics-informed neural network (PINN) that incorporates the gravitational lensing equation to improve network performance over the common test results.
For classifying gravitational lenses into three types (no lensing, vortex, and halo substructure), I incorporated the lens equation, which describes how light is bent by the gravitational field of a massive object. The mass distribution of the lensing object is assumed to follow a Singular Isothermal Sphere (SIS) model, with a proportionality parameter ( k ) to correct potential distortions.
-
Define the lens equation: β=θ−α where β is the apparent position of the source, θ is the observed position, and α is the deflection angle.
-
Incorporate the mass distribution due to galaxies and dark matter: β+cX=θ−kr^2
-
Utilize feature vectors θ and k from ResNet-18.
-
Apply three neural layers on the resulting vector to extract features for lens classification.
The model achieved an ROC-AUC score of 0.92 on the test data.
You can find the detailed implementation and results of this approach in the following Jupyter notebook: PINN Approach 1
In this approach, the original image vector I represents θ. Another feature vector k from ResNet-18 is used as follows: C=I−B(features)⋅r^2 A concatenated feature vector D is formed from another ResNet-18 feature vector A features and C . This vector is then processed through three neural layers to classify the lenses.
You can find the detailed implementation and results of this approach in the following Jupyter notebook: PINN Approach 2

