Juan Vazquez-Rodriguez
email: juan.vazquezrodriguez@orange.com

Grégoire Lefebvre
email: gregoire.lefebvre@orange.com

Julien Cumin
email: julien1.cumin@orange.com

James L Crowley
email: james.crowley@inria.fr

TRANSFORMER-BASED SELF-SUPERVISED LEARNING FOR EMOTION RECOGNITION

In order to exploit representations of time-series signals, such as physiological signals, it is essential that these representations capture relevant information from the whole signal. In this work, we propose to use a Transformer-based model to process electrocardiograms (ECG) for emotion recognition. Attention mechanisms of the Transformer can be used to build contextualized representations for a signal, giving more importance to relevant parts. These representations may then be processed with a fully-connected network to predict emotions.

To overcome the relatively small size of datasets with emotional labels, we employ self-supervised learning. We gathered several ECG datasets with no labels of emotion to pre-train our model, which we then fine-tuned for emotion recognition on the AMIGOS dataset. We show that our approach reaches state-of-the-art performances for emotion recognition using ECG signals on AMIGOS. More generally, our experiments show that transformers and pre-training are promising strategies for emotion recognition with physiological signals.

Introduction

When processing time-series signals with deep learning approaches, it is useful to be able to aggregate information from the whole signal, including long-range information, in a way that the most relevant parts are given more importance. One way of doing this is by employing an attention mechanism [START_REF] Bahdanau | Neural machine translation by jointly learning to align and translate[END_REF] that uses attention weights to limit processing to relevant contextual information, independent of distance.

Arguably, the Transformer [START_REF] Vaswani | Attention is All you Need[END_REF] is one of the most successful attention-based approaches. Developed for Natural Language Processing (NLP), the Transformer uses attention mechanisms to interpret sequences of words, and is suitable for use in other tasks requiring interpretation of sequences, such as time series forecasting, [START_REF] Li | Enhancing the Locality and Breaking the Memory Bottleneck of Transformer on Time Series Forecasting[END_REF], analysis of medical physiological signals [START_REF] Yan | Fusing Transformer Model with Temporal Features for ECG Heartbeat Classification[END_REF][START_REF] Ahmedt-Aristizabal | Attention Networks for Multi-Task Signal Analysis[END_REF], and recognition of human activity from motion [START_REF] Haresamudram | Masked reconstruction based self-supervision for human activity recognition[END_REF].

Physiological signal analysis can be seen as a form of time-series analysis and are thus amenable to processing with Transformers. Moreover, these signals can be used to predict emotions [START_REF] Shu | A Review of Emotion Recognition Using Physiological Signals[END_REF], and sensors for these types of signals can be incorporated into wearable devices, as a non-invasive means for monitoring the emotional reaction of users. Several works in this direction have emerged using signals like electrocardiograms (ECG) [START_REF] Santamaria-Granados | Using Deep Convolutional Neural Network for Emotion Detection on a Physiological Signals Dataset (AMIGOS)[END_REF][START_REF] Sarkar | Self-Supervised Learning for ECG-Based Emotion Recognition[END_REF], electroencephalograms (EEG) [START_REF] Song | EEG Emotion Recognition Using Dynamical Graph Convolutional Neural Networks[END_REF][START_REF] Becker | Emotion Recognition Based on High-Resolution EEG Recordings and Reconstructed Brain Sources[END_REF], electrodermal activity (EDA) [START_REF] Shukla | Feature Extraction and Selection for Emotion Recognition from Electrodermal Activity[END_REF], and other types of physiological signals [START_REF] Chen | Emotion Recognition Based on Skin Potential Signals with a Portable Wireless Device[END_REF][START_REF] Ramaji Kose | A new approach for emotions recognition through EOG and EMG signals[END_REF].

