Code Monkey home page Code Monkey logo

svjlucas / vit-for-dark-matter-morphology Goto Github PK

View Code? Open in Web Editor NEW
3.0 2.0 0.0 167.62 MB

Under the international Google Summer of Code program, the project "Transformers for Dark Matter Morphology with Strong Gravitational Lensing" was developed to improve the Machine Learning for Science pipeline using transformers, contributing to both astrophysics and machine learning research.

License: MIT License

Jupyter Notebook 100.00%
artificial-intelligence computer-vision pytorch transformer open-source opencv python google-summer-of-code

vit-for-dark-matter-morphology's Introduction

Vision Transformers (ViT) for Dark Matter Morphology

Google_Summer_of_Code_logo_(2021) svg

The project titled "Vision Transformers (ViT) for Dark Matter Morphology" was conceived and developed as part of the Google Summer of Code initiative. This globally recognized annual program, sponsored by Google, provides a paid opportunity for student developers to engage with and contribute to open-source software projects. The project was carried out in collaboration with Machine Learning for Sciences (ML4SCI), an organization dedicated to integrating machine learning methodologies into scientific research.

Through Google Summer of Code, students are given the chance to work on significant projects during their summer break, all while gaining real-world, hands-on experience in software development and becoming familiar with the dynamics of open-source projects. Participating students are paired with a mentor from their project, fostering a learning environment guided by experienced developers.

In this particular project, I focused on the application of Vision Transformers, a type of machine learning methodology, to the field of dark matter morphology. By skillfully combining traditional physics-based characteristics with state-of-the-art machine learning techniques and metaheuristic optimization, a robust model was developed capable of detecting and analyzing dark matter substructures in images. This project highlights the vast potential that interdisciplinary collaboration holds for advancing both scientific and technological domains.

Transformers (ViT) for Physics

The Transformer design has shown to be very successful for a wide range of NLP applications, leading to its widespread acceptance in the field. In recent years, there has been growing interest in using Transformers for a variety of other applications beyond NLP, including computer vision. At the same time, the use of deep learning techniques in the field of science has become common, with the introduction of Physics-informed neural networks (PINNs). In this context, I use both techniques together, in this project, to find Dark Matter substructures in observations, extracting features of physical meaning from the observations (images) and, then, concatenating them to be process by a Vision Transformer (ViT) neural network.

Image Processing

First, we need to process incoming images. By finding the region of interest (and then the possible observation of dark matter interaction), we can crop out the most important part of the image. When performing a rotation, we also decrease the space of symmetries (since we minimize the rotational symmetry), which turns rotated images into similar images and facilitates model learning.

Finding the Region Of Interest

Feature Engineering

Next, we will take some features induced by physical knowledge of the problem. The area occupied in the observation of the Dark Matter substructure is a characteristic of this substructure, as well as the number of points of greater luminosity. These features have value for model prediction and will be added to the neural network.

Crop and Rotate the ROI (1)

Model Architecture

The final architecture is inspired by the Vision Transformers for Small-Size Datasets, using innovations proposed by this paper, such as the Shifted Patch Tokenization (SPT) layer and Locally Multihead Attention (LMHA), which facilitate the learning of the ViT. The final model was, then, totally implemented in Pytorch.

Cropped, Rotated and Resized the Region of Interest (ROI) (2)

Bayesian Optimization

Since visual transformers are sensitive to some of their hyperparameters, Baysian optimization was performed on some of them. For the proposed transformer in question, the learning rate proved to be of very important optimization, since the transformer could not train

download (20)

Below, find the plot of the negative ROC-AUC of the model versus the number of iterations. We can see that the optimization was effective, when we left a model with ROC-AUC=0.85 (not in the graph) to the final model with ROC-AUC=0.91.

download (19)

Model Performance

After the final training, the Transformer performed with a ROC-AUC of 0.956, a high value, showing the good performance of the technique used, approaching the ideal ROC curve, as can be seen in the graph.

download (21)

These results are impressive and show the power of combining classical features (inspired by physical meaning), Machine Learning and Metaheuristic Optimization.

vit-for-dark-matter-morphology's People

Contributors

svjlucas avatar

Stargazers

 avatar  avatar  avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.