Cross-Temporal Spectrogram Autoencoder (CTSAE): Unsupervised Dimensionality Reduction for Clustering Gravitational Wave Glitches
Yi Li Yunan Wu Aggelos K. Katsaggelos

Casimir energy on the sphere and 6D CFT trace anomaly
    R Aros^1, F Bugini^2, DE Díaz^3 and C Núñez-Barra^4
    
=======================================================


The advancement of The Laser Interferometer Gravitational-Wave Observatory (LIGO) has significantly enhanced the feasibility and reliability of gravitational wave detection. However, LIGO's high sensitivity makes it susceptible to transient noises known as glitches, which necessitate effective differentiation from real gravitational wave signals. Traditional approaches predominantly employ fully supervised or semi-supervised algorithms for the task of glitch classification and clustering. In the future task of identifying and classifying glitches across main and auxiliary channels, it is impractical to build a dataset with manually labeled ground-truth. In addition, the patterns of glitches can vary with time, generating new glitches without manual labels. In response to this challenge, we introduce the Cross-Temporal Spectrogram Autoencoder (CTSAE), a pioneering unsupervised method for the dimensionality reduction and clustering of gravitational wave glitches. CTSAE integrates a novel four-branch autoencoder with a hybrid of Convolutional Neural Networks (CNN) and Vision Transformers (ViT). To further extract features across multi-branches, we introduce a novel multi-branch fusion method using the CLS (Class) token. Our model, trained and evaluated on the GravitySpy O3 dataset on the main channel, demonstrates superior performance in clustering tasks when compared to state-of-the-art semi-supervised learning methods. To the best of our knowledge, CTSAE represents the first unsupervised approach tailored specifically for clustering LIGO data, marking a significant step forward in the field of gravitational wave research. The code of this paper is available at https://github.com/Zod-L/CTSAEhttps://github.com/Zod-L/CTSAE
    





§ INTRODUCTION


The detection of gravitational waves has revolutionized our cosmic exploration by opening a new window into the universe. The Laser Interferometer Gravitational-Wave Observatory (LIGO) marked a milestone by confirming these spacetime ripples for the first time in September 2015 <cit.>. These groundbreaking observations are contingent upon highly sensitive detection systems capable of distinguishing the faintest spacetime fluctuations amidst a myriad of environmental and instrumental noises <cit.>. Among these, non-Gaussian noise bursts, or glitches, present significant challenges to the clarity and reliability of gravitational wave detections <cit.>. The Gravity Spy dataset comprises time-frequency spectrograms capturing the characteristics of glitches. Each glitch instance consists of four frequency spectrograms with distinct time windows: 0.5 s, 1.0 s, 2.0 s, and 4.0 s. An example of glitch spectrograms is shown in <ref>.





To address this challenge, the Gravity Spy project combines volunteer efforts and machine learning to categorize the glitches in LIGO's time-series data <cit.>. Despite the project's success in glitch classification, a notable gap remains in identifying and classifying glitches across the main channel and auxiliary channels monitored by LIGO detectors <cit.>, which is essential for understanding the causal relations between these channels. Given the infeasibility of labeling data from all channels in the future GravitySpy 2.0 dataset, we propose an unsupervised learning model, called CTSAE, to uncover the underlying correlations between different glitches. This method aims to enhance the glitch identification process and the accuracy of gravitational wave detections, thereby advancing the frontier of space technology and exploration. Since the GravitySpy O4 dataset on the main and auxiliary channels is still under the early stage of construction, we apply CTSAE to the GravitySpy O3 dataset on the main channel where only main channel glitches are involved to evaluate the cluster performance. The contribution of our paper is as follows: 


  * We develop a novel four-branch autoencoder that integrates CNN and ViT to process glitches across four different time window durations, facilitating spatial feature extraction of glitch characteristics.


  * We introduce a novel CLS fusion module designed for effective inter-branch communication, enabling the extraction of temporal glitch features by capturing dynamic changes over time.


  * CTSAE is the first method to cluster gravitational wave glitches in an unsupervised learning manner, achieving superior performance over existing semi-supervised methods deployed by Gravity Spy that rely on partial training labels.







§ RELATED WORK
 