Established approaches for deep learning with Convolutions and Recurrent networks require large datasets of labeled training data. However, providing ground truth emotion labels for physiological data is a difficult and expensive process, limiting the availability of data for training [START_REF] Koelstra | DEAP: A Database for Emotion Analysis ;Using Physiological Signals[END_REF][START_REF] Subramanian | ASCERTAIN: Emotion and Personality Recognition Using Commercial Sensors[END_REF][START_REF] Miranda Correa | AMIGOS: A Dataset for Affect, Personality and Mood Research on Individuals and Groups[END_REF]. Pre-training models with self-supervised learning can help to overcome this lack of labeled training data. With such an approach, during pre-training the model learns general data representations using large volumes of unlabeled data. The model is then fine tuned for a specific task using labeled data. This approach has been successfully used in other domains including NLP [START_REF] Peters | Deep Contextualized Word Representations[END_REF][START_REF] Devlin | BERT: Pre-training of Deep Bidirectional Transformers for Language Understanding[END_REF] and Computer Vision [START_REF] Chen | A Simple Framework for Contrastive Learning of Visual Representations[END_REF][START_REF] Wu | Visual Transformers: Token-based Image Representation and Processing for Computer Vision[END_REF]. It has also been successfully used in affective computing, in tasks like emotion recognition from physiological signals [START_REF] Sarkar | Self-Supervised Learning for ECG-Based Emotion Recognition[END_REF][START_REF] Ross | Unsupervised multi-modal representation learning for affective computing with multi-corpus wearable data[END_REF] and from speech [START_REF] Macary | On the Use of Self-Supervised Pre-Trained Acoustic and Linguistic Features for Continuous Speech Emotion Recognition[END_REF], personality recognition [START_REF] Song | Self-supervised Learning of Person-specific Facial Dynamics for Automatic Personality Recognition[END_REF], and facial expression recognition [START_REF] Wiles | Self-supervised learning of a facial attribute embedding from video[END_REF][START_REF] Li | Self-Supervised Representation Learning From Videos for Facial Action Unit Detection[END_REF][START_REF] Roy | Self-supervised Contrastive Learning of Multi-view Facial Expressions[END_REF].

In this paper, we address the problem of predicting emotions from ECG signals. We are interested in obtaining contextualized representations from these signals using a Transformer-based architecture, and then using these representations to predict low/high levels of arousal and valence. We believe that the contextualized representations obtained with the Transformer should capture relevant information from the whole signal, which the performance of the downstream task of emotion recognition should benefit from. Our main contributions are: 1. We show that it is feasible to use a Transformer-based architecture for emotion prediction from ECG signals. 2. We show that using a self-supervised technique to pre-train the model is useful for ECG signals, achieving superior performance in emotion recognition than a fully-supervised approach. 3. We show that our pre-trained Transformer-based model reaches state-of-the-art performances on a dataset of the literature.

Related Work

Traditional techniques for emotion recognition from physiological signals include Gaussian naive Bayes, Support Vector Machines, k-Nearest Neighbours, and Random Forests. [START_REF] Subramanian | ASCERTAIN: Emotion and Personality Recognition Using Commercial Sensors[END_REF][START_REF] Miranda Correa | AMIGOS: A Dataset for Affect, Personality and Mood Research on Individuals and Groups[END_REF][START_REF] Gjoreski | An Inter-domain Study for Arousal Recognition from Physiological Signals[END_REF][START_REF] Ayata | Emotion Recognition from Multimodal Physiological Signals for Emotion Aware Healthcare Systems[END_REF][START_REF] Hsu | Automatic ECG-Based Emotion Recognition in Music Listening[END_REF][START_REF] Shu | Wearable Emotion Recognition Using Heart Rate Data from a Smart Bracelet[END_REF]. These approaches typically use manually-selected time and frequency features derived from intuition and domain knowledge. Shukla et al. [START_REF] Shukla | Feature Extraction and Selection for Emotion Recognition from Electrodermal Activity[END_REF] show that commonly used features for arousal and valence prediction are not necessarily the most discriminant. This illustrates the difficulty of selecting good hand-crafted features.

To overcome this, researchers have increasingly used deep learning techniques to extract features from physiological signals for emotion recognition. A common approach, described by Santamaria et al. [START_REF] Santamaria-Granados | Using Deep Convolutional Neural Network for Emotion Detection on a Physiological Signals Dataset (AMIGOS)[END_REF], is to use a 1D Convolutional Neural Network (CNN) to extract the features (also called representations), followed by a fully-connected network (FCN) used as classifier to predict emotions. As an alternative, Harper and Southern [START_REF] Harper | A Bayesian Deep Learning Framework for End-To-End Prediction of Emotion from Heartbeat[END_REF] use a Long Short-Term Memory (LSTM) network concurrently with a 1D-CNN. Siddharth et al. [START_REF] Siddharth | Utilizing Deep Learning Towards Multi-modal Bio-sensing and Vision-based Affective Computing[END_REF], first convert signals into an image using spectrograms [START_REF] Fulop | Algorithms for computing the time-corrected instantaneous frequency (reassigned) spectrogram, with applications[END_REF], and then use a 2D-CNN for feature extraction, followed by an extreme learning machine [START_REF] Huang | Extreme learning machine: Theory and applications[END_REF] for classification.

