{'fraction_non_alphanumeric': 0.03277884315212059, 'fraction_numerical': 0.009409980823261829, 'mean_word_length': 4.617234468937876, 'pattern_counts': {'":': 0, '<': 1, '<?xml version=': 0, '>': 0, 'https://': 2, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
VNIbCReg: VICReg with Neighboring-Invariance and better-Covariance Evaluated on Non-stationary Seismic Signal Time Series

One of the latest self-supervised learning (SSL) methods, VICReg, showed a great performance both in the linear evaluation and the fine-tuning evaluation. However, VICReg is proposed in computer vision and it learns by pulling representations of random crops of an image while maintaining the representation space by the variance and covariance loss. However, VICReg would be ineffective on non-stationary time series where different parts/crops of input should be differently encoded to consider the non-stationarity. Another recent SSL proposal, Temporal Neighborhood Coding (TNC) is effective for encoding non-stationary time series. This study shows that a combination of a VICReg-style method and TNC is very effective for SSL on non-stationary time series, where a non-stationary seismic signal time series is used as an evaluation dataset.


Introduction
The recent mainstream SSL frameworks can be divided into two main categories: 1) contrastive learning, 2) noncontrastive learning. Some well-known contrastive learning methods are MoCo [2] and SimCLR [3]. In those methods, there are a reference sample, a positive sample, and a negative sample. The reference and positive samples form a positive pair, and the reference and negative samples form a negative pair. Then, those contrastive methods learn representations by pulling the representations of the positive pairs together and pushing those of the negative pairs apart. However, these methods require a large number of negative pairs per positive pair to learn representations effectively. To eliminate the need for negative pairs, non-contrastive learning methods such as BYOL [4], SimSiam [5], Barlow Twins [6], VICReg [7], and VIbCReg [8] have been proposed. The non-contrastive learning methods use positive pairs only, and training of the networks could be simplified. The non-contrastive learning methods were able to outperform the existing contrastive learning methods in terms of quality of learned representations. In particular, VICReg and VIbCReg outperform other competing SSL methods by having effective feature decorrelation.
Temporal Neighborhood Coding (TNC) [9] is another recent SSL method to learn representations for non-stationary time series. It learns time series representations by ensuring that a distribution of signals from the same neighborhood is distinguishable from a distribution of non-neighboring signals. It was developed to address time series in the medical field, where modeling the dynamic nature of time series data is important.
Simplified illustrations of the introduced SSL methods are presented in Fig. 1. It should be noted that time series or spectrogram can be used as an input instead of an image while the entire methodological framework remains intact.
Also, an overview of the TNC framework is presented in Fig. 2. While the figure shows time series as input, it should be noted that spectrograms can be used as input instead of time series, which is the case in our study. Figure 1: Simplified illustrations of SSL methods. grad denotes gradient and similarity denotes similarity between two output vectors from two encoders that share their weights and the similarity is optimized to be reduced between the two augmented images. The dash lines indicate the gradient propagation flow. Therefore, the lack of a dash line denotes stop-gradient. Figure 2: Overview of the TNC framework components. Enc, z, and D denote an encoder, representation, and a discriminator, where the discriminator is a shallow neural network for binary classification. TNC encodes the distinguishable distributions between neighboring samples and non-neighboring samples by training the discriminator predict 1 for representations of neighboring samples (denoted as z t and z l ) and 0 for representations of non-neighboring samples (denoted as z t and z k ).
In this study, VNIbCReg (Variance Neighboring-Invariance better-Covariance Regularization) is proposed. It can be viewed as a combination of a VICReg-style method and TNC with neighboring-invariance and better-covariance. It is shown to be effective in learning quality representations on non-stationary time series. In particular, VIbCReg is used instead of VICReg as VIbCReg was shown to be more effective than VICReg on time series. The evaluation is conducted by the linear evaluation and the fine-tuning evaluation on small subsets of the training set. As for the dataset, non-stationary seismic signal time series is used. A detailed description about the dataset is presented in the following section.
The source code is available at https://github.com/ML4ITS/Aknes_clf. The used dataset, called Åknes dataset, is included in the source code, but can also be found at https://bit.ly/3EZkthW. For the Åknes dataset, events were classified by visual inspection of a large number of waveforms recorded in different years, and proper labelling was ensured by cross-checking with a reviewed seismic bulletin [10]. Therefore, this dataset is encouraged to be used as a benchmark dataset so that different classification methods can be developed and fairly compared to each other.