Deep Learning-Based Approaches for Glitch Classification and Clustering
Deep learning methods <cit.> have been widely used for classifying and clustering glitches. For instance, Coughlin  <cit.> demonstrated the effectiveness of utilizing the VGG16 architecture <cit.> for glitch classification tasks. Later on, Wu  <cit.> introduced a multi-view fusion model, combined with an attention mechanism to improve the glitch classification performance. 

They both extended their works to the clustering task by leveraging their models as feature extractors, facilitating the clustering of unidentified classes.

In DIRECT <cit.>, a contrastive learning framework was established to train a deep feature extraction model, utilizing true class labels to improve its learning efficacy.

Similarly, Bahaadini  <cit.> explored a semi-supervised learning approach, where a virtual adversarial model was developed and trained with a mixture of labeled and unlabeled data.

Regarding the task of glitch classification and clustering, existing works primarily focus on models trained under conditions of full supervision or semi-supervision, necessitating the use of pre-labeled glitch data. To the best of our knowledge, our work is the first unsupervised learning method for clustering LIGO glitches. 
 

Autoencoder-based Self-supervised Dimensionality Reduction
Typically, to reduce computational cost and remove irrelevant information, high-resolution images are reduced to a low-dimensional space before undergoing clustering. Traditional approaches to image dimensionality reduction largely rely on shallow machine learning algorithms, such as Principal Component Analysis (PCA). However, with the rapid development of deep learning over recent years, deep neural networks have been introduced for dimensionality reduction in a self-supervision manner. Autoencoder (AE) <cit.> stands out as a prominent self-supervised algorithm widely used for both dimensionality reduction and representation learning. Despite its simplicity in implementation and training, AE is prone to overfitting, especially with limited training data. To avoid the issue of merely copying the input without capturing high-level features, several variants of AE <cit.> are proposed. A common strategy to mitigate overfitting is data augmentation <cit.>. For instance, denoising autoencoder <cit.> augments training data by introducing random noise to the input image, with the AE then trained to remove this added noise. Zhang  <cit.> introduced input corruption by removing color channels while Pathak  <cit.> proposed a context encoder that was trained by the inpainting of randomly masked images. He  <cit.> achieved state-of-the-art performance in feature extraction by masking random image patches and reconstructing on the unmasked patches. In tasks related to clustering and representation learning, it is important to model the similarity and dissimilarity between images. Contrastive learning <cit.> aims to learn representations that bring similar images closer together in the feature space while keeping dissimilar ones apart. It leverages data augmentation to generate positive samples in the absence of ground truth class labels. While these methods are effective in extracting high-level features from images, they predominantly rely on data augmentation, which is not suitable for our Gravity Spy dataset. Augmenting glitch spectrograms can significantly distort their physical semantics. Therefore, we choose to use a standard AE framework in this work.

Combining CNN and ViT for Enhanced Feature Extraction
Recent advancements have been seen in the combinations of CNN and ViT, yielding great success across different tasks. Such combinations excel at capturing both global and local features, which is critical for effective unsupervised clustering. Previous studies have shown the benefits of both sequential <cit.> and parallel structures <cit.> in combining the convolutional and transformer-based methods. Srinivas  <cit.> improved the performance of instance segmentation and object detection by replacing the last three CNN bottleneck blocks in ResNet <cit.> with self-attention mechanisms. d’Ascoli  <cit.> proposed a gated positional self-attention (GPSA) layer with a “soft” convolutional inductive bias where each self-attention layer decides whether to behave as a convolutional layer based on the context. In the LeViT model <cit.>, the initial patchification process is replaced with a compact CNN encoder. While these sequential combinations have achieved substantial improvements, they do not possess an advantage for information exchange within the CNN part of the multi-branch structures due to feature unalignment problems. In terms of parallel structures, Peng  <cit.> introduced Conformer for image classification, featuring separate convolution and transformer branches linked via Feature Coupling Units (FCU). Moreover, Chen  <cit.> designed a lightweight Mobile-Former, which establishes a bidirectional connection between the MobileNet <cit.> and transformer branches. Aiming to capture high-level features across glitches from all four time-window durations, our work aligns with the parallel structure  <cit.>, which we expand into a four-branch autoencoder. This improved model effectively addresses the global-local feature fusion from convolutions and transformers problem.