One drawback of these CNN-based approaches is that they do not take context into account: after training, kernel weights of the CNN are static, no matter the input. For this reason, attention-based architectures such as the Transformer [START_REF] Vaswani | Attention is All you Need[END_REF], capable of incorporating contextual information, have started to be used for emotion prediction. Transformers have been successfully used to recognize emotions with multimodal inputs composed of text, visual, audio and physiological signals [START_REF] Tsai | Multimodal Transformer for Unaligned Multimodal Language Sequences[END_REF][START_REF] Wu | Attending to Emotional Narratives[END_REF][START_REF] Huang | Multimodal Transformer Fusion for Continuous Emotion Recognition[END_REF][START_REF] Cai | Multimodal Sentiment Analysis based on Recurrent Neural Network and Multimodal Attention[END_REF][START_REF] Chien | Self-assessed Emotion Classification from Acoustic and Physiological Features within Small-group Conversation[END_REF]. In addition, Transformers have been used to process time-series in general [START_REF] Li | Enhancing the Locality and Breaking the Memory Bottleneck of Transformer on Time Series Forecasting[END_REF][START_REF] Wu | Deep Transformer Models for Time Series Forecasting: The Influenza Prevalence Case[END_REF], and also to process uni-modal physiological signals in particular, with the aim of recognizing emotions. Arjun et al. [START_REF] Arjun | Introducing Attention Mechanism for EEG Signals: Emotion Recognition with Vision Transformers[END_REF] employ a variation of the Transformer, the Vision Transformer [START_REF] Dosovitskiy | An Image is Worth 16x16 Words: Transformers for Image Recognition at Scale[END_REF] to process EEG signals for emotion recognition, converting the EEG signals into images using continuous wavelet transform. Behinaein et al. [START_REF] Behnam Behinaein | A Transformer Architecture for Stress Detection from ECG[END_REF] propose to detect stress from ECG signals, by using a 1D-CNN followed by a Transformer and a FCN as classifier.

Most of the approaches for measuring emotions, including those using multimodal physiological data, have relied on supervised learning, and thus are limited by the availability of labeled training data. Using self-supervised pre-training can improve performances of a model [START_REF] Erhan | Why Does Unsupervised Pre-training Help Deep Learning[END_REF], as it allows to learn more general representations, thus avoiding overfitting in the downstream task. This is especially important for tasks with limited labeled data. Sarkar and Etemad [START_REF] Sarkar | Self-Supervised Learning for ECG-Based Emotion Recognition[END_REF] pretrain a 1D-CNN using a self-supervised task to learn representations from ECG signals. Their self-supervised task consists in first transforming the signal, with operations such as scaling or adding noise, and then using the network to predict which transformation has been applied. Ross et al. [START_REF] Ross | Unsupervised multi-modal representation learning for affective computing with multi-corpus wearable data[END_REF] learn representations from ECG signals using autoencoders based on 1D-CNN. In both approaches, once the representations have been learned, they are used to predict emotions.

In contrast with the two previously mentioned approaches, we propose to take into account contextual information during pre-training by using a Transformer-based model. Such an approach has been used for pre-training Transformers from visual, speech and textual modalities [START_REF] Macary | On the Use of Self-Supervised Pre-Trained Acoustic and Linguistic Features for Continuous Speech Emotion Recognition[END_REF][START_REF] Khare | Multi-Modal Embeddings Using Multi-Task Learning for Emotion Recognition[END_REF][START_REF] Rahman | Integrating Multimodal Information in Large Pretrained Transformers[END_REF][START_REF] Siriwardhana | Multimodal Emotion Recognition With Transformer-Based Self Supervised Feature Fusion[END_REF][START_REF] Khare | Self-Supervised Learning with Cross-Modal Transformers for Emotion Recognition[END_REF]. Haresamudram et al. use this approach to pre-train a Transformer for human activity recognition using accelerometer and gyroscope data [START_REF] Haresamudram | Masked reconstruction based self-supervision for human activity recognition[END_REF]. Zerveas et al. [START_REF] Zerveas | A Transformer-based Framework for Multivariate Time Series Representation Learning[END_REF] develop a framework for multivariate time-series representation learning, by pre-training a Transformer-based architecture. However, none of these works deal with uni-modal physiological signals. In this work, we have extended this approach for use with ECG signals. Specifically, we investigate the effectiveness of pre-training a Transformer for ECG emotion recognition, which to the best of our knowledge has not been done before.

Our approach