Background on the Dataset and Dataset Description
The data is obtained from an Åknes rock slope. The Åknes rock slope is located south of Stranda in Western Norway, see Figure 3, by the fjord going in to Hellesylt and Geiranger. The steep slope goes from the fjord up to nearly  [11]. The unstable area is highlighted by the red shade.
1500 m altitude. The unstable rock slope is limited by strike-slip faults to the North-East and South-West, and a fracture/backscarp as the upper limit. The upper fracture has lately been widening at about 2 cm per year, and this has caused concern about rock fall geohazards.
The risk-prone rock slope volume is up to 50 million m 3 . Even though three dimensional numerical modeling of the slope has been conducted [12], it has shown difficult to map the subsurface properties of the slope due to large heterogeneities in the subsurface seismic velocity model. There are hence large uncertainties associated with the unstable volume, and how it will collapse into the fjord. But even with a much smaller volume, rock collapse would create a tsunami with severe impacts on the local communities [13], particularly considering its location in the narrow Norwegian fjords. The natural beauty of this fjord region has made it a UNESCO World Heritage Site. The area attracts nearly a million tourists per year and about 200 cruise ships pass by the Åknes rock slope every year.
Because of the widening of the upper crack at Åknes, the rock slope has been extensively monitored for several years. In these efforts one has gathered different data sources such as surface crack displacements sensors [14] and the displacements connections to meteorological data [15], InSAR data [16] and seismic geophone data [17]. Here, the focus is mainly on the geophone data.
Altogether, there are eight geophones in the slope, each of them with three-component sensors. The geophone data passively register seismic activity at Åknes. The data are streamed to a computer server and this hence provides a continuous-time monitoring system for detecting potential rock fall or movements on the rock slope. When there is a seismic signal above a pre-specified amplitude threshold, a window of 16 seconds of geophone data is stored. Based on expert opinion, every event is then classified into one of eight classes, as described in Table 1. Each of these classes present specific characteristics and are likely associated with different physical mechanisms either directly involved in the movement of the rockslope or occurring farther away. Discussing these processes is out of the scope of this work, but more details can be found in [18]. There is by now a rich database of geophone observations and associated rock fall class interpretation for various seismic events at Åknes [18]. This provides an excellent test case to understand and try out new machine learning methods for classifying rock slope events, and by building a reliable encoder and classifier, one can achieve automatic classification of such seismic geophone data events in the future. This would provide a low-cost and highly valuable decision support tool in the context of geohazard warning systems. Table 1: Class types with the corresponding numbers of samples in the dataset. The dataset is available within the source code. The data has been acquired over many years. The data with the valid classes (i.e., Noise to Spike) had been acquired from 2007 to 2020 and the data with the Unlabeled class was acquired throughout 2021.
class name a number of samples Noise Examples of 16 seconds geophone data recordings are shown in Fig. 4. The sampling frequency is 1000 Hz, so the time series data consist of length-16 000 vectors for each of the eight geophones with three (x, y, z) components (24 time series in total). These data represent non-stationary time series, where the amplitude and frequency content clearly change over the 16 second time interval. It is not obvious how to summarize such an image by simple statistics such as mean, variance, correlation, dominating frequency, or other measures.
A common technique of analysing such data is to compute spectrograms [19]. This essentially entails taking a rolling window short-time Fourier transformation of the data. The magnitudes for each frequency and time will then indicate the core frequency contents of the signal as a function of the 16 second time interval. Figure 4 shows example spectrograms associated with the time series.
There are apparent differences in the signals. The most obvious one is probably the signal duration which can last less than 3 seconds (Fig. 4a, b, d, h) or, in the contrary, last longer or even span the full duration of the record (Fig. 4c, e, f, g). The shape of the signals, represented by their envelopes, is also an important characteristic and displays either a main peak of energy (e.g. Fig. 4a, h) or several peaks of energy distributed over time (e.g. Fig. 4c, e, f). Lastly, the frequency content of the signals exhibit clear differences from a type of event to another, with some classes reaching high frequencies up to 80 Hz or even more (e.g. Fig. 4a, d, e, h) while the other are confined to lower frequencies (< 20 Hz, e.g. Fig. 4b, c, f). Moreover, variability in the time series, and consequently in the spectrograms, can be observed depending on the sensor which recorded the event. This is particularly visible for the rockfall event (Fig. 4e) where the energy bandwidth decreases for the records from top to bottom. In this example, the relative amplitudes of the different bursts in the time series are also variable. Such variability from a geophone to another is mostly due to the event source location and its distance to the recording stations. Seismic waves are indeed affected by the properties of the medium in which they propagate.

