BBH Detection Baseline
This section provides a guide to the Binary Black Hole (BBH) detection baseline. It utilizes a Deep Learning approach—specifically a Convolutional Neural Network (CNN) implemented in PyTorch—to identify gravitational wave signals from merging black holes within noisy detector data.
Overview
The detection baseline is designed to handle the end-to-end pipeline of gravitational wave analysis:
- Data Generation: Simulating realistic BBH waveforms and injecting them into modeled detector noise.
- Preprocessing: Applying windows and frequency-domain transformations.
- Signal Detection: Using a deep CNN to classify time-series segments as "Signal + Noise" or "Noise Only."
Data Preparation and Generation
The baseline uses the DatasetGenerator class to create synthetic training data on the fly. It leverages LALSimulation to generate waveforms based on astrophysical parameters.
DatasetGenerator
The DatasetGenerator implements the PyTorch Dataset interface, making it compatible with standard DataLoaders.
from main import DatasetGenerator
# Initialize the generator
dataset = DatasetGenerator(
fs=8192, # Sampling frequency (Hz)
T=1, # Observation duration (seconds)
snr=20, # Target Signal-to-Noise Ratio
detectors=['H1', 'L1'], # Detectors to simulate (e.g., Hanford, Livingston)
nsample_perepoch=100 # Number of samples to generate per epoch
)
Key Parameters:
fs: The sampling rate. High-frequency resolution is critical for capturing merger details.T: The time window length.snr: Controls the difficulty of the detection task by scaling the signal amplitude relative to the noise.mdist: The mass distribution model (astro,gh, ormetric).
Model Architecture
The baseline model, MyNet, is a deep Convolutional Neural Network optimized for time-series pattern recognition. Although it uses Conv2d layers, it effectively performs 1D convolutions across the time dimension for multiple detector channels.
Architecture Highlights
- 8 Convolutional Stages: Each stage includes a Convolutional layer, ELU activation, and Batch Normalization.
- Downsampling: Strategic Max-Pooling layers reduce the temporal dimensionality while extracting high-level features.
- Fully Connected Head: A flattened layer followed by two dense layers to output the detection probability.
from main import MyNet
# Instantiate the model
model = MyNet()
# Basic structure overview
print(model)
Training and Evaluation
The training process involves iterating through simulated batches where the model learns to distinguish between pure Gaussian noise and noise containing a BBH chirp signal.
Monitoring with Utilities
The project includes several utility classes in utils.py to monitor the training process:
Animator: Provides real-time plotting of loss and accuracy within Jupyter notebooks.Accumulator: Sums up metrics over multiple batches for precise epoch-level reporting.Timer: Benchmarks the computational efficiency of the training loop.
Basic Training Loop Example
import torch
from torch.utils.data import DataLoader
# Setup data and model
train_set = DatasetGenerator(nsample_perepoch=1000)
train_loader = DataLoader(train_set, batch_size=32, shuffle=True)
model = MyNet().to('cuda')
optimizer = torch.optim.Adam(model.parameters(), lr=0.001)
criterion = torch.nn.CrossEntropyLoss()
# Training iteration
for epoch in range(10):
for X, y in train_loader:
X, y = X.to('cuda'), y.to('cuda')
pred = model(X)
loss = criterion(pred, y)
optimizer.zero_grad()
loss.backward()
optimizer.step()
Performance Visualization
The baseline includes scripts to generate a "Sugon" report (via baseline_sugon.html), which visualizes:
- Waveform Injections: How the signal looks when buried in noise.
- Loss Curves: The convergence behavior of the CNN.
- Detection Statistics: Accuracy and False Alarm Rate (FAR) metrics.
To view these results, navigate to the 2023/deep_learning/baseline/ directory and open the provided HTML summaries in your browser.