§ METHOD




To construct a latent space that is simultaneously smooth, discriminative, and low-dimensional, we introduce a multi-branch AE to extract high-level features from glitch spectrograms. Our CTSAE model leverages the CNN-ViT blocks <cit.>, combining convolution and vision transformer <cit.> to effectively capture both global and local glitch features. The distinct branches of CTSAE are interconnected through an innovative fusion strategy we have developed. 



 §.§ Overview

 In the context of unsupervised learning algorithms, distinguishing glitch spectrograms from different classes presents a significant challenge, especially when they exhibit similar patterns across specific timescales. To effectively distinguish those closely similar classes, features from different timescales should be analyzed. Given that the Gravity Spy project generates glitches in four different time window durations, we propose CTSAE, a four-branch AE for feature extractions, as illustrated in <ref>. Our model processes an input glitch composed of four spectrograms, each representing a different duration, denoted as I_0.5,I_1.0,I_2.0,I_4.0. These four spectrograms are parallelly fed into four CNN-ViT encoders E_i, which compresses them into a lower-dimensional vector z_i in the latent space following:

    z_i = E_i(I_i)    ∀ i ∈{0.5, 1.0, 2.0, 4.0}.


 Interconnectivity between four encoders is achieved via a shared CLS token, a learnable parameter, facilitated by CLS Fusion modules.
 
 
 These vectors are then fed into a fully connected layer, producing an output z, which is subsequently concatenated with the shared CLS token x_cls to form the latent code ẑ. The process can be formulated as follows:


    z = [z_0.5 |  z_1.0 |  z_2.0 |  z_4.0]W_1^T + b_1,




    ẑ = [z  | x_cls]W_2^T + b_2,



where W_1, b_1, W_2 and b_2, are parameters of the fully connected layers. Finally, the latent code ẑ is decoded by the four-branch decoder D_i to reconstruct the spectrograms Î_̂î in four time durations.


    Î_̂î = D_i(ẑ)   ∀ i ∈{0.5, 1.0, 2.0, 4.0}.


 The reconstructed spectrograms Î_̂î, along with the original inputs I_i are used to compute the reconstruction loss, which is defined as follows:

 
    L = ∑_i=0.5,1.0,2.0,4.0L_mse(I_i, Î_̂î)


where L_mse represents the mean square error loss. The decoders are discarded during inference and glitches are clustered using the low-dimensional latent code ẑ.

 




 §.§ CNN-ViT Encoder/Decoder

For unsupervised clustering of glitches, integrating both global and local features is crucial for effectively distinguishing between different types of glitches. To this end, we employ an encoder and decoder architecture based on CNN and ViT to construct our multi-branch AE. Specifically, our encoders and decoders utilize CNN-ViT blocks, each comprised of two ResNet bottleneck layers, a self-attention module, along with downsampling and upsampling modules, as depicted in <ref>. The CNN component adheres to a standard encoder-decoder configuration. Throughout the encoding phase, the resolution of feature maps is progressively halved, while their channel dimension is expanded at each subsequent layer. Conversely, the decoding phase mirrors the encoding process, employing transposed convolution to upsample the feature maps, thus restoring their original image size. The encoded local information from the CNN module is fed to the attention module via a downsampling process, as illustrated in <ref> (b). A 1×1 convolution is applied first to align the CNN features with the attention tokens. This step transforms the feature map dimensions from shape (N× C × H × W) to (N× K × H × W), where N, H, W, C, K are the batch size, image height, image width, number of channels in the CNN features, and the embedding size of the self-attention module, respectively. The aligned feature map is then downsampled by an average pooling, followed by a vector flatten operation and a normalization layer. Patch tokens should maintain the same receptive field as the network forward, hence, the stride of downsampling is decreased by half as the resolution of feature maps halves. The downsampled output, denoted as x_d, is then combined with the patch token x_t from the self-attention module, following:



    x̂_̂t̂ = x_d + x_t,



    y_t = attn(x̂_̂t̂).