Proposed Method: VNIbCReg
As mentioned earlier, VNIbCReg can be viewed as VIbCReg with TNC with neighboring-invariance and bettercovariance. VIbCReg is effective in representation learning because samples with different classes can be well separated in the representation space. Despite the effectiveness of VIbCReg, it was not designed to encode temporal transition in the (signal) representation. The necessity of encoding the temporal transition can be observed given several samples from our dataset in Fig. 4. To compensate for the lack of ability of encoding the temporal transition in VIbCReg, TNC is adopted into VIbCReg, resulting in VNIbCReg.
The overall framework of VNIbCReg is presented in Fig. 5. Notation is clarified next, along with the required loss functions. Here, X denotes an input of the spectrograms where X ∈ R B×24×H×W (B: batch, H: height, and W : width), and m and n denote randomly-selected indices for a single time series among the 24 time series. Therefore, X m and X n have dimension B B×H×W . A cropped window is denoted by W , where W t and W l are in the same neighborhood while W t and W k are non-neighboring. It should be noted that W t , W l , and W k are randomly chosen  while keeping their spatial relations to each other. An illustration of W t , W l , and W k is presented in Fig. 6. Further, E, P , and D denote an encoder, the projector in VIbCReg, and the discriminator in TNC, respectively. Loss functions are denoted by L. Note that an iterative normalization layer in VIbCReg is omitted for simplicity in the figure and the same coloring for models such as E, P , and D represents the shared weights between the same colored models. As for the discriminator's input, two Y -s are concatenated and used as input. As for Y and Z in the loss functions, the following notation is used: Y = [y 1 , · · · , y B ] T ∈ R B×Fy and Z = [z 1 , · · · , z B ] T ∈ R B×Fz , where F y and F z denote feature size of Y and Z, respectively. Figure 6: Illustration of W t , W l , and W k . Each denotes a reference window, a neighboring window, and a nonneighboring window. The red curve of a normal distribution shape represents the neighborhood.
The additive loss is used for the two parts: Here, the first part on the right side of Eqn. 1 consists of Here, s(..) denotes the invariance term, v(..) variance term and c(..) the covariance term. Moreover, Var denotes a variance estimator, γ is a target value for the standard deviation, fixed to 1 as in the original implementation, is a small scalar (i.e., 0.0001) to prevent numerical instability, i =j denotes summation of off-diagonal terms in a 2-dimensional matrix, and λ, µ, and ν are hyper-parameters to control the importance of each term. It should be noted that the notation for L vibcreg largely follows that of the original paper.
The second term on the right in Eqn. (1) is defined as follows: The original TNC loss function is defined as − log (D(Y t , Y l )) + log (1 − D(Y t , Y k )) given that its regularization weighting hyper-parameter is set to zero. In Eqn. (7), there is an additional term, which is proposed added. This addition improves quality of representation learning on the top of the original TNC loss by correlating Y t and Y l and de-correlating Y t and Y k . Here, i=j denotes summation of diagonal terms in a 2-dimensional matrix and ρ is a hyper-parameter for weighting L tnc . In the experiments, λ, µ, ν, and ρ are empirically set to 10, 10, 10, and 13, respectively.
Lastly, a quirky component in the VNIbCReg framework is the sensor invariance which is proposed for the following reason: A single sample consists of the 24 time series in our dataset. Although the 24 time series are different to some extent due to the sensors' location, functionality, and axial directions, they are semantically the same in a sense that they belong to the same class. The sensor invariance is what allows representations of the spectrograms of the different time series within the same sample to be pulled together in the embedding space by both VIbCReg and TNC.
After pre-training by a SSL method, only the encoder is typically kept while discarding the rest of the parts such as the projector and the discriminator. Then, the encoder can be used for various downstream tasks of classification with some fine-tuning.

