G2Net: Unlocking the Secrets of the Universe

Chirag Samal
9 min readMar 11, 2023

--

Image credit: NASA

Introduction

Do you want to be a part of a groundbreaking discovery in astrophysics and astronomy? Are you looking for a chance to contribute to cutting-edge research and hone your data science skills? If you answered yes to both questions, then the G2Net Detecting Continuous Gravitational Waves Kaggle competition is for you!
In this competition, our goal is to develop a model that can accurately detect and classify long-lasting gravitational-wave signals by rapidly spinningneutron stars within noisy data. By doing so, we can improve the sensitivity of scientists to these signals, potentially leading to new discoveries in the field. This will give us an opportunity to help us achieve this goal and make a significant contribution to the field of astrophysics and astronomy.

In this article, we will explore the problem statement, dataset, and our approach to developing a simple baseline model for this competition. Here, I will provide step-by-step guidance and insights into a basic thought process, allowing you to follow along and potentially develop your own model.
So, are you ready to contribute to groundbreaking discoveries in astrophysics and astronomy?

Context

Continuous gravitational waves are ripples in the fabric of space-time that are caused by the motion of massive celestial objects such as black holes and neutron stars. These waves have been the subject of extensive research in the field of astrophysics, and detecting them is crucial to better understanding the universe. The detection of gravitational waves marked a significant breakthrough in astrophysics and astronomy. Since then, scientists have detected gravitational waves from merging black holes and neutron stars, but a second class of gravitational waves, continuous gravitational waves, remains undetected. Continuous gravitational waves are weak yet long-lasting signals emitted by rapidly spinning neutron stars. Detecting them could enable scientists to learn more about the structure of the most extreme stars in our universe.

The G2Net Detecting Continuous Gravitational Waves Kaggle competition aims to develop a model that is sensitive enough to detect these weak signals within noisy data. In this competition, we aim to create a model that can distinguish between noisy data and the weak but persistent signals emitted by swiftly rotating neutron stars. The task is to detect the presence of a signal in the data given a training set containing time-frequency data from two gravitational-wave interferometers (LIGO Hanford & LIGO Livingston), each data sample with real or simulated noise, and possibly a continuous simulated gravitational-wave signal (CW).

To overcome the challenge of detecting continuous gravitational waves, the G2Net Kaggle competition provides participants with access to a unique dataset of simulated gravitational-wave signals. This dataset has been specifically designed to mimic the noise and signal properties that are expected in real gravitational-wave observations. To improve the accuracy of their models, participants can also use data augmentation techniques such as flipping and shifting the training data to create new samples. The competition aims to create a model that can identify continuous gravitational waves in noisy data and contribute to the ongoing quest to understand the universe.

EDA

Exploratory Data Analysis (EDA) is a crucial step in understanding the G2Net dataset. The first step is to plot the distribution of labels to understand the proportion of data with and without a simulated continuous gravitational wave signal.

The file “target labels.csv” contains the target labels, which are either 0 if there are no gravitational waves present in the data or 1 if there are. (Note the presence of a few files with the suffix -1. The status of these files is currently unknown to physicists.)

Frequency of Labels in the Training Data. Image by the Author

H1 EDA involves exploring the time-frequency data from LIGO Hanford, whereas L1 EDA involves exploring data from LIGO Livingston.

Spectrograms and Fourier Transform can be used to gain insight into the data. A spectrogram is a visual representation of the frequency content of a signal over time. It is obtained by dividing the signal into overlapping frames, computing the Fourier transform of each frame, and plotting the magnitude of the resulting spectrum as a function of time. This allows us to see how the frequency content of the signal changes over time.

The Fourier transform is a mathematical tool that decomposes a signal into its frequency components. It transforms a signal from the time domain to the frequency domain, which allows us to analyze the signal in terms of its constituent frequencies. The Fourier transform of a signal x(t) is defined as:

where F(k) is the frequency-domain representation of f(x) at frequency k, and e^(-2πikx) is the complex exponential at frequency k and time x.

H1 Spectograms. Image by the Author
H1 Fourier Transform. Image by the Author
L1 Spectrogram. Image by the Author
L1 Fourier Transform. Image by the Author

Additionally, TimeStamp and Frequency Analysis can provide more insights into the variations present in the data. TimeStamp Analysis can be used to study how the signal changes over time, while Frequency Analysis can be used to study how the frequency content of the signal changes over time. These analyses can help identify specific patterns or features in the data that may be important for detecting gravitational waves. Understanding these patterns can help in developing effective signal-processing techniques and machine-learning models for the detection of continuous gravitational waves.

TimeStamp Analysis. Image by the Author
Frequency Analysis. Image by the Author

Dataset Description