Our framework for using deep learning for emotion recognition is based on the following two steps: first, we need to obtain contextualized representations from time-series signals using a deep model; then, we use those representations to perform the targeted downstream task. In this paper, the considered physiological time-series are raw ECG signals, and the downstream task is binary emotion recognition: predicting high/low levels of arousal, and high/low levels of valence.

For the first step (see Figure 1.a), we developed a signal encoder based on deep neural networks and attention, to obtain contextualized representations from ECG signals. The main component of the signal encoder is a Transformer [START_REF] Vaswani | Attention is All you Need[END_REF]. This signal encoder is pre-trained with a self-supervised task, using unlabeled ECG data. For the second step (see Figure 1.b), we fine-tune the whole model (the signal encoder and the fully-connected classifier) for our downstream task of binary emotion recognition, using labeled ECG data.

In the following subsections, we describe in detail the different components of our approach.

Learning Contextualized Representations

At the heart of our signal encoder is a Transformer encoder [START_REF] Vaswani | Attention is All you Need[END_REF], which we use to learn contextualized representations of ECG signals. In Transformers, contextual information is obtained through an attention mechanism, with the attention function considered as a mapping of a query vector along with a group of key-value vector pairs to an output. In the case of the Transformer encoder, each position in the output pays attention to all positions in the input. Several attention modules (also called heads) are used, creating various representation subspaces and improving the ability of the model to be attentive to different positions. The Transformer encoder is constructed by stacking several layers containing a multi-head attention module followed by a fully-connected network applied to each position, with residual connections. Since our implementation of the Transformer is almost identical to the one described in [START_REF] Vaswani | Attention is All you Need[END_REF], we refer the readers to this paper for further details.

In Figure 2, we present our signal encoder, which we describe in the remainder of this subsection.

Input Encoder: to process an ECG signal with the Transformer, we first encode it into s feature vectors of dimension d model that represent each one of the s values of the ECG signal. We use 1D Convolutional Neural Networks (1D-CNN) to perform this encoding, like in [START_REF] Haresamudram | Masked reconstruction based self-supervision for human activity recognition[END_REF][START_REF] Tsai | Multimodal Transformer for Unaligned Multimodal Language Sequences[END_REF][START_REF] Baevski | Wav2vec 2.0: A Framework for Self-Supervised Learning of Speech Representations[END_REF]. Thus, for a raw input signal X = {x 1 , ..., x s } where x i is a single value, after encoding X with the input encoder we obtain features F = {f 1 , ..., f s } where f i ∈ R dmodel .

CLS token: given that our downstream task is a classification task, we need to obtain a single representation of the whole processed signal at the output of our signal encoder. Similar to what is done in BERT [START_REF] Devlin | BERT: Pre-training of Deep Bidirectional Transformers for Language Understanding[END_REF], we append a special classification token (CLS) at the start of the feature sequence F , resulting in the sequence F ′ = {CLS, f 1 , ..., f s }. We use a trainable vector of dimension d model as CLS token. At the output of the Transformer, we obtain an embedding of the CLS token (e CLS ), along with the rest of the representations of the signal (see Figure 2 and Equation 2). Through the attention mechanisms of the Transformer, e CLS is capable of aggregating information from the entire input signal and its contextualized representations. For this reason, at classification time, e CLS can be used as input for the classifier network.

Positional Encoding: positional information of each input is required so that the Transformer can take into account the actual ordering of time-steps in the input sequence. As in [START_REF] Vaswani | Attention is All you Need[END_REF], we use fixed sinusoidal positional embeddings. We sum the positional embeddings with the features F ′ :

Z = {CLS + pe 0 , f 1 + pe 1 , ..., f s + pe s }, (1)
where pe i ∈ R dmodel is the positional embedding for time-step i. We then apply layer normalization [START_REF] Lei Ba | Layer Normalization[END_REF] to Z. Please refer to [START_REF] Vaswani | Attention is All you Need[END_REF] for details on how to obtain the positional embeddings.

Transformer Encoder: we obtain contextualized representations E using a Transformer encoder with h heads and l layers on the sequence Z: E = {e CLS , e 1 , ..., e s } = Transformer h,l (Z).

We then use the representations E for emotion recognition, as is described in Section 3.3

Pre-training Task

To pre-train our signal encoder, we employ a self-supervised approach inspired in BERT [START_REF] Devlin | BERT: Pre-training of Deep Bidirectional Transformers for Language Understanding[END_REF]. We mask random segments of a certain length by replacing them with zeros, and then we train our model to predict the masked values, as shown in Figure 1a. Labeled data is not needed for this step.

