Skip to main content

A PyTorch-based collection of Unsupervised Domain Adaptation methods applied to strong gravitational lenses

Project description

DeepLense Domain Adaptation

A PyTorch-based collection of Unsupervised Domain Adaptation methods applied to strong gravitational lenses!

This project was created for Google Summer of Code 2021 under the Machine Learning for Science (ML4Sci) umbrella organization.

Description

A promising means to identify the nature of dark matter is to study it through dark matter halos, and strong gravitational lenses have seen encouraging results in detecting the existence of dark matter substructure. Unfortunately, there isn't a lot of data of strong gravitational lenses available, which means that, if we want to train a machine learning model to identify the different kinds of dark matter substructure, we'd need to use simulations. The problem though, is that a model trained on simulated data does not generalize well to real data, having a very bad performance. This project aims to fix this problem by using Unsupervised Domain Adaptation (UDA) techniques to adapt a model trained on simulated data to real data!

Blog post

For more about the motivation behind the project and also my Google Summer of Code experience check out this blog post.

Algorithms

There are currently four different UDA algorithms supported:

  • ADDA
  • Self-Ensemble
  • CGDM
  • AdaMatch

There is also a normal supervised training algorithm

Installation

This repo's code can be acessed through the deeplense_domain_adaptation package. To install it simply do:

pip install --upgrade deeplense_domain_adaptation

Data

The data loading pipeline implemented here expects the image data to be in the form of a four dimensional numpy array of shape: (number_of_images, 1, height, width). Label data is expected to have a shape: (number_of_images, 1).

The dataset used for training and inference will be made available as soon as possible! It consists of a source and a target dataset, both were simulated using PyAutoLens according to the following paper: Decoding Dark Matter Substructure without Supervision.

The paper's Model A is our source dataset (less complex simulations) and the paper's Model B is our target dataset (more complex simulations). We have three distinct classes: no dark matter substructure, spherical dark matter substructure and vortex dar matter substructure. On our training sets we have 30'000 images for the source and 30'000 images for the target; in both cases there are 10'000 images per class. On our test sets we have 7'500 images for the source and 7'500 images for the target; in both cases there are 2'500 images per class.

How to use deeplense_domain_adaptation

For a tutorial on how to use the deeplense_domain_adaptation package check out tutorial.ipynb. If the file isn't loading properly on GitHub you can also check the Jupyter Notebook on nbviewer here. For more information on specific functions/classes check out the documentation available on the functions/classes definitions.

Current results (ResNet18 model)

Training on source and testing on target:

  • Accuracy = 0.6326
  • AUROC = 0.8114

After applying UDA algorithms:

Algorithm ADDA Self-Ensemble CGDM AdaMatch
Accuracy 0.8449 0.7480 0.7132 0.7300
AUROC 0.9442 0.8816 0.8931 0.9179

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

deeplense_domain_adaptation-0.1.2.tar.gz (20.8 kB view hashes)

Uploaded Source

Built Distribution

deeplense_domain_adaptation-0.1.2-py3-none-any.whl (29.7 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page