The dataset for this competition includes time-frequency data from two gravitational-wave interferometers (LIGO Hanford & LIGO Livingston). Each data sample contains real or simulated noise and a simulated continuous gravitational wave signal. Each sample has Short-time Fourier Transforms and GPS time stamps for each interferometer, which are not always contiguous in time. The simulated signals have eight randomized parameters and are characterized by the location, orientation, frequency, and spin-down of the hypothetical astrophysical source. The typical amplitudes of the resulting signals are lower than the detector noise. The data also includes timestamps and frequency data for each sample.

Dataset Structure. Image by Edward Crookenden

Data Augmentation

Data augmentation is a powerful tool for increasing the size of a small dataset, as it allows us to generate new variations of the same data by rotating, flipping, and shifting the input images. By using data augmentation, we can train our model more effectively by providing it with more training examples, which leads to better generalization and improved accuracy. However, it’s essential to ensure that any variation of the image does not violate the physical principles behind the input data.

Here, we will discuss two common data augmentation techniques that we can apply to our SFT images.

1. Horizontal Flipping:

One simple technique is to flip the SFT images horizontally. The intuition behind this technique is that flipping the image horizontally doesn’t change the underlying physics of the signal, but it does add more diversity to our training data.

2. Vertical Shifting:

Another useful technique is to shift the SFT images vertically by a certain number of pixels. The intuition behind this technique is that the location of the signal in the image shouldn’t affect the prediction of our model.

In the context of SFTs, we can use horizontal and vertical flipping to create new images that have the same features as the original but are flipped. This method can help the model learn the features from different angles and improve its performance. Additionally, we can shift the images vertically by a specific number of units to generate a new set of images that have the same features but are slightly different. This technique can help the model learn to detect gravitational waves, even when they are shifted, thus improving the model’s accuracy.

Visualizing Augmented Image. Image by the Author

Baseline Model

In this section, I want to share some insights on the baseline model used for the G2Net challenge. The model is built using TensorFlow and uses a convolutional neural network (CNN) to detect gravitational wave signals in the SFT images. The training data is loaded from a directory containing SFT images in HDF5 format.

Before feeding the images to the model, we preprocess them by applying various transformations such as reshaping, normalization, and augmentation. The CNN model uses EfficientNet B3 as the base model with ‘imagenet’ weights for pretraining. EfficientNet B3 has been shown to perform well on image classification tasks and provides a good starting point for the G2Net challenge.

The input image size is (360, 360) with two channels, and the output shape of the image is (360, 360, 2). We add a dropout layer with a rate of 0.2 to the last layer of the model. The shuffle size for the dataset is set to 128, and the batch size for training is set to 16, while the test batch size is set to 64. The model is trained for 200 epochs with a learning rate of 0.001 using binary cross-entropy loss and the Adam optimizer. The training is stopped early if the validation loss does not improve for ten epochs, which is known as early stopping.

A pictorial representation of the relationship between loss and accuracy over epochs.

The final results show that the model achieves an accuracy of 0.8059 on the training data and 0.7909 on the validation data at epoch 41 out of 200. The loss for training data is 0.4092, while for the validation data, it is 0.4284. We restore the model weights from the end of the best epoch, and the training is stopped at epoch 41 because the validation loss does not improve for ten epochs.

Summary

In conclusion, the G2Net challenge is an exciting opportunity to explore the depths of our universe and detect long-lasting gravitational wave signals. We have explored the data preprocessing and augmentation techniques used in a baseline model for the challenge, which uses TensorFlow and EfficientNet B3 as the base model. Overall, the baseline model provides a solid starting point for the G2Net challenge. However, there is still room for improvement by further tuning the hyperparameters or using more advanced techniques such as transfer learning or ensemble methods.

As we continue to push the boundaries of our knowledge of the universe, the G2Net challenge represents an important step toward detecting and studying continuous gravitational waves. With the power of AI and machine learning, we can uncover the secrets of the universe and further our understanding of the world around us.

You can access the complete code here in this GitHub Repository: Detecting Gravitational Waves

References

As I wrap up this post, I would like to thank all the wonderful people who shared their expertise and knowledge on the G2Net challenge. Without their contributions, this article would not have been possible.

If you’re interested in diving deeper into the G2Net challenge, I highly recommend checking out the following resources:

And, of course, a big shoutout to the creator of the baseline model used in this post, George Chirita, whose code can be found here.

I hope this post has been informative and helpful for those interested in the G2Net challenge. As always, I welcome any suggestions and feedback and look forward to continuing the discussion with you all. Happy learning!

--

--

Chirag Samal

Computer Vision Engineer @ Zeiss | Former Intern @ Stanford University, IISc | Kaggle Master | IIIT-NR