Similar to [START_REF] Baevski | Wav2vec 2.0: A Framework for Self-Supervised Learning of Speech Representations[END_REF], a proportion p of points is randomly selected from the input signal as starting points for masked segments, and then for each starting point the subsequent M points are masked. The masked segments may overlap.

To predict masked points, we use a fully-connected network (FCN) on top of the signal encoder, as shown in Figure 1a.

We only predict values of masked inputs, as opposed to reconstructing the whole signal. We use the mean square error between predicted and real values as the reconstruction loss L r during pre-training:

L r = 1 N m Nm j=1 (x j -x p(j) ) 2 , (3)
where N m is the number of masked values, xj is the prediction corresponding to the j th masked value, and x p(j) is the original input value selected to be the j th masked value, whose position is p(j) in the input signal.

Fine-tuning

We fine-tune our model to perform binary emotion prediction, as shown in Figure 1b. This step is supervised, using labeled data. To make the prediction, a FCN is added on top of the signal encoder, using e CLS as input. We initialize the signal encoder with the weights obtained after pre-training, while the FCN is randomly initialized. We then fine-tune all the parameters of the model, including the pre-trained weights. For this task, we minimize the binary cross-entropy loss L f t : where y is an indicator variable with value 1 if the class of the ground truth is positive and 0 if it is negative, out is the output of the classifier, σ is the sigmoid function, and w p is the ratio of negative to positive training samples, used to compensate unbalances that may be present in the dataset.

L f t = -w p y log[σ(out)] -(1 -y) log[1 -σ(out)] (4)

Experimental Setup

In this section, we describe the experimental choices taken to evaluate our approach for a downstream task of binary emotion recognition (high/low levels of arousal and valence), on ECG signals. We present the datasets used, the pre-processes employed, and the parametrization of our two steps of pre-training and fine-tuning.

Datasets

For pre-training, we only require datasets that contain ECG signals, regardless of why they were actually collected or which labeling they have, if any. The datasets that we use in our experiments are: ASCERTAIN [START_REF] Subramanian | ASCERTAIN: Emotion and Personality Recognition Using Commercial Sensors[END_REF], DREAMER [START_REF] Katsigiannis | DREAMER: A Database for Emotion Recognition Through EEG and ECG Signals From Wireless Low-cost Off-the-Shelf Devices[END_REF], PsPM-FR [START_REF] Tzovara | PsPM-FR: SCR, ECG and respiration measurements in a delay fear conditioning task with visual CS and electrical US[END_REF], PsPM-HRM5 [START_REF] Philipp | PsPM-HRM5: SCR, ECG and respiration measurements in response to positive/negative IAPS pictures, and neutral/aversive sounds[END_REF], PsPM-RRM1-2 [START_REF] Dominik | PsPM-RRM1-2: SCR, ECG, respiration and eye tracker measurements in response to electric stimulation or visual targets[END_REF], and PsPM-VIS [START_REF] Xia | PsPM-VIS: SCR, ECG, respiration and eyetracker measurements in a delay fear conditioning task with visual CS and electrical US[END_REF]. We also employ the AMIGOS dataset [START_REF] Miranda Correa | AMIGOS: A Dataset for Affect, Personality and Mood Research on Individuals and Groups[END_REF], taking care of not using the same data for pre-training and evaluating our model, as this dataset is also used for the downstream task. To gather as much data as possible, we use all the ECG channels available in the datasets. For ASCERTAIN, we discard some signals according to the quality evaluation provided in the dataset: if a signal has a quality level of 3 or worse in the provided scale, it is discarded. In total, there are around 230 hours of ECG data for pre-training.

To fine-tune our model to predict emotions, we use the AMIGOS dataset [START_REF] Miranda Correa | AMIGOS: A Dataset for Affect, Personality and Mood Research on Individuals and Groups[END_REF]. In this dataset, 40 subjects watched videos specially selected to evoke an emotion. After watching each video, a self-assessment of their emotional state is conducted. In this assessment, subjects rated their levels of arousal and valence on a scale of 1 to 9. Of the 40 subjects, 37 watched a total of 20 videos, while the other 3 subjects watched only 16 videos. During each trial, ECG data were recorded on both left and right arms. We use data only from the left arm to fine-tune our model. AMIGOS includes a pre-processed version of the data, that was down-sampled to 128Hz and filtered with a low-pass filter with 60Hz cut-off frequency. We use these pre-processed data for our experiments, including the pre-training phase. The ECG data that we use for fine-tuning amounts to around 65 hours of recordings.

Signal Pre-processing