where attn represents the self-attention layer. The output y_t is upsampled (<ref> (c)) and then fed back to the CNN module, which can provide global contextual information, enriching the local feature map x_c through addition:


    x̂_̂ĉ = y_t + x_c,



    y_c = fuse(x̂_̂ĉ).


where fuse is a ResNet bottleneck layer fusing the local feature map x_c and the globally upsampled output y_t. 
 






 §.§ CLS Fusion Module

To effectively capture features across multiple time-window durations, it's crucial to facilitate information exchange between the branches of our model. A straightforward way is to concatenate the patch tokens from all four branches and apply self-attention across the aggregated tokens. However, this approach is impractical for our purpose because glitch spectrograms from different durations do not exhibit spatial alignment, rendering most cross-branch patch pairs irrelevant. Incorporating these pairs not only significantly increases computational demands but also introduces noise into the model. To address these potential issues, we introduce an innovative fusion technique centered around the use of a shared CLS token, which acts as a mediator for inter-branch communication, as depicted in <ref>. Specifically, this process begins with the CLS token x_cls functioning as the query in interactions with patch tokens x_i from each branch:

    Q = x_clsW_q^T + b_q,



    K = [x_cls |  x_0.5 |  x_1.0 |  x_2.0 |  x_4.0]W_k^T + b_k,



    V = [x_cls |  x_0.5 |  x_1.0 |  x_2.0 |  x_4.0]W_v^T + b_v,




    x̂_̂t̂ = softmax(QK^T/√(d_k))V,



    x_t = x_t + x̂_̂t̂.





where d_k denotes the embedding dimension for the query token Q. The updated CLS token is concatenated with the patch tokens from each branch for the subsequent standard self-attention processing. The use of shared attention weights W_q,b_q,w_k,b_k,w_v,b_v is applied to all branches as well as the CLS fusion process to ensure consistent parameters in mediating interactions. Notably, employing a shared CLS token enables branches to extract more discriminative features of glitches by considering global context without being overwhelmed by irrelevant local patch details. Furthermore, the use of common attention weights fosters a form of soft interconnection among branches, enhancing the model's ability to integrate and differentiate multi-duration features effectively.















§ EXPERIMENTS



 §.§ Setup

Dataset Our study focuses on the GravitySpy O3 dataset on the main channel <cit.>. We sample 41745 glitches categorized into 23 different classes from the full dataset, collecting data from both Hanford and Livingston detectors. The detailed distribution of each class is shown in <ref>. As you can see, this dataset has a complicated distribution with higher intra-class and inter-class variance, which poses a greater challenge for the clustering task. For the purpose of training and evaluation, we pick 70% of the data for training and 10% for validation and the remaining 20% of data for testing. Notably, the class labels here are not used for model training but only for evaluating the clustering performance. 

Evaluation Metrics To assess the performance of our unsupervised clustering algorithm, we adopt two standard metrics: normalized mutual information (NMI) and adjustable rand index (ARI), as described in <cit.>. NMI is defined as:

    NMI(Z; Ẑ) = I(Z; Ẑ)/√(H(Z)×Ẑ)×


where Z and Ẑ denote the ground-truth cluster and the predicted cluster, and I and H represent mutual information and entropy, respectively. NMI measures the mutual dependence between the predicted and the ground truth distributions, with its values normalized within the range [0, 1]. A higher NMI value indicates a stronger correlation between these distributions. Additionally, we use ARI to quantify the similarity between the ground truth and predicted clusters. ARI adjusts the Rand index RI, a metric that calculates the proportion of sample pairs correctly grouped together or apart in the same or different clusters, respectively:



    RI = C_1 + C_2/n2



where n is the total number of samples, C_1 is the count of sample pairs correctly placed in the same cluster according to both the ground truth and prediction, and C_2 is the count of sample pairs correctly separated into different clusters by both. ARI is then adjusted and defined as:



    ARI = RI - E(RI)/max(RI) - E(RI)




where E(RI),max(RI) are the expectation and maximum of RI, respectively, and -1 ≤ ARI ≤ 1.  A higher ARI score indicates greater concordance between the clustering assignments.







0.3pt
100











 §.§ Implementation Detail

Before being fed into the model, all spectrograms undergo a standard preprocessing where they are normalized to the range of [-1, 1] and resized from dimensions of 480x575 to 224x224 pixels. Our CTSAE architecture incorporates 13 CNN-ViT blocks to construct both encoders and decoders components. The encoder is organized into four parts. First, a single CNN-ViT block converts the input spectrogram into feature maps and patch tokens. The rest three parts each contain three blocks, where the second and third parts reduce the feature maps from 224x224 to 112x112, and then further down to 56x56, respectively. The last part downsamples the feature maps twice, resulting in an output in 14x14. These feature maps are finally pooled to 4x4, which are then flattened to form the latent codes z_i, as mentioned in <ref>. The decoder mirrors the encoder's structure but inverts the downsampling process with upsampling transposed convolutions, ensuring a symmetrical architecture. In the encoding phase, an embedding size of 384 is used for the self-attention components. Following <cit.>, the decoder is designed to be more compact, with a reduced embedding size of 192 to optimize computational efficiency. Our model's training was executed on 8 Tesla V100 GPUs, requiring approximately 4 days to complete 200 epochs. All experiments are conducted on our validation and testing dataset. The selection of the optimal model was based on its performance on the validation set. K-Means algorithm is utilized to cluster the extracted latent codes and the random seed is fixed for a fair comparison.





 §.§ Comparison

As we are the first in applying unsupervised learning to the task of glitches clustering, we benchmark our proposed method against existing semi-supervised clustering methods <cit.>. Results are shown in <ref>. We first compare our method with DIRECT <cit.> which is currently deployed to the official GravitySpy pipeline to find new glitch classes. We utilize its most recent version of checkpoints for a direct comparison on our same test set. Our approach outperforms DIRECT by a large margin even in the absence of supervision, suggesting that our unsupervised approach has the potential to substantially enhance the LIGO glitch identification process upon implementation. Furthermore, we compare our method with the state-of-the-art clustering algorithm, virtual adversarial training (VAT), on the GravitySpy data <cit.>. We reproduce the VAT model <cit.> and experiment with VAT under various ratios of labeled to unlabeled data. We observe that while our model does not exceed the performance of VAT trained with 5% labeled and 95% unlabeled data, it presents considerable improvements over VAT configured with 1% labeled data. Notably, VAT still needs labeled dataset while our method is fully unsupervised. Given the upcoming tasks on the GravitySpy O4 dataset on the main and auxiliary channels, i.e., to find correlations between main channel glitches and auxiliary channel glitches, which will contain significantly less than 1% labeled data, we anticipate our model to set new benchmarks in clustering glitches sourced from the GravitySpy O4 dataset on the main and auxiliary channels.





 §.§ Ablation Study


The Multi-branch Architecture
We begin with examining the necessity of incorporating glitch spectrograms acorss all four durations in our analysis. This is assessed by comparing the performance of our multi-branch architecture, which utilizes spectrograms from all four durations, against a single-branch architecture that processes only 4.0 s duration spectrograms. To make a fair comparison, the architecture of the single-branch model mirrors that of each individual branch within our proposed multi-branch framework. As is shown in <ref>, the multi-branch model demonstrates superior performance relative to its single-branch counterpart. This discrepancy in performance can be attributed to the fact that glitches, even when belonging to distinct classes, may exhibit similar patterns within a singular time duration. Such similarities obscure clear class distinctions, which can be effectively resolved only by aggregating and analyzing data across all four time durations. Therefore, extracting features from all four time-window durations achieves a more comprehensive understanding and accurate clustering of glitches.



CNN-ViT We further assess the effectiveness of the CNN-ViT hybrid block in comparison to the CNN-only block and the ViT-only block. To avoid the impact of different multi-branch fusion strategies, this evaluation is conducted using single-branch autoencoder models. The CNN-only and ViT-only configurations are derived by omitting the complementary component from the CNN-ViT block, resulting in three distinct single-branch autoencoders, each built upon the same architectural framework but differing in their foundational blocks. All AEs are trained and tested on the data with only 4.0 s spectrograms. For the models based on CNN and CNN-ViT, the encoder outputs are encoded into low-dimensional latent vectors. Conversely, in the ViT-based model, the encoder's embedding tokens, inclusive of the CLS token, proceed through several fully connected layers before being fed into the decoder, with the CLS token being specifically leveraged for clustering in the test phase as described in <cit.>. 

As shown in <ref>, the ViT-only model exhibits the lowest performance, a phenomenon potentially linked to inadequate constraints applied to the CLS token. In the context of the Masked AE <cit.>, the CLS token will further undergo additional fine-tuning for clustering tasks, forcing the CLS token to encode critical global information. However, in unsupervised settings, there lacks a direct mechanism to ensure the CLS token aggregately represents global features, rendering a solely ViT-based autoencoder less effective for unsupervised learning tasks due to its inherent characteristics.

Moreover, the CNN-ViT hybrid model outperforms the CNN-based model in both NMI and ARI metrics, indicating that the inclusion of a ViT branch facilitates superior global information capture and, consequently, enhances overall performance. An additional benefit of integrating attention mechanisms within this setup is the facilitation of efficient information fusion across branches, achieved through our proposed CLS Fusion module.




CLS Fusion Module
Finally, we investigate various multi-branch fusion schemes, including methods with No Fusion, the All-attention as outline in Sec.3.3, and our proposed CLS Fusion module. As shown in <ref>, both fusion strategies achieve superior ARI and NMI scores compared to the model without any fusion. This again affirms the critical role of cross-branch interaction for enhanced clustering outcomes. Compared with the All-attention approach, our CLS Fusion module obtains a better performance while reducing the computation complexity. This superiority can be attributed to two primary factors. Firstly, our CLS Fusion module forces the CLS token to communicate with tokens from all branches before per-branch self-attention. As discussed in the CNN-ViT context, imposing such a communicative constraint is advantageous for clustering activities. Besides, while the All-attention approach considers the correlation between each pair of tokens across all branches, it tends to generate an excess of redundant correlations. For instance, the majority of patches within 4.0 s spectrograms lie beyond the coverage of those in 0.5 s spectrograms, potentially introducing irrelevant noise to the refined features discerned from shorter duration spectrograms. Our CLS Fusion strategy mitigates this issue by channeling all cross-branch communications through the CLS token, thereby restricting interactions to within individual branches and effectively eliminating redundancy.




 §.§ Reconstruction Results

We also present the reconstruction results of our CTSAE model. As shown in <ref>, our CTSAE also achieves the lowest reconstruction error among the compared models, suggesting its superior capability in capturing and accurately encoding the spectral information of glitches. <ref> illustrates that the reconstructed spectrograms effectively retain the integral structure of the glitches, significantly reducing background noise in the process. This fidelity in reconstruction not only demonstrates the effectiveness of CTSAE in encoding relevant information but also opens avenues for future research. We aim to explore the potential of CTSAE to generate glitch spectrograms that preserve their physical semantics without compromise, effectively solving the issue of imbalanced classes shown in <ref>. 









§ CONCLUSION

In this paper, we propose CTSAE, the first unsupervised model designed for dimensionality reduction and clustering of gravitational wave glitches. By integrating CNNs with ViTs, we develop a multi-branch autoencoder, enhanced with a novel inter-branch CLS fusion module. This model has been trained on the Gravity Spy 1.0 dataset. During inference, multi-duration glitch spectrograms are encoded into a low-dimensional latent space via encoders, facilitating the clustering of glitches within the test set. Experiments show that our CTSAE model outperforms the existing state-of-the-art semi-supervised methods even without reliance on any labeled data. In the future, we aim to extend our research to the Gravity Spy 2.0 dataset, which promises richer cosmic signal data from both main and auxiliary channels. Given the ongoing development and current lack of manual labeling in Gravity Spy 2.0, we plan to deploy our CTSAE model to this newer dataset and investigate enhancements, particularly incorporating conditions related to characteristics of LIGO instruments and sensors.




§ ACKNOWLEDGEMENT

The authors wish to express their sincere gratitude to the community-science volunteers of the Gravity Spy project. We also extend our thanks to ManLeong Chan for his insightful comments that significantly enhanced the quality of this manuscript. Furthermore, this work was supported by the NSF's LIGO Laboratory, a major facility fully funded by the National Science Foundation.

    ieeenat_fullname
    