Implementation Details
Training and Test Datasets For the naive supervised learning and the linear evaluation, the dataset is split by stratified random sampling into 80% for training and 20% for testing. For the fine-tuning evaluation, the dataset is split into n% (where n is specified in the fine-tuning result table) and 20% of the dataset for training and test datasets, respectively. For the naive supervised learning, the linear evaluation, and the fine-tuning evaluation, samples with valid classes (i.e., noise, regional, rockfall, slope HF, slope LF, slope tremor, slope multi, and spike) are used as a dataset. For the SSL, its dataset consists of all the samples including the unlabeled-class samples. Given the randomness of the dataset split, all the experimental cases are run three times with different random seeds.
Preprocessing First, a time series input is converted into a spectrogram using a spectrogram function from SciPy with a 0.08 s-long sliding window with a 12.5% overlap [20]. Then, it is scaled by log and min-max scaling, and resized such that the height is adjusted to 128 and the width is adjusted proportionally to the increase ratio of the height.
The preprocessing used in our experiments is somewhat different from that of [18] in which spectrograms are computed using a 1 sec sliding window with a 95% overlap, and then converted into an RGB image with the size of (3×224×224). The sliding window length and overlap give monotonous spectrograms i.e., low-resolution spectrogram, and it leads to an overfitting which give lower accuracy in our experiments. Also, the spectrograms do not have to be converted into square-shaped RGB images. Spectrograms originally have dimension of (1 × H × W ) as 1 channel real-valued matrix, where H and W denote height and width, respectively. Thus, a naive form of spectrograms can be already viewed as an 1-dimensional real-valued image data. In addition, because a convolutional layer can process rectangle image shapes as well as square shapes, the rectangle shapes of the naive form of spectrograms can be processed by a CNN model without squishing the rectangular shape into a square, which can actually lead to some information loss and performance drop.
Augmentation In our experiments, there are two types of augmentations: Neighboring Crop (NC) and Random Crop (RC). The NC takes a spectrogram and outputs three different cropped windows of the spectrogram, W t , W l , and W k , as shown in Fig. 5. In contrast, the RC outputs three different cropped windows of the spectrogram. But the cropped windows in the RC do not have any spatial relation between each other as the three cropped windows are selected at random. In our experiments, height of the crop is set to the same height as the input spectrogram and the width of the crop is set to 10% of width of the input spectrogram for both the NC and the RC. Although additional augmentation methods can likely gain extra performance improvement, no other method is used here to clearly compare the performance between the RC and the NC in the linear and fine-tuning evaluations.
Architecture In our experiments, ResNet34 is used. The original implementation [18] takes spectrograms converted into RGB images (i.e., C × H × W , where C is 3) as input. Therefore, the input channel size is 3 for the first convolutional layers in both models. In our experiments, the input spectrogram has a dimension of (1 × H × W ), therefore, the first convolutional layers in both models are modified to receive an input with one channel. Except that, both model architectures remain the same as in [18]. The same holds for the projector and the discriminator.
Optimizer Adam [21] is used with a cosine learning rate scheduler. Its initial learning rate for the encoder and the classifier is set to 0.001 for the SSL and the linear evaluation. For the fine-tuning evaluation on the SSL methods, the initial learning rates are set to 0.0005 and 0.001 for the encoder and the classifier, respectively. The batch size is 128 for the SSL and 64 for naive supervised learning, the linear evaluation, and the fine-tuning evaluation. A number of epochs is 300 for the self-supervised learning and 100 for the linear evaluation and the fine-tuning evaluation. The used deep learning library is PyTorch [22].

Results
Linear and Fine-tuning Evaluations on SSL Methods The linear and fine-tuning evaluations are conducted on VIbCReg, VNIbCReg, and intermediate variants between VIbCReg and VNIbCReg. The evaluation on the intermediate variants are conducted to find out how much contribution each component that is added on VIbCReg to form VNIbCReg makes.
The linear evaluation results are presented in Table 2. VIbCReg does not perform so well here, meaning that the learned representations by VIbCReg are not so linearly-separable by class. By introducing main components from the original TNC (i.e., NC and L † tnc ), a significant improvement is achieved in the linear evaluation. This indicates that the ability of encoding the temporal transition improves quality of learned representations especially for non-stationary time series with apparent temporal transition.
The effectiveness of L tnc is shown by further improving the performance. The fine-tuning evaluation result is presented in Table 3. The performance ranking order of the fine-tuning evaluation between VIbCReg, VNIbCReg, and the intermediate variants remains the same as in the linear evaluation. One of the noticeable points in the result is the high test accuracy in a small dataset regime (i.e., n of 5% and 10%) for models that are pretrained by a SSL method. Especially, VNIbCReg results in the highest test accuracy in the small dataset regime, indicating that the model is well generalized by VNIbCReg. As the geophone sensor data is collected unlabeled, there is naturally a large unlabeled dataset while the labeled dataset is much smaller because proper labeling can only be done manually by an expert. Given that circumstance, VNIbCReg is expected to provide robust performance improvement when a large amount of unlabeled dataset is utilized.  Table 3: Fine-tuning evaluation result. The notation is the same as in the linear evaluation result. RandInit refers to a case where an encoder is randomly-initialized and frozen without any pre-training and used for the fine-tuning evaluation (i.e., naive supervised learning). Note that the accuracy is much higher with a small labeled dataset when pretrained by VNIbCReg.

Conclusion
Although SSL methods such as VICReg on images and VIbCReg on time series were successful on their benchmark datasets, they were not designed to be able to consider non-stationarity. VNIbCReg which is a combination of VIbCReg and TNC is shown to be effective in learning representations of non-stationary time series. Given its effectiveness, a further study can be conducted on more non-stationary time series datasets to verify its general SSL capability.