We first filter signals with an 8 th order Butterworth band-pass filter, having a low-cut-off frequency of 0.8Hz and a high-cut-off frequency of 50Hz. We then down-sample the signals to 128 Hz, except for AMIGOS which already has that sampling rate. Signals are normalized so they have zero-mean and unit-variance, for each subject independently. Signals are finally divided into 10-second segments (we also report results for segments of 20 seconds and 40 seconds).

Pre-training

As stated previously, we use ASCERTAIN, DREAMER, PsPM-FR, PsPM-RRM1-2, PsPM-VIS, and AMIGOS for pre-training. Since we also use AMIGOS for fine-tuning, we need to avoid using the same segments both for pretraining and for evaluating the model. To do this, we pre-train two models, one using half of the data from AMIGOS, and the second using the other half. When testing our model with certain segments from AMIGOS, we fine-tune the model that was pre-trained with the half of AMIGOS that do not contain those segments. More details are given in Section 4.4. In total, both of our models are pre-trained with 83401 10-second segments.

We select a proportion of p = 0.0325 points from each input segment to be the starting point of a masked span of length M = 20, resulting in around 47% of the input values masked.

The input encoder is built with 3 layers of 1D-CNN with ReLU activation function. We use layer normalization [START_REF] Lei Ba | Layer Normalization[END_REF] on the first layer, and at the output of the encoder. Kernel sizes are (65, [START_REF] Siddharth | Utilizing Deep Learning Towards Multi-modal Bio-sensing and Vision-based Affective Computing[END_REF][START_REF] Miranda Correa | AMIGOS: A Dataset for Affect, Personality and Mood Research on Individuals and Groups[END_REF], the numbers of channels are (64, 128, 256) and the stride for all layers is 1. This results in a receptive field of 113 input values or 0.88s. We selected this receptive field size because it is comparable with the typical interval between peaks on an ECG signal, which is between 0.6s and 1s, including when experiencing emotions [START_REF] Wu | How Do Amusement, Anger and Fear Influence Heart Rate and Heart Rate Variability[END_REF].

The Transformer in our signal encoder has a model dimension d model = 256, 2 layers and 2 attention heads, with its FCN size of d model • 4 = 1024. The FCN used to predict the masked values consists of a single linear layer of size d model /2 = 128 followed by a ReLU activation function. An additional linear layer is used to project the output vector to a single value, which corresponds to the predicted value of a masked point.

We pre-train the two models for 500 epochs, warming up the learning rate over the first 30 epochs up to a value of 0.001 and using linear decay after that. We employ Adam optimization, with β 1 = 0.9, β 2 = 0.999, and L 2 weight decay of 0.005. We use dropout of 0.1 at the end of the input encoder, after the positional encoding, and inside the Transformer.

We tuned the number of layers and heads in the Transformer, the learning rate, and the warm-up duration using the Ray Tune framework [START_REF] Liaw | Tune: A Research Platform for Distributed Model Selection and Training[END_REF] with BOHB optimization [START_REF] Falkner | BOHB: Robust and Efficient Hyperparameter Optimization at Scale[END_REF].

Fine-Tuning

We fine-tune our model (both the signal encoder and FCN classifier) for emotion recognition with the AMIGOS dataset, using each of the 10-second segments as a sample. As labels, we use the emotional self-assessments given in the dataset. Since these assessments provide values of arousal and valence on a scale 1 to 9, we use the average arousal and the average valence as threshold value to determine a low or a high level.

We use 10-fold cross-validation to evaluate our approach. Recall that we pre-train two signal encoders. After dividing AMIGOS into 10 folds, we use folds 1 to 5 to pre-train one signal encoder (SE 1 ), and folds 6 to 10 to pre-train the second one (SE 2 ) (and all data from the other datasets, for both). Then, when we fine-tune the models to be tested with folds 1 to 5, we use the weights from SE 2 to initialize the signal encoder parameters. In a similar fashion, we use SE 1 as initialization point of the signal encoder when we fine-tune the models to be tested with folds 6 to 10. This method allows us to pre-train, fine-tune and test our model in a more efficient way than pre-training 10 different models, one for each fold, while retaining complete separations between training and testing data.

The FCN classifier used to predict emotions has two hidden layers of sizes [1024, 512] with ReLU activation functions, and an output layer that projects the output to a single value. We fine-tune one model to predict arousal and another to predict valence. For each task, we fine-tune our model for 100 epochs using Adam optimization, with β 1 = 0.9, β 2 = 0.999 and L 2 weight decay of 0.00001. We start with a learning rate of 0.0001, and decrease it every 45 epochs by a factor of 0.65. We keep using a dropout of 0.1 at the end of the input encoder, after the positional encoding, and inside the Transformer. We use dropout of 0.3 in the FCN classifier.

We used Ray Tune with BOHB, as we did on pre-training, to tune the learning rate, the learning rate schedule, the shape and dropout of the FCN classifier, and the L 2 weight decay.

Results

In our results, we use as metrics the mean accuracy and mean F1-score between positive and negative classes. We report the mean and confidence intervals of the metrics across our 10 folds of cross-validation. The confidence intervals are calculated using a t-distribution with 9 degrees of freedom, for a two-sided 95% confidence. [START_REF] Ross | Unsupervised multi-modal representation learning for affective computing with multi-corpus wearable data[END_REF] No 10 seconds 0.85 0.89 --

Our protocol

Pre-trained CNN [START_REF] Sarkar | Self-Supervised Learning for ECG-Based Emotion Recognition[END_REF] No 10 seconds 0.85±5.4e -3 0.84±5.3e -3 0.77±5.5e -3 0.77±5.1e -3 Pre-trained Transformer (ours) No 10 seconds 0.88±5.4e -3 0.87±5.4e -3 0.83±7.8e -3 0.83±7.4e -3

Comparing Aggregation Methods and Segment Lengths

We report in Table 1 the performances of our approach for different strategical choices. Firstly, we compare different aggregation approaches to combine the contextualized representations at the output of the signal encoder, given to the FCN classifier. Secondly, we compare performances for different segment lengths used to divide the input signals.

Aggregation Method: we compared 4 strategies for aggregating representations, to be given as input to the FCN: maxpooling, average-pooling, using only the last representation e s , and using only the embedding of the CLS token e CLS (we call this strategy CLS). Max-pooling 1 and average-pooling 1 are the result of max-pooling and average-pooling across all representations, to obtain a single representation of size d model = 256. Max-pooling 2 was optimized on the validation set: representations are reduced to a size of 64, divided into two groups, then max-pooling was applied on each group and the results concatenated to obtain a single representation of size 128. Average-pooling 2 was optimized on the validation set: representations are divided into 4 groups, average-pooling is applied on each group and the results concatenated to obtain a single representation of size 1024.

We see in Table 1 that the best results were obtained with average-pooling strategies and with CLS, with accuracies up to 0.88 for arousal, for example. In the following experiments, we will thus use CLS as our aggregation method. Indeed, although results are practically identical for CLS and average-pooling 2 (e.g. 0.88±5.4e -3 compared to 0.88±4.4e -3 accuracies for arousal), CLS has the advantage of being a commonly-used strategy for Transformers, which does not require any kind of tuning on validation data, contrary to average-pooling 2.

Segment length: we compare 3 different segment lengths for dividing ECG signals into input instances: 10, 20, and 40 second segments. We can see in Table 1 that shorter segments lead to better results on average, both for arousal and valence. For example for arousal, 10-second segments lead to an accuracy of 0.88±5.4e -3 , compared to 0.87±5.6e -3 for 20-second segments, and 0.86±1.2e -2 for 40-second segments.

Two explanations emerge for this observation: firstly, since emotions are relatively volatile states, longer segmentation might cover fluctuating emotional states, thus making it harder to characterize emotion; secondly, longer segments should require more complex models (i.e. bigger Transformer and FCN), which are harder to train with the relatively restricted amount of labeled data in AMIGOS. Moreover, shorter segments are faster to process, allowing a high number of training epochs and smaller learning rates. In the following experiments, we will thus use 10-second segments.

Effectiveness of Pre-training

To demonstrate the effectiveness of our pre-training approach, we tested our architecture by fine-tuning our model on AMIGOS with all parameters randomly initialized, instead of using a pre-trained signal encoder (thus skipping step (a) of our process in Figure 1). As reported in Table 2, the pre-trained model is on average significantly better than the model with no pre-training, for both accuracy and F1-score. For example, for arousal, the pre-trained model reaches an average accuracy of 0.88 ± 5.4e -3 , compared to 0.85 ± 5.6e -3 for the model with no pre-training. These results illustrate the benefits of pre-training Transformers for our task. Moreover, during our experiments, we observed that the model with no pre-training had a tendency to overfit quickly, which was not the case for the pre-trained model.

Pre-training the model on many different datasets should increase its robustness to overfitting when fine-tuning on a specific dataset.

Figure 1 :

 1 Figure 1: Our approach with self supervised learning based on a Transformer (a) and fine-tuning strategy for learning the final emotion predictor (b).

Figure 2 :

 2 Figure 2: Our Transformer-based signal encoder that produces contextualized representations. The aggregated representation e CLS is used for classification.

Table 1 :

 1 Comparison of different strategies of our approach on AMIGOS dataset

	Arousal Acc.	Arousal F1	Valence Acc.	Valence F1

Table 2 :

 2 No Pre-training vs pre-trained model

	Pre-train	Arousal Acc.	Arousal F1	Valence Acc.	Valence F1
	No	0.85±5.6e -3	0.84±5.8e -3	0.8±6.5e -3	0.8±6.4e -3
	Yes	0.88±5.4e -3	0.87±5.4e -3	0.83±7.8e -3	0.83±7.4e -3

Table 3 :

 3 Comparison of different methods on AMIGOS dataset

		Model	Subj. Ind. Input Seg. Size	Arousal Acc.	Arousal F1	Valence Acc.	Valence F1
		Gaussian Naive Bayes [17]	Yes	20 seconds	-	0.551	-	0.545
	Various	1D-CNN [8]	No	200 peaks	0.81	0.76	0.71	0.68
	experiment	2D-CNN [33]	Yes	Not segmented	0.83	0.76	0.82	0.80
	protocols	1D-CNN with LSTM [32]	Yes	Not segmented	-	-	0.81	0.80
		Convolutional autoencoder

https://code.engineering.queensu.ca/pritam/SSL-ECG

Acknowledgements: This work has been partially supported by the MIAI Multidisciplinary AI Institute at the Univ. Grenoble Alpes: (MIAI@Grenoble Alpes -ANR-19-P3IA-0003).

Comparisons With Other Approaches

We report in Table 3 various state-of-the-art results for emotion recognition from ECG signals on the AMIGOS dataset. The first section of the table contains results from works which all use different experiment protocols, such as different segment sizes, different separations of data into training and test sets, subject dependent and independent evaluations, etc. These results are therefore not directly comparable with one another, nor are they directly comparable with ours. Nevertheless, we report them to showcase the variety of state-of-the-art approaches published for this task, and give a relative idea of achieved performances on AMIGOS.

To compare our approach with another state-of-the-art approach as fairly as possible, it is required that both use exactly the same experiment protocol. For this, we fully retrained and tested the pre-trained CNN approach proposed by Sarkar and Etemad [START_REF] Sarkar | Self-Supervised Learning for ECG-Based Emotion Recognition[END_REF], with the experiment protocol we presented. To this end, we use the implementation provided by the authors 1 . To ensure fair comparisons, the exact same data was used to pre-train, fine-tune, and test both our approach and also Sarkar and Etemad's approach, for each fold of cross-validation.

We see in Table 3 that our approach achieves better performance on average than Sarkar and Etemad's approach with the same experiment protocol, for both arousal and valence. For example, our approach achieves an F1-score of 0.83±7.4e -3 for valence, compared to 0.77±5.1e -3 for the pre-trained CNN. These results are statistically significant with p < 0.01 following a t-test. This final set of results shows that our approach, and more generally self-supervised Transformer-based approaches, can be successfully applied to obtain contextualized representations from ECG signals for emotion recognition tasks.

Conclusions and Perspectives

In this paper, we investigate the use of transformers for recognizing arousal and valence from ECG signals. This approach used self-supervised learning for pre-training from unlabeled data, followed by fine-tuning with labeled data. Our experiments indicate that the model builds robust features for predicting arousal and valence on the AMIGOS dataset, and provides very promising results in comparison to recent state-of-the-art methods. This work showcases that self-supervision and attention-based models such as Transformers can be successfully used for research in affective computing.

Multiple perspectives emerge from our work. New pre-training tasks can be investigated: other methods such as contrastive loss or triplet loss might be more efficient with regards to the specificities of ECG signals, compared to masked points prediction which we used in this work. Extending our work to other input modalities (EEC, GSR, and even non-physiological inputs such as ambient sensors) and, in general, to process multimodal situations could prove useful for improving performances of emotion recognition. Finally, larger scale experiments, with new datasets captured in varied situations, will allow for a better understanding of the behaviour of our approach.


Manuela Lotierzo

Florin Olaru-Soare

Anne-Marie Dupuy

Maëlle Plawecki

Françoise Paris

Jean-Paul Cristol

Comparative study of human growth hormone measurements: impact on clinical interpretation

à la diffusion de documents scientifiques de niveau recherche, publiés ou non, émanant des établissements d'enseignement et de recherche français ou étrangers,