extfieldsofstudy:
Computer Science
Engineering

text:
Deep Learning for Sleep Stages Classification: Modified Rectified Linear Unit Activation Function and Modified Orthogonal Weight Initialisation

Background and Aim: Each stage of sleep can affect human health, and not getting enough sleep at any stage may lead to sleep disorder like parasomnia, apnea, insomnia, etc. Sleep-related diseases could be diagnosed using Convolutional Neural Network Classifier. However, this classifier has not been successfully implemented into sleep stage classification systems due to high complexity and low accuracy of classification. The aim of this research is to increase the accuracy and reduce the learning time of Convolutional Neural Network Classifier. Methodology: The proposed system used a modified Orthogonal Convolutional Neural Network and a modified Adam optimisation technique to improve the sleep stage classification accuracy and reduce the gradient saturation problem that occurs due to sigmoid activation function. The proposed system uses Leaky Rectified Linear Unit (ReLU) instead of sigmoid activation function as an activation function. Results: The proposed system called Enhanced Sleep Stage Classification system (ESSC) used six different databases for training and testing the proposed model on the different sleep stages. These databases are University College Dublin database (UCD), Beth Israel Deaconess Medical Center MIT database (MIT-BIH), Sleep European Data Format (EDF), Sleep EDF Extended, Montreal Archive of Sleep Studies (MASS), and Sleep Heart Health Study (SHHS). Our results show that the gradient saturation problem does not exist anymore. The modified Adam optimiser helps to reduce the noise which in turn result in faster convergence time. Conclusion: The convergence speed of ESSC is increased along with better classification accuracy compared to the state of art solution.

Introduction
Sleep Stage Classification is traditionally conducted by Polysomnography Scoring (PSG). Patients have to spend a night in the PSG recording centres and attach complex equipment in order to record the sleep signals which is inconvenient hence decreases the accuracy of reading due to sleep obstructions. The manual scoring of PSG signals is labour intensive and timeconsuming [1]. Event scoring is prone to fatigue errors due to its monotonous and laborious nature [2]. Also, intra and inter-rater reliability can affect classification. Due to this, sleep stage classification suffers from substantial variability which reduces the accuracy of the process [1]. Sleep Stage Classification in biomedical engineering has been greatly enhanced by Deep Learning, which is a relatively new technology Deep learning and Convolutional Neural Network (CNN) is used to increase the accuracy of automatic sleep stage classification and reduce the learning time of the model . CNN has the capacity to extract high-level features from each new layer using the information from the input signal. Such models generally fail to extract a rich and a diverse feature from the signal. The current CNN systems are not compatible with the portable wearable devices with low computational power. With the use of orthogonally initialised weights, Orthogonal Convolutional Neural Network (OCNN) makes it possible for this model to run on portable devices and allow the patient to record sleep data from the place of their convenience without any sleep obstructions [2] [3].
For accurate sleep stage classification, it is highly desirable for the network model to provide an accurate prediction within the least possible training time. Technically, Hilbert Huang transform converts EEG signal into a Time-Frequency Image representation which better describes the EEG signal for a CNN and allows it to extract more rich and diverse features. Zhang et al. [4] used the Sigmoid function as an activation function. This work suffers from gradient saturation which causes the weights to be updated slowly, hence reducing the accuracy of classification [4] [5]. In order to overcome this, Mousav et al. [5] utilise the ReLU function as an activation function to eliminate the problem of gradient saturation and hence increase the accuracy. Figure 1 shows three different classification systems. The aim of our research is to propose an OCNN model based on a ReLU activation function to remove the problem of gradient saturation. Furthermore, this research aims to improve the classification accuracy by removing the problem of slow weight updates caused by gradient saturation in a sigmoid function. This study proposes a modified Leaky ReLU activation function for the OCNN model along with the addition of Adam optimiser [6] to increase the accuracy of classification and reduction of training time, i.e. processing time of the model. This paper is organized as: In section 2, a literature review is presented with the state of art explanation. In section 3, the proposed system is explained with its improvement over the state of art solution. In section 4, the results of the proposed system are given. The results are discussed and compared with the other existing solution in section 5. Finally, we conclude the study in the section 6.

Literature Review
As given in the rules of Rechtschaffen and Kales (R&K), a sleep stage is classified as Wake (W), 4 stages from S1 to S4 for non-rapid eye movement (NREM), and rapid eye movement (REM). S3 and S4 are replaced by a single class as slow-wave sleep (SWS). That means S1 from NREM is the first stage of a sleep, S2 is the stage when the sleep begins without eye movements. In REM stage, eyes are closed, however they are moving fast [2] [5].
To understand the concept of neural network models for Sleep Stage Classification for detection of sleep stages and sleep related disorders, we studied relevant papers in the field which are analysed in the following subsections. These papers are organized into three classes according to their type: Extracting features from the input signal, Neural Network Models for sleep Stage Classification, and the state of art paper.

Extracting Features from the input signal
Phan et al. [7]  Sors et al. [6] proposed a method for sleep stage scoring using temporal context and feature extraction capabilities of CNN. This work was done to enhance the performance and to make the method available on portable and wearable devices. In addition, this method can be used in continuous monitoring of brain injury patients. This paper used a 1-Dimensional Convolutional Neural Network (1D CNN) model with temporal context that led to the study of Zhang et al. [3], and Fernandez-Blanco et al. [2] to develop end-to-end network training. This method achieved an accuracy of 87% and Cohen's Kappa(K) of 0.81. Furthermore, Fernandez-Blanco et al. [2] proposed an architecture that makes use of simultaneously recorded EEG signals to test the system separately with each signal and also as a combined input. As a result, the two signal inputs were found to be the most advantageous with an accuracy of 92.67% and Cohen's Kappa(K) of 0.84 on two channels. Werth et al. [11] proposed a model that improves the accuracy of sleep stage classification in infants by using an ECG R-peak detection algorithm. This work uses Adam optimiser to improve the learning rate and remove the learning rate decay in the model. It has been shown that Adam optimiser is the most efficient and superior performing optimization algorithms.
Erdenebayar et al. [12] compared the accuracy of six different neural network models and identified the most accurate method to classify events of sleep stage. As a result, the best performing model, 1D CNN, showed an accuracy of 99% in detecting class events. Mousavi et al. [5] proposed a method to enhance the accuracy and Cohen's Kappa coefficient of sleep stage classification using data augmentation on a raw EEG signal. This method eliminated the need of a feature extraction stage as the model is capable of learning proper features related to each case. This method non-linearizes the network by using a ReLU activation function as a result of which the problem of gradient saturation is avoided. The simulated model resulted in accuracy for 2 to 6 stage classifications as 92.95% to 98.10%.
Zhang et al. [3] enhanced the CNN method by introducing orthogonal weight initialisation. This model used time-frequency image representation to learn rich and diverse features of the input signal. This is done by using Hilbert-Huang Transform to convert 1-Dimensional signal into 2-Dimensional time-frequency representation, this resulted in accuracy of 88.4. This work is further discussed in the below section.

State of Art
This section presents the current system features (highlighted in blue broken lines in Figure 2 and the limitations (highlighted in red broken lines in Figure 2). Zhang et al. [3] proposed an OCNN system to be used instead of traditional CNN system in order to better learning rich and diverse features of the EEG signal. This system makes use of the Hilbert Huang transform that converts EEG data to a Time Frequency Image representation which better describes the EEG signal for a CNN. This paper conducted the research by fusing an autoencoder and the Squeeze and Excitation network into one block to improve the performance of the classification algorithm and dramatically decrease the training time. It provides an accuracy of 88.4%. This model consists of three stages as shown in Figure 2., i.e. Pre-processing, Time Frequency Image Representation, and Orthogonal Convolutional Neural Network [3]. Pre-processing: Pre-processing stage starts with resampling of the EEG signals at 64Hz to remove the resampling differences in different datasets. Notch filtering is applied at 50/60Hz so that the power line differences are cancelled out. Then to filter out the resampled signals to 0.5 -30 Hz, an eighth order Butterworth filter is used.
Time Frequency Image Representation: Zhang et al. [3] used time frequency image representation instead of EEG as an input to the CNN to better learn rich and diverse features. To achieve this, the first step is empirical mode decomposition, and then Hilbert Transform operate on the result to construct a time frequency signal. Eventually, the output is run through the autoencoder to reduce the dimension of the signal.

Orthogonal Convolutional Neural Network:
In this stage, deep weights are initialized to improve the learning speed. After that orthogonal regularization is performed. Then the Squeeze and excitation block is implemented to improve the classification performance and reduce the training time. The implementation of the SENet block helps increase the weight of useful features and decrease the weight of useless features.
Limitation: However, this model used a sigmoid function as the activation function. due to which the linear part of each neuron will have a very big or very small amount of value after some epochs of training. Since the gradient values become very small, weights are updated very slowly. To mitigate this, ReLU function needs to be used. This will directly result in an improvement in the classification accuracy as the weights are updated faster. With this model, Cite as: Akriti Bhusal, Abeer Alsadoon, P. W. C. Prasad, Nada Alsalami &Tarik A. Rashid (2022). Deep learning for sleep stages classification: modified rectified linear unit activation function and modified orthogonal weight initialisation. Multimed Tools Appl. https://doi.org/10.1007/s11042-022-12372-7 6 there is no optimisation involved. It is always beneficial to add an optimisation algorithm for more balanced classification and better training. The use of right optimisation algorithm will result in a reduction of the learning time, i.e. significant improvement in the processing time.
Limitation Justification: With the use of a ReLU function instead of a sigmoid function, the problem of gradient saturation can be removed and eventually, the classification accuracy can be increased. With the use of an Adam optimizer, the training time can be decreased as it can help to reduce the noise on the training signal data, which is beneficial for the portable sleep stage detection devices. This model presented a classification accuracy of 88.4% and 87.6% on two public datasets, respectively.
The OCNN Algorithm is implemented with 7 convolution layers, one fully connected layer and one SoftMax layer. Since this model also uses sigmoid as the activation function, gradient values become very small. The weights are updated very slowly, and this causes gradient saturation. To mitigate the gradient saturation, ReLU function can be used. This will directly result in an improvement in the classification accuracy as the weights are updated faster. Also, the processing time can be reduced using an Adam optimiser.
The sigmoid function is given by Equation (1) [3]: Where, e = the natural logarithm y = the output feature map can be expressed by Equation (2) Where, W * = Is an orthogonal matrix, used to store the initialised weights for each layer. The Convolution model implemented with 7 convolutional layers does not optimise the weights before initialising them. By using an Adam optimiser, the weights are optimised before they are initialised to the system which results in a reduced training time and processing time. Table  1 presents the algorithm of the state of art OCNN solution, while Figure 3 shows the flowchart of this solution. Step 1: Get the time frequency image representation of the signal from the pre-processing module.
Step 2: Feed the signal into the orthogonal neural network model of 7 layers.
Step 3: Send two copies of the output of OCNN, one to the SENet block and one to the combination block.
Step 4: If signal is received into the SENet block, feed it to the global pooling block and fully connected layers, else go to step 6.
Step 5: Feed the signal into the Sigmoid operator as in equation (1) Step 6: Combine the signals from SENet Block.
Step 7: Feed the output to Next layer in the OCNN model and repeat Step 3 to 7, 6 more times.
Step 8: Feed into the fully connected layer..
Step 9: Feed into the SoftMax Layer END  After reviewing different literatures regarding the sleep stage classification algorithm, and analysing the pros and cons of each method, it was found that the OCNN algorithm proposed by Zhang et al. [3], is the most effective algorithm to determine the rich and diverse features of an EEG signal. These features make use of orthogonal initialisation and orthogonal regularisation to significantly improve the learning speed of the training models. This paper also proposes a method to convert the EEG to a time frequency domain by using Hilbert-Huang Transform function. These methods improve the overall accuracy of the system and reduce the learning time. The OCNN algorithm makes it possible for the model to run on portable sleep devices as they are not complicated as the normal CNN methods. The proposed solution with Adam optimizer will help reduce the processing time by reducing noisy parameters. This feature has been adapted from the second-best solution [2]. It is always beneficial to add optimisation algorithm for more balanced classification and better training of the models. The proposed system consists of three major stages, as shown in Figure 4, called Pre-processing, Time Frequency Image Representation, and Orthogonal Convolutional Neural Network. These stages are explained with more details in the following paragraphs:

The Proposed System
Pre-processing: This stage removes the resampling differences in the different datasets which are used in the system. The signals are first resampled at 64Hz, then it is passed through a Notch filter at 50/60Hz so that the power line differences are cancelled out. Then to filter out the resampled signals to 0.5 -30 Hz, an eighth order Butterworth filter is used. The datasets are oversampled to eliminate the class imbalance in the sleep stages. This data is then fed into the next component.

Proposed Equation
Equation 3 represents the ReLU function. It has been used as the activation function for the neural network model in the second-best solution [5]. We replaced the sigmoid activation function used by the state of art by the ReLU function as it will get rid of the limitation of gradient saturation that occurs in sigmoid function. A ReLU activation function will ensure that gradient does not vanish, and the weights are updated faster. The removal of gradient saturation will contribute to improvement in accuracy of the sleep stage classification.
Equation (4) represents leaky ReLU function [6]. ReLU functions can have a problem of dying ReLU, it returns a zero for all negative values. There is a tendency for neuron to vanish if it has a negative value [13]. The Leaky ReLU function has a small slope to the negative values rather than a zero value. Equation (3) has been modified to Equation (4). This adds the negative value as a parameter to the model and thus reduces the training time by producing more balanced results.
Equation (5) represents Rectified Linear Unit (ReLU) function modified to include a slope of 0.1 for negative values. This allows the function to add negative value as a parameter to produce balanced results and improve the accuracy. We experimented with different values of α (0.1, 0.2, and 0.3) and ended up with 0.1 because it works best for our system, as shown in our results given in section 4.
We use this modified function as an activation function in equation (6) where the sigmoid function in equation (1) is replaced by a ReLU function in equation (6).
Equation (7) represents Adam optimisation algorithm [14], it is used to optimise each weight Wi before initialisation. This is done to update the initial weight wi by optimising it to Wi which represents the new optimised weight. This step will allow the model to learn useful features faster.
Equation (7a) gives the stochastic gradient descent that is calculated using the values of weighted average derivatives.   Equation (8) represents the modified Adam optimiser with learning rate lr = 3x10 -5 , β1 = 0.9, β2 = 0.999 [6]. The value for dwi is calculated from equation (7a). Equation (7) has been modified to equation (8) to incorporate the parameters on [6]. This will allow the proposed system to operate on recommended β1 and β2 values along with the learning rate of 3x10 -5 = − .
The modified output feature map 1,1 1 is given by equation (9). Equation (2) has been modified by us to include the modified weight initialisations derived from equation (8). This has been done to update the weights at each stage and optimise their values using the Adam optimiser. As a result, the training time is reduced.
Enhanced Sleep Stage Classification is represented by equation (10). It consists of MY which represents the modified activation function Leaky ReLU as represented in equation (6). It also consists of a modified output feature map as represented in equation (9) ESSC = +  (10) Two equations are proposed, first is the ReLU function which aims to avoid the gradient saturation problem that is faced by most sigmoid functions. As the sigmoid function in the state of art is replaced by a ReLU function, the gradient saturation problem does not exist anymore, and the convergence speed is increased along with better classification accuracy.
The second proposal is an addition to output feature map, which introduces optimisation to reduce the weight of useless features and amplify that of the useful features which leads to decreased learning time and increased accuracy and performance.
For the experiment, 2.2 GHz Intel Core i7 processor with 8 GB RAM and a Nvidia RTX 2070 GPU is used. The deep learning framework TensorFlow has been used with Python and Keras framework to implement this solution. Evaluate () method of the Keras Python package is used to calculate the accuracy. The fit generator () method of Keras package is used to calculate processing time. This is done by the subtraction of start time and end time is calculated to get the execution time of the system.  [17].

Databases
The Keras library first converts the edf data into a python readable array format, i.e. .npz that is a numpy gzip compression in the TensorFlow platform. Then we randomize the dataset into training and testing data. K fold cross validation was used with the value of k as 20. The sample data is randomly divided into k subsamples where one is used for testing and remaining for training. 15% of the data has been set aside for testing, and the remaining are used for training. After this, the 1-dimensional CNN model is initialized with orthogonal weights which are used to train the model. The trained model is stored as a .h5 file type which is a Hierarchical Data Format (HDF). The samples were scored manually according to the Rechtschaffen and Kales [18]. The accuracy is calculated as given in Equation 11 [3]: The formula for the standard deviation is

Area of Improvement
We proposed a Leaky ReLU function as an activation function along with a orthogonal weight initialisation method to avoid gradient saturation and to speed up the convergence to accurate result. This also helps to improve the classification accuracy. A sigmoid function is prone to reach its peak maximum or minimum value which leads to gradient saturation. This saturation stops the gradient propagation and results in improper weighting of features. Firstly, a ReLU function helps to avoid gradient saturation and to converge faster. This also helps improve classification accuracy. Secondly, the Adam optimizer allows the models to better train with reduced time frame which helps to improve accuracy and reduce training time. Adam optimisation achieves this by faster convergence and reduced oscillations increase momentum towards the optimal result.
The state of art uses sigmoid as an activation function, that has been replaced by a Leaky ReLU function in the proposed system to improve the accuracy of classification of sleep stages. Optimisation algorithm can help in minimizing the error function that depends on the model's learnable parameters. This step of optimisation is important to decrease the training time and improve the accuracy. The state of art system does not provide any sort of optimisation in training the model. Table 2 presents the algorithm of the proposed system, while Figure 5 shows the flowchart of the proposed OCNN algorithm. Step 1: Get the time frequency image representation of the signal from the pre-processing module.
Step 2: Feed the signal into the orthogonal neural network model of 7 layers.
Step 3: Send two copies of the output of OCNN, one to the SENet block and one to the combination block.
Step 4: If signal is received into the SENet block, feed it to the global pooling block and fully connected layers, else go to step 6.
Step 5: Feed the signal into the ReLU block using equation (3).
Step 6: Combine the signals from SENet Block and OCNN block and feed into Adam optimiser.
Step 7: Feed the output to Next layer in the OCNN model and repeat Step 2 to 7, 6 more times.
Step 8: Feed into the fully connected layer.
Step 9: Feed into the SoftMax Layer.

Results and Discussion
The results were compared with the state of art and other literatures based on accuracy, processing time, and F1 score. Table 3 shows a comparison of UCD dataset between the state of art and the proposed solutions. The sequence test for UCD dataset (given in Table 3) shows a 2.36% increase in accuracy. The change in classification accuracy for the classification stages Wake, S1, S2, SWS and REM are 2, 1, -2.5, 8.3 and 3 respectively. The accuracy for classification of S2 stage tends to fall but the accuracy of classification for Wake, S1, SWS and REM have shown significant increase. This might be related to the random selection of the subjects involved in the training and testing process. Using selective procedure, especially when creating the training set, might efficiently affect the accuracy. Furthermore, the accuracy for classification of SWS is too high (100%), the main reason for this excellent accuracy is related to the data used in the training and testing. Also, it is related to the types of subjects in the UCD database. All subjects were randomly selected from patients referred to the Sleep Disorder Clinic for possible diagnosis of apnea or primary snoring. Table 4 shows the sequence test for MIT-BIH database, there is 7.2 increase in accuracy from 88.1. Table5 shows the sequence test for EDF dataset, the accuracy increased by 3.32 from 83.9. For EDF Expanded dataset given in Table 6, the accuracy is increased by 2.74 from 85.86. In addition, the processing times are decreased due to faster learning and prediction capability, as given in Table 3, Table 4, Table 5, and Table 6. For example, the processing time for UCD database is decreased by 58s to 1192s. For MIT-BIH, the processing time is decreased by 49s to 1191s. For Sleep EDF database, it is decreased by 87s to 1203s. Also, for EDF Expanded database, it is decreased by 72s to 1188s.  An improvement in the accuracy has been seen as the model is trained with more datasets, as shown in Table3, Tables 4, Table 5, and Table 6. The classification results are compared with the manually labelled classification data to calculate the accuracy for Wake, S1, S2, SWS and REM stages. The processing time is compared from the output table for each dataset. It shows a steady decrease in processing time for each dataset. The accuracy is calculated as given in Equation 11, and the mean and standard deviation of the sample data of four different stages of sleep are calculated using Equation 12.   The results of our proposed system given in Table 3, Table 4, Table5, Table 6 show that the improvement in the classification accuracy of S1 and REM were lower than the improvement of the other stages like Wake, S2, and SWS. In table 3, for UCD database, although the accuracy of classification for Wake, S1, SWS and REM have shown significant increase, however, the accuracy for classification of S2 stage tends to fall. Thus, the diverse and features of S1 and REM require further research and improvement. Furthermore, currently, we randomize the dataset into training and testing data. However, using selective procedure specially when creating the training set, might affect the classification accuracy of our proposed method.
The improvement in accuracy is a contribution of the activation function ReLU that has reduced the problem of gradient saturation in state of art. Furthermore, the reduction in processing time has been achieved through the use of optimised weights that has significantly reduced the amount of time taken to reach to the optimal result for each neuron. Table 7 summaries those results and gives a comparison between the state of art and the proposed solutions. From Table 7, the proposed system increases in accuracy due to faster and richer feature extraction than the state of art systems. Also, the proposed system decreases in processing time due to faster learning and prediction capability. Thus, our Enhanced Sleep Stage Classification system can be used for wearable sleep devices, such device can be used for home sleep monitor.

Contribution 1
Replacement of the sigmoid function by a Leaky ReLU function to avoid gradient saturation problem and to increase convergence speed and accuracy.
= { > 0 0.1 ≤ 0 The state of art uses a sigmoid function which is prone to suffer from gradient saturation.

Contribution 2
Addition of an Adam optimiser helps achieve faster convergence towards useful classification. This helps reduce noise which in turn can result in reduction of training time. The state of art does not provide a method for optimisation of signals.

= − .
Where represents each initialised weight represents the step size (7)

Conclusion and Future Work
The proposed solution aims to improve the sleep stage classification accuracy by removing the problem of gradient saturation. Replacement of the sigmoid function by a Leaky ReLU function can avoid the gradient saturation problem and increase convergence speed and accuracy. Along with this, the proposed solution aims to use optimised values as feature weights to reduce the processing time. Adam optimiser helps to reduce noise which in turn can result in reduction of training time. The proposed model shows an overall increase in accuracy and reduction in processing time. The limitation of the State of Art has been solved in this research by using Re. The comparison of UCD dataset between the state of art and our proposed method shows a 2.36% increase in accuracy and 58s decrease in the processing time. For MIT-BIH database, there is 7.2% increase in accuracy and 49s decrease in the processing time. For EDF dataset, the accuracy increased by 3.32% from and the processing time is decreased by 87s. Also, for EDF Expanded dataset, the accuracy is increased by 2.74%, and the processing time is decreased by 72 second compared with the state of art solution. The proportion of true positive results is calculated to obtain the accuracy where true positive and true negative metrics are used. In addition, it can be concluded that the best performing models constituted of 1-Dimensional CNN models.
Future research includes the application of advanced CNN models that will allow extraction of richer and more diverse characteristics from the raw signal to further improve the accuracy of the system. A further field of study is in the direction of maintenance of dynamic isometry with the use of ReLU functions.
To improve our results and the learning process in general, more databases can be used, for example, the ISRUC-Sleep dataset. In addition, currently, we randomize the dataset into training and testing data. However, using selective procedure specially when creating the training set, might efficiently affect the learning and the generalization abilities of our proposed method.


Is my Driver Observation Model Overconfident? Input-guided Calibration Networks for Reliable and Interpretable Confidence Estimates

Driver observation models are rarely deployed under perfect conditions. In practice, illumination, camera placement and type differ from the ones present during training and unforeseen behaviours may occur at any time. While observing the human behind the steering wheel leads to more intuitive human-vehicle-interaction and safer driving, it requires recognition algorithms which do not only predict the correct driver state, but also determine their prediction quality through realistic and interpretable confidence measures. Reliable uncertainty estimates are crucial for building trust and are a serious obstacle for deploying activity recognition networks in real driving systems. In this work, we for the first time examine how well the confidence values of modern driver observation models indeed match the probability of the correct outcome and show that raw neural network-based approaches tend to significantly overestimate their prediction quality. To correct this misalignment between the confidence values and the actual uncertainty, we consider two strategies. First, we enhance two activity recognition models often used for driver observation with temperature scaling-an off-the-shelf method for confidence calibration in image classification. Then, we introduce Calibrated Action Recognition with Input Guidance (CARING)-a novel approach leveraging an additional neural network to learn scaling the confidences depending on the video representation. Extensive experiments on the Drive&Act dataset demonstrate that both strategies drastically improve the quality of model confidences, while our CARING model out-performs both, the original architectures and their temperature scaling enhancement, leading to best uncertainty estimates.

I. INTRODUCTION
W ITH the rapidly growing accuracy of driver observation models [1], the existing gap between the published methods and their applications in practice makes us wonder about important performance aspects potentially being overlooked. When examining the previous research, we make two observations. First, the existing driver activity recognition algorithms are highly driven by the top-1 accuracy [1]- [8], skipping other relevant metrics, such as the reliability of their confidence values. Second, recent fundamental deep learning This work was supported by the Competence Center Karlsruhe for AI Systems Engineering (CC-KING, www.ai-engineering.eu) sponsored by the Ministry of Economic Affairs, Labour and Housing Baden-Württemberg.
Authors are with Institute for Anthropomatics and Robotics, Karlsruhe Institute of Technology, Germany (e-mail: firstname.lastname@kit.edu).
Corresponding author: Alina Roitberg.  Fig. 1: Deep neural networks have seen a surge in popularity in driver observation, but worrying evidence indicates that such models produce unjustifiably high-confidence predictions. Overconfident models imply that if a network predicts certain secondary behaviour with > 99% confidence (which is indeed very common), the prediction is oftentimes correct in much less than in 99% of cases. This figure depicts an example of observed predictions and confidence values of a driver activity recognition CNN during a single driving session. If we directly use the probability estimates provided by the original CNNs, we end up with unjustifiably high confidences, which can be very damaging in practice. Temperature-based methods [9] apply a fixed scaling to the CNN probability estimates in order to obtain more realistic values. Our approach, CARING, goes one step further, and dynamically infers a suitable scaling factor depending on the current observation, leading to more reliable confidences.
research raises alarm about neural networks being notably bad at detecting ambiguities [9]- [12]. Despite the impressive gain in accuracy on modern driver activity recognition datasets [1], [5], [13], examining how well the confidence values of driver behaviour understanding models indeed reflect the probability of a correct prediction (see Figure 1) has been overlooked in the past and is the main motivation of our work.
Humans have a natural intuition about probabilities [14]: If a neural network reports that the driver is "talking on the phone" with 99% confidence, we tend to take this prediction for granted. In neural networks, the output of the last fullyconnected is usually normalized through the Softmax 1 function 1 Softmax function is often applied on logits (the output vector of the last layer of a classification network, where each value represents a category score) and normalizes them to sum up to one by computing the exponents of each output and then normalizing each of them by the sum of those exponents.
to sum up to one, therefore resembling prediction probabilities. However, blindly interpreting these values as probabilities of the outcome being correct would be naive, as the Softmax scores are not calibrated and merely optimized for a high top-1 accuracy on a static set driver of behaviours. The output Softmax vector appears to hold probabilities of the individual classes, but they do not necessarily match the true confidence of the model [9], [15]. Furthermore, worrying evidence from deep learning research highlights the problem of model miscalibration, suggesting that raw neural network confidences tend to be biased towards very high values for both, correct and incorrect predictions [9], [15]. In real-life driving applications, on the other hand, models need to be more reserved: wrong high-confidence decision can lead to tragic outcomes. At the same time, indicating high classification uncertainty and reacting accordingly is the better choice. In this work, we equip driver observation frameworks with building blocks for reliably quantifying model confidence.
We aim to highlight the need for interpretable and reliable uncertainty measures as a means for identifying misclasifications inside the vehicle cabin. Although this area is seeing growing attention in the field of general image recognition [9], [11], it is underresearched in video classification and especially driver observation. To achieve this, we integrate the reliability of model confidence in the large-scale driver activity recognition benchmark Drive&Act [1] and develop models which learn to convert oftentimes overconfident uncertainty values of the original networks into reliable probability estimates.
Why driver activity recognition? Rising levels of automation increase human freedom, leading to drivers being engaged in distractive behaviors more often while the type of activities become increasingly diverse. For example, working on laptop or reading magazine behind the steering were almost unthinkable until now, but these behaviours become more common as the driver is gradually relieved from actively steering the car. Although distractions become safer as the vehicle becomes more intelligent, this change does not happen from one day to another and is a rather long-lasting transformation [16]. Over-reliance on artificial intelligence might lead to catastrophic consequences, and, for a long time, the driver will need to intervene in case of uncertainty [16]- [18]. However, there are important long-term application scenarios of driver activity recognition even in fully-autonomous cars. For example, understanding the situation inside the vehicle cabin may increase comfort, e.g., by adjusting the driving style if the person is drinking a hot drink or being an intuitive communication interface via gestures. Applications of driver activity recognition models depend on the degree of vehicle automation [19].
We summarize four main use-cases for applications of driver activity recognition [1], [20], [21]: • Improved safety through identified distraction. Recent studies highlight that current activity directly affects human cognitive workload in both, general-and driving context [22]- [24]. For example, Deo and Trivedi [24] suggest that certain secondary activities such as interacting with the infotainment unit negatively impact the perceived readiness-to-take-over. Therefore, the key application of such algorithms at SAE levels 0 to 3 [19] is the assessment of human distraction and reacting accordingly, for example, with a warning signal. • Increased comfort through automatic driver-centered adaptation. With the automation rising to SAE levels 4 and 5, increasing driver comfort by automatic adaptation of the vehicle controls becomes the more important usecase. For example, movement dynamics might automatically adjust depending on the detected activity, e.g., softer driving if the person is drinking tea or sleeping. • Novel intuitive communication interfaces. Visually recognizing driver gestures might lead to novel communication interfaces inside the vehicle, serving as a more intuitive alternative for the central console, as previous research identifies hand signals as a highly convenient way for human-machine interaction [2], [25], [26]. • Identifying and preventing dangerous maneuvers.
Since the majority of traffic fatalities are caused by inappropriate driving events induced by humans [27], [28], a further safety-related application of driver activity recognition during manual driving is intention prediction. Timely anticipation of driver intention offers a possible solution to prevent potential accidents at an early stage, allowing ADAS to notice that the person e.g. is going to induce a dangerous turn and prevent the accident by taking over the control or notifying the driver [29].
A Note on Terminology While various meanings have been given to the term uncertainty, we specifically refer to the "classication uncertainty of a discriminative classification model" as to inverse of model's confidence [30], [31]. We follow the probabilistic definition of model's confidence [9], [32]- [34], which is a numeric value depicting a probability estimate of a class membership in the context of multi-class categorization. Lastly, the reliability of model confidence represents the quality of the observed confidence estimates, where we adopt the mathematical formulation of [9], which intuitively means that if a network produces a confidence value of 95% it should indeed be correct 95% of times, (i.e.this would also be the value of model's accuracy). The exact mathematical formulation of this definition is provided in Section III-A. learns to infer an instance-dependent scaling factor, which is then used to scale the logits of the original network, therefore "softening" the resulting confidences and leading to much more realistic confidence estimates for driver observation. models with the temperature scaling approach [9] -an offthe-shelf approach for model confidence calibration in image classification. This approach learns one global scalar τ through which the network logits are divided to obtain better confidence estimates. (3) We expect, that taking the video input representation into account gives us cues which are helpful for estimating prediction uncertainty, and present a new method named Calibrated Action Recognition with Input Guidance (CARING). A novel aspect of our approach is that CARING entails an additional calibration network, which learns to produce flexible temperature values T (z) dependent on the input z. In contrast, [9] uses one global scalar for scaling the confidences, so that the logits are always divided by the same value, while we dynamically infer the temperature values which suit currently observed state. Despite disregarding the input, temperature scaling alone leads to much more meaningful confidence values, while our input-dependent CARING model excels these improvements, reducing the expected calibration error to only ∼ 5% on Drive&Act and to only ∼ 2.5% in case of sufficient training data. However, our results also showcase room for improvement in case of underrepresented categories where the confidence-accuracy mismatch remains high even after significant improvement through CARING.

Contributions and Summary
This paper is an extension of our conference publication [35], which has been expanded with specific focus on driver behavior understanding, a detailed description of the proposed CARING method, and an extended set of experiments and analyses.

II. RELATED WORK A. Driver Action Recognition
Driver activity recognition is an essential task in Advanced Driving Assistance Systems (ADAS), aiming at recognition of normal-and abnormal driver behaviors, such as eating, phoning, and smoking. According to [36], over 90% of vehicle crashes are due to drivers' abnormal behaviors and driving errors in the US, while the total number of traffic accidents might be decreased by 10 − 20% if a good driving assistant monitoring system would be in place [37]. Similar to other computer vision fields, existing research works in driver action recognition field can be also divided into two main groups: (1) approaches based on manually defined features and (2) deep learning based approaches, which learn intermediate representations end-to-end.
The general goal of the above research is to improve the recognition accuracy on driver activity recognition datasets without considering whether the network confidence indeed reflects the likelihood of a correct prediction (Figure 4 demonstrates the confidence-accuracy mismatch of P3D on the Drive&Act [1] dataset revealed by our study).
In our work, we go beyond the incentive of high top-1 accuracy and aim for driver activity recognition models with realistic confidence estimates. Keep in mind, that while our method leads to far more realistic uncertainty estimates, the accuracy is not impacted, as the transformation scales the output without changing the category order.

B. Detecting Model Misclassifications
Since real applications of deep CNNs need good quality of confidence measures, several researchers have highlighted this requirement [10]- [12]. However, this issue still lacks attention in both, driver-and general activity recognition. Still, multiple works have addressed this topic in classical machine learning [67]- [69], image classification [9], [11], [15], and person identification [70], offering useful insights for applying these techniques for video-based driver observation. A group of those methods follows the Bayesian approach, such as Monte Carlo Dropout sampling [15] or using an ensemble of models to estimate uncertainty [71]. Compared to dropout sampling, which gives gaussian distributions to assess model uncertainty, calibration-based techniques [9], [69], [72]- [75] return a single confidence value. Calibration-based methods hold several advantages: they do not require sampling and are therefore less computationally expensive and their result is calibrated, meaning that the resulting values ideally match human interpretation of probabilities (i.e. the likelihood of a correct outcome). Guo et al. [9] compared several calibrationbased approaches such as isotonic regression, histogram binning, and Bayesian quantile binning regression on image and document classification tasks. In their work, they introduced temperature scaling -an approach, which is a variant of the Platt Scaling approach [69], in which a single global parameter is learned on a validation set, and then utilized to scale the network logits and make the output confidence closer to the actual accuracy. Temperature scaling was simple but proved to be highly effective, outperforming far heavier approaches [9] and later found success in natural language processing [74] and medical applications [76].
We for the first time integrate different building blocks for identifying the faithfulness of model confidences for driver activity analysis. In particular, we augment driver activity recognition networks with uncertainty estimation through (1) the raw Softmax confidences [11], (2) the temperature scaling technique of Guo et al. [9], and (3) our newly proposed CAR-ING model, which, in contrast to [9], features input-driven confidence transformation. While in temperature scaling, the logits are always divided by the same global value, our CAR-ING model dynamically infers different scaling parameters for different inputs through an additional calibration network.

III. UNCERTAINTY-SENSITIVE ACTION RECOGNITION
We aim to explore reliability of model confidence in the field of driver observation, where the existing frameworks have been mostly motivated by high accuracy [1], [2], [37], [62]. First, we formalize the problem and equip the Drive&Act benchmark [1] with multiple metrics linked to the confidence quality (Section III-A). We then combine two 3D CNNs (model description in Section III-B) often used for driver activity recognition, with three different strategies for quantifying prediction confidence: using raw Softmax output (Section III-C), transforming the confidences through temperature scaling (Section III-D) and our newly proposed CARING model, which learns to infer optimal scaling parameters depending on the input (Section III-E).

A. Problem Definition: Reliable Confidence Measures
Intuitively, the confidence of a classification model should reflect its accuracy, i.e., reliable confidence should indicate the probability of a prediction to be correct. Based on a driver observation x, we predict an action class a pred with model confidencep(a pred ) ∈ [0, 1], a ∈ A {1,...,m} being the set of possible driver behaviour classes. Provided with the groundtruth label a true , we consider our model confidence to be well calibrated and reliable if it, on average, reflects the probability of a successful outcome P(a pred = a true ). We follow the definition of [9] and assume that the confidence quality of a model is perfect if the following condition is met: The model therefore delivers reliable probability estimates if the mismatch between the average model's confidence and the prediction accuracy is low (the right side of Figure 2 illustrates such confidence-accuracy disarray).
In practice, perfect model calibration and even its perfect evaluation are not possible, since Equation (1) is defined on the continuous interval [0, 1] while we only have a finite amount of confidence estimatesp(a pred ). However, this value can be approximated with different techniques, e.g., discrete partitioning of the probability space. We consider three different metrics: Expected Calibration Error (ECE) [9], the presumably most popular metric for quantifying confidence discrepancy, the normalized Brier score [77], and Negative Log Likelihood.
Expected Calibration Error (ECE). One way to solve the issue of continuous probability space in Equation (1) is quantizing the [0, 1] interval into equally sized segments K with i ∈ 0, ..., K − 1 (K = 10 in this work) and calculating the average accuracy and confidence among all N segi samples falling into the same confidence segment (see Figure 3). In case of perfect confidence calibration, the accuracy-confidence distance of the individual segments should be zero. The Expected Calibration Error (ECE) [9], leverages such partitioning and measures the absolute difference between accuracy acc(seg i ) and average confidencê p(seg i ) for each individual segment seg i , followed by averaging among all segments weighted by the number of samples in each of the K segments. Formally, ECE is computed as: where N total denotes the number of samples in all segments.
In deep learning research, ECE is perhaps the most widespread measure of model confidence reliability [9], [75], [76], [78], and we therefore also view it as our primary performance metric.
Reliability Diagrams. ECE can be effectively visualized using reliability diagrams (Figure 3), where the X-axis represents the probability space discretized into K bins. In each bin, we visualize a bar with size matching the empirically computed accuracy of samples, which confidence fell into this segment.
Since the accuracy and the confidence match in perfect case, the bars should ideally match the diagonal. Our results in Figure 3 showcase, that for an out-of-the-box (illustrated on the left), the accuracies are significantly below the confidence value. The original model is therefore overly confident.
Brier Score. Another metric for quantifying model confidence quality is the Brier score [77], initially developed to quantify weather forecasts reliability and later adapted as a general confidence reliability measure. The Brier score represents squared error between the estimated probabilities and the one-hot encoding of the ground-truth data. As the original definition has different boundaries for binary and multi-class cases [77], we use the normalized version of the Brier score, where the values lie between 0 and 1, formally defined as [79]: where N total is the total number of samples, m is the number of possible driver activity classes,p(a, i) is the model probability estimates of the ith sample belonging to category a and C a,i ∈ 0, 1 is 1 if a is the ground-truth class of the ith sample, otherwise 0. Note, that previously published research describes Brier score as a metric is insensitive towards rare classes in the test set [78] and should be taken with caution since in real-life datasets the categories are rarely equally distributed (which is also the case in Drive&Act).
Negative Log Likelihood (NLL). Negative Log Likelihood, which is also leveraged for optimizing the classifier itself, can be used to measure quality of the uncertainty estimates [9] and is therefore reported in our study.

B. Backbone Neural Architectures
We evaluate model confidence reliability on two widely used architectures, the Pseudo 3D ResNet [51] as well as the Inflated 3D ConvNet [52]. Both networks have proven to be successful in driver observation [1], [13]. While the P3D  ResNet decouples spatial and temporal convolutions by either using a (3 × 3 × 1) filter kernel for the spatial domain or a (1 × 1 × 3) filter kernel for the temporal domain, the I3D Network makes use of filter kernels which perform spatial and temporal convolutions at the same time. Another structural difference, is that P3D ResNet has an impressive depth of 152 layers enabled through use of residual connections to ease the gradient flow, while I3D has 27 layers and stacks multiple Inception modules, which perform different types of convolutions in parallel.

C. Softmax Output as Confidence Measures
Similar to other neural networks, the last fully-connected layer are referred to as a logit vector y. The individual values y a are scores marking how likely the activity a is indeed the current class. The raw logit vector is not normalized. In order to mimic a probability function (have values between 0 and 1 and sum up to 1), it is commonly normalized using Softmax. Although these scores are rather pseudo-probabilities, they are often used as model uncertainty estimates [11]. The confidence estimates in this case are obtained as:

D. Calibration via Temperature Scaling
In image recognition, an off-the-shelf strategy for improving confidence estimates is temperature scaling [9]. Temperature scaling leverages a single, global parameter τ to scale the logit vector prior to Softmax normalization, with the final estimates becoming:p This introduces the properties lim τ →∞p (a pred ) = 1/m and lim τ →0p (a pred ) = 1, meaning that τ is a parameter which either decreases confidence (τ > 1) or increases confidence (τ < 1). After the classifier is trained to assign the categories in a standad way, the model weights are frozen and the parameter τ is optimized on a held-out validation set also using Negative-Log-Likelihood. Note, that this scaling affects  Fig. 4: Overview of the Calibrated Action Recognition under Instance Guidance Model (CARING). CARING is an additional neural network which learns to infer the scaling factor T depending on the instance representation. The logits of the original activity recognition network are then divided by T , giving better estimates of the model uncertainty. In our implementation, the intermediate vector z is extracted from the 9th inception block of the I3D model, while for P3D we use the layer before the last fully-connected layer.
probability estimates of all classes equally and does not alter the order of the top-k categories or the final top-1 prediction of the model. This means that the accuracy of the model stays the same. Although the method is remarkably simple, it had been extremely effective for obtaining well-calibrated image recognition CNNs, surpassing more complex approaches [9]. We learn a suitable temperature parameter τ using Gradient Descent with a learning rate of 0.01 for 50 epochs.

E. Calibrated Action Recognition with Input Guidance
Next, we introduce a new approach for obtaining good uncertainty estimates by learning to scale the logits depending on the input. While in the next section our experiments will reveal, that temperature scaling significantly improves the confidence reliability on its own, it does not consider the current observation when transforming the confidences, as the logits are always divided by the same temperature scalar τ . Our idea is leveraging information present in the current driver observation, as it may carry important hints about the prediction reliability (i.e. the sample might contain visible noise). Therefore, we propose to infer an individual input-dependent scaling factor τ (z) during inference instead of learning a single global parameter τ , resulting in the confidence calculation. Our model and the temperature scaling approach [9] therefore have one crucial difference: the scaling factor is not fixed but varying dependent on current input. We therefore dynamically infer the scaling parameter T (z) onthe-fly at test-time depending on the video representation z. Therefore, the transformed logits become y scaled = y/T (z).
To enable such input-dependent inference of T (z), we propose an additional calibration neural network, which we refer to as CARING (Calibrated Action Recognition under Input Guidance), as it guides the logit transformation depending on the video input. An overview of our model is provided in Figure 4. CARING is a lightweight regression network with two fully-connected layers and the output of the second layer being a single regressed value. The final scaling factor is obtained by applying the relu activation and adding 1 to assure T (z) ≥ 1, so that the probability estimates are softened. The input-dependent temperature T (z) is therefore obtained as: where W 1 ,W 2 depict the weight matrices, and b 1 , b 2 are the bias terms, and z is an intermediate representation of current input. We leverage the intermediate feature vector of the backbone classification network, which have dimensionality of 1024 and 2048 for Inflated 3D ConvNet and Pseudo 3D ResNet, respectively. After we regress the input-dependent temperature T (z), the logits are divided by it before the Softmax function and our final confidence estimates become: Training procedure. Conceptually, our proposed architecture comprises two main components: 1) the standard classification network aimed at assigning the correct driver behaviour to the input video and 2) an additional calibration network used to scale the classifier logits and produce more realistic confidences. First, we train the classifier following the standard procedure and Negative-Log-Likelihood (NLL) optimization.
In the second step, the classifier weights are frozen and the calibration network is optimized on a separate, held-out validation set which examples were not present during the classifier training. Different losses can be used for training such network, including the NLL loss [9], Maximum Mean Calibration Error (MMCE) [80], Brier Loss [77] and Focal Loss [81]. We selected the NLL loss in our training, since it is presumably the most popular choice [9], [74], [76] for confidence calibration and is also used in the temperature scaling approach of [9] to which our model is compared. By freezing the model weights and only training our lightweight calibration model on a validation set, a realistic distribution of correct and incorrect predictions is provided and being overly confident about these predictions would increase the loss. In the same fashion as temperature scaling, CARING is a post-processing technique for improving model probability estimates. It does not influence the accuracy, as the order of the logit categories does not change (we do divide by different temperature values for different observations, but all the logit vector values are divided by the same scalar). We optimize CARING with a learning rate of 5e−3 and a weight decay of 1e−6 for 300 epochs on a held-out validation set using the previously mentioned NLL loss while maintaining the weights of the backbone classification network frozen. The complete process is described as pseudo-code in Algorithm 1. Algorithm 1: The CARING training and evaluation procedure in the specific case of using I3D as a backbone and evaluation using the Expected Calibration Error (ECE) metric.
For the intermediate representation vector z, we leverage the output of the 9th inception block of I3D. We average the output over the temporal dimension to reduce the vector size, resulting in 1024-dimensional vectors. For P3D, we use the layer before the last fully-connected layer (the output size is 2048). Furthermore, we observe that the CARING performance does not alternate significantly if the representations were extracted at medium or late network depths, but the quality declines at earlier layers. Note, that the size of z directly impacts computational complexity of CARING. For our configuration, (i.e., 1024-dimensional z in case of I3D), CARING comprises 66.7 parameters and requires 0.13 MFLOPS for a forward pass, which is a small overhead given the significantly larger size of the classification network (12.06 M parameters and 107.9 GFLOPS for I3D).
Why is training the calibration network with NLL loss effective against miscalibration? Since both the classifier backbone and the CARING model use the NLL loss, we need to clarify why such optimization leads to unrealistic confidences after the standard classifier training but gives proper confidence estimates after the calibration. NLL itself indeed reflects confidence miscalibration [9] and we therefore use it as one of our metrics. The main reason for the confidence-accuracy disarray rising during the classifier training is overfitting on the training   set combined with the target labels being exclusively 0 or 1 [9], [80]. Target labels for classification training are commonly 0 or 1 (one-hot encodings of the ground truth). The high capacity of modern neural architectures leads to overfitting to the onehot encoded labels, which is considered the key reason for model miscalibration [9], [81] (although other factors have been witnessed, such as batch normalization). By training a model to learn Softmax scores which mimic binary targets, it is incited to provide overly confident results. After the classifier training has converged in terms of accuracy (which is usually very high on the training data), it further optimizes the NLL-criteria to match the 0/1 labels, which will usually be 1 for the predicted class on the training data, leading to overly confident models. Consequently, the classifier becomes overly confident due to the unrealistically high amount of the correct 1-label predictions. By freezing the model weights and only training our lightweight CARING model on a held-out set, we bypass the issue of overfiting to 0/1 labels due to high model capacity. A realistic distribution of correct and incorrect predictions is therefore provided and being overly confident about these predictions would increase the loss. Note that overfitting is prevented since CARING does not influence the model accuracy (since the classifier is frozen and the logits order stays the same).
Does our CARING model indeed scale different inputs differently? Although CARING always takes in representation of the video input, it could theoretically ignore it and fall back learning a constant value, therefore converging to conventional temperature scaling. In order to validate if our model actually infers different τ (z) for different inputs, we analyze the Expected Calibration Error (Figure 5a) in combination with the mean and standard deviation of the scaling factor τ (z) (Figure 5b) computed over all validation samples during each CARING training epoch. Figure 5 reveals that while the ECE decreases during optimization, the standard deviation of the individual scaling factors increases, indicating that varying τ (z) is indeed beneficial for confidence reliability, which will also be validated empirically in the upcoming section.

IV. EXPERIMENTS
In this section, we for the first time benchmark modern driver activity recognition models with regard to their abilitiy to identify failure cases through their own probability estimates. To this intent we for the first time consider metrics described in Section in the context of driver activity recognition III-A. In a variety of settings featuring different input modalities and amount of training data, we benchmark two prominent video classification CNNs, against their versions equipped with the temperature scaling method [9] and our proposed CARING approach. We hope that by establishing this benchmark we will motivate researchers to rethink the roles of uncertainty estimates in driver observation.
This Section is structured as follows. First, we give an overview of the evaluation testbed and the underlying data (Section IV-A). Next, we provide a thorough evaluation of confidence estimates for driver activity recognition, focusing on the main evaluation setting of Drive&Act (a single NIR modality) and distinguishing between different amount of available training data (Section IV-B). Since different activity types might be relevant for different driving applications, Section IV-C is devoted to individual category-specific outcomes. Then, in Section IV-D we focus on recognition from different sensor types and placements within the vehicle cabin, demonstrating generalization capabilities of our model. Finally, Section IV-E provides qualitative analyses of the resulting distributions of model confidences.

A. Benchmark settings
Currently, there is no established evaluation scheme targeting the reliability of confidence values in the context of driver observation. Thereby, we adapt the evaluation protocols of Drive&Act [1] -a large-scale driver activity understanding testbed, to our task. Drive&Act [1], is a multimodal benchmark for driver activity recognition covering nine synchronized views and three modalities (near-infrared, depth, and color). Drive&Act comprises 34 fine-grained activity classes on the main evaluation level. Yet, the categories are heavily unbalanced, which is typical for application-specific datasets: the number of samples ranges from only 19 examples of taking laptop from backpack to 2797 instances of sitting still. Considering that CNNs often suffer when learning from few examples, the behaviors are sorted according to their frequency in the dataset and separated into common (top half of the classes) and rare (the bottom half) ones. The models are subsequently evaluated in three different modes: incorporating all activities as in the usual case, using only the overrepresented-, or only the rare categories.
For P3D-and I3D models, the input are snippets of 64 consecutive frames. If the original video segment is longer, the snippet is randomly chosen during training and at the center of the video at test-time. If the segment is shorter, the last frame will be repeated until the 64-frame snippet has been filled.
Following the problem formalization in Section III-A, the standard accuracy-driven evaluation protocols [1] have been extended with the expected calibration error (ECE), which depicts the divergence of model confidence score from the   [9]. Overall, we average results over the three spits.

B. Confidence estimates for driver activity recognition
In Table I, we compare the described CNN-based activity recognition approaches among themselves and with their uncertainty-aware versions in terms of ECE, Brier Score, and NLL for overepresented, rare, and all classes in Drive&Act. First, the conjecture has been confirmed that native activity recognition architectures yield unreliable confidence predictions. Evidently, confidence scores produced by I3D score have a misalignment of 15.97% for Drive&Act. Similar problems have been observed in P3D: 21.2% ECE on Drive&Act, an exceedingly high error for safety-critical driving applications.
Model reliability has been clearly improved by learning to attain proper probability estimates, since all of the uncertaintyaware versions exceed the original Softmax values. To our surprise, while I3D has better initial uncertainty estimates than P3D, i.e., 15.97% for I3D in contrast with ECE of 21.09% for P3D, it seems that P3D has a stronger response to both, temperature scaling and CARING approaches than I3D, resulting ECE of 5.26% for CARING-P3D and 6.02% for CARING-I3D. However, this difference is less than 1%, and thereby one would advocate to use I3D due to its higher accuracy in most cases [1], [51], [52]. While the expected calibration error is deemed to be essentially important for real applications, one must realize that this metric is complementary to model accuracy and both measures should be taken into consideration when selecting the suitable model for deployment. We further mark, that both temperature scaling and the CARING method do not influence the model accuracy, as illustrated in Sections III-D and III-E. Regarding Pseudo 3D ResNet, we have achieved an overall accuracy of 54.86% on the validation split and 46.62% on the test split of Drive&Act, which does not change after our uncertainty-inspired adaptations. In line  with [1], I3D reaches a higher accuracy of 68.71% on the validation set and 63.09% on the test set. 2 It arrives as expected, that the model confidence reliability is correlated to the amount of training data, as seen in the distinguished areas for common, rare, and all classes of Drive&Act (Table I). A case in point lies in the common classes setting, which encounters the lowest expected calibration error for both original and uncertainty-aware architectures, i.e., 13.38% for I3D and 5.26% for CARING-I3D. Using intermediate input representation through our CARING calibration network results in the best probability estimates on both datasets and in all evaluation settings. More precisely, with the proposed CARING strategy, our model clearly stands out in front of the raw neural network and the temperature scaling-based one, surpassing them by 9.95% and 2.53% on Drive&Act. The differences are smaller when considering the Brier Score metric, presumably because it is especially insensitive to rare categories [71], which, however, might be of high importance in driver observation, as uncommon events are often linked to distraction. Still, also in terms of the Brier score, the advantages of the CARING model are evident, while the largest performance gain is achieved for underrepresented classes. Overall, our experiments highlight the benefits of learning to attain probability scores depending on the input.
Moreover, we assess model performance for the individual classes by examining the top five common and the five least frequent activities in Drive&Act, whose results are displayed in Table II in a separate manner. In addition to ECE, we include the accuracy for samples belonging to the individual classes, the average confidence value achieved with the corresponding model, and the difference between them (denoted as ∆Acc). While a such global confidence-accuracy disagreement 2 The slight deviation from the accuracy reported in the original work [1] (between 0.18% and 1.3%) is due to random factors in the training process. is interesting to consider (and is 0 for a perfectly calibrated model), it should be interpreted with care, as it may bring about an imprecise illusion of good confidence calibration, as e.g., many samples with too high and too low confidence values may cancel each other out due to the averaging effects. Reliability of the confidence scores has been significantly improved via the CARING method and is linked to the amount of training samples and the accuracy. Models have clear issues when learning with few examples, and have a limited performance, e.g., 76.00% for I3D and 59.80% for CARING-I3D ECE in dealing with putting laptop into backpack. In contrast, for both, over-and underrepresented classes, the ECE of easy-to-identify activities (i.e., the ones with high accuracy) is much lower. Before calibrated, the average confidence value is always higher than the accuracy (positive ∆Acc), revealing that the models are too optimistic in their predictions. Interestingly, after the CARING conversion is executed, the average model confidence becomes lower than the accuracy for some classes, such as eating. In this sense, CARING models are more conservative in their assessment of prediction certainty.

C. Results for different driver behaviours
We now look at different driver behaviour types individually, with the exact ECE for the original classifier and our CARING model provided in Figure 6. We observe in Figure 6, that nearly all secondary behaviours exhibit better quality of the confidence estimates with the proposed CARING model, but certain behaviours still have a large room for improvement.
As previously validated in Table II, the realism of confidences is especially good for more discriminative behaviors (which also obtain higher accuracies) and classes with sufficient training examples. For instance, the activity eating has around 800 examples in Drive&Act [1] and a much lower ECE compared to a similar category preparing food, of which there are only ∼ 50 examples. Especially a mixture of low distinctiveness (e.g., opening backpack vs. taking laptop from backpack) and low number of training examples are fatal for a category: taking laptop backpack is off by 70% in terms of ECE (with CARING), which goes up to 85% without additional confidence calibration. In other words, the model did not correctly predict the class in nearly all cases of this behaviour, while the estimated confidence was very high.

D. Observation results from alternate views and modalities
All activities in Drive&Act are captured by a set of six cameras, five lightweight near-infrared (NIR) cameras and one Kinect camera. The NIR cameras covers several different views from the interior of the vehicle, namely: front top, right top, back, face view, and left top. In addition, the Kinect camera provides three different modalities: near-infrared, color, and depth. All cameras are synchronized at the frame level, therefore every labeled activity is captured by every camera and corresponds to the same time interval. The principal modality, used in the other evaluation tasks, corresponds to the front top view, as done in [1].
In Table III, we show the performance of CARING in all available views and modalities. One of the key differences Fig. 7: Distribution of predicted confidences as a 2D histogram for correct and incorrect predictions. The Y axis represents standard Softmax probability estimates, while the X axis are confidences improved through the CARING network. Red denotes common cases (high frequency), while blue illustrates unlikely cases. between them is the difficulty of the task, e.g., it is easier to recognize an activity in views where the entire body is visible than in views where only the face is visible. We can observe how the face view, with its limited aperture, obtains a mean accuracy amongst all classes of only 49.57%, whereas the front top obtains an accuracy of 68.71%. Therefore, we can compare how CARING behaves when recognizing the same activities from different levels of difficulty. The ECE of the raw CNN hovers between 10% and 20% on most of the modalities, albeit it shows significant variance and rises up to 80.45% on the Kinect IR modality when only common cases are considered. Conversely, the ECE of the CARING models not only is lower, but it shows a very stable behavior with little variance between different views and modalities. Compared to the raw 3D CNN and temperature scaling approach on the main sensor modality of Drive&Act [1], i.e., Front top NIR, CARING improves the validation and test sets ECE by 13.14% and 19.72% for rare classes, 7.65% and 7.16% for common classes and 8.68% and 9.96% for all classes, indicating clear advantages of the proposed CARING model for uncertainty estimation, which is consistent for different amounts of training data (although the overall confidence quality declines with less training examples for all considered approaches). Similar results are observed for other Drive&Act modalities and sensor placements. For example, for the Kinect Depth modality, CARING outperforms the other two methods on validation and test sets by 12.12% and 16.28% for rare classes, 7.07% and 7.10% for common classes and 5.91% and 9.02% for all classes, providing empirical evidence for cross-modal generalization abilities of CARING. Even so, we observe that the ECE of the most challenging view is larger than the ECE of less challenging views, which is consistent with a confidence model where the network is more selfconfident on easier tasks.

E. Distribution analysis
We now take a closer look at how the obtained probability estimates are distributed. Figure 7 plots these distributions, where the color highlights the frequency of Drive&Act validation set samples obtaining a certain confidence score for   [9] and CARING is our input-guided framework. Additionally to the confidence quality metrics (ECE, Brier Score and NLL, where ECE is considered the most reliable measure), we report the classification accuracies of the indivudual modalities for the I3D network on the Drive&Act dataset. We evaluate our model not only on all classes but also on rare classes (underreprensented) and common classes (overreprensented). Keep in mind, that as both models do not impact the order of the logits, the accuracy of the model does not change.
In the vast majority of modalities, our confidence improvement through CARING leads to significantly more realistic confidence estimates, indicating its effectiveness across different sensor types and camera placements inside the vehicle cabin.   correct and incorrect predictions. The X axis denotes the improved probability estimates after the CARING transformation, while the Y axis corresponds the original Softmax confidences. For correct predictions ( Figure 7 on the left), model confidences tend to be high both with and without CARING, but the CARING confidences have much higher variance, which is visible through the horizontal spread of the density plot. This effect is even stronger in case the model made a mistake ( Figure 7 on the right): the red high-frequency region is much wider on the X-axis than on the Y-axis, highlighting more reserved confidence values for CARING. Figure 8 visualizes the agreement between the estimated model confidence and the empirically measured probability of the correct outcome by using reliability diagrams (explained in Section III-A). In case of good estimates, the result will be closely approaching the diagonal line. Values above the diagonal are correlated to models being over-confident in their prediction, while values below imply that the model harbours suspicions about the outcome and the accurate prediction probability is higher than assumed.
We first analyze the reliability diagrams of the original action recognition networks. Both P3D and I3D confidence values largely deviate from the target, showing clear biases towards excessively optimistic scores (i.e., values are oftentimes below the diagonal in Figures 8a, 8d, 8g, 8j, 8m, 8p). One exception worth discussion is an above-diagonal peak in the low probability segment for all and common classes, hinting that in "easier" settings, low confidence samples often turn out to be correct (8a, 8d, 8g, 8j). Still, in the "harder" setting of rare activities (Figure 8m, 8p), the biases towards too high probabilities are noticeable for all values.
We have observed a clear positive effect of temperature scaling (Figures 8b, 8e, 8h, 8k, 8n, 8q) and our CARING model (Figures 8c, 8f, 8i, 8l, 8o, 8r). Evidently, CARING models outperform other approaches in all settings and lead to almost perfect reliability diagrams for all and common classes. Yet, both temperature scaling and CARING strategies still have issues in dealing with rare classes, with confidence being too high, indicating a vital direction for future explorations.
It is worth noting that ECE might be in a slight disarray with the visual reliability diagram representation, as the metric weighs the misalignment in each bin by the amount of data points in it, whereas the reliability diagrams do not manifest such frequency distribution. For instance, while the CARING-I3D model in Figure 8i marginally exceeds the target diagonal, it has lower expected calibration error than CARING-P3D which seems to yield nearly perfect results in Figure 8l. As there are only very few examples in the low-confidence bin, they are overshadowed by smaller differences in the highconfidence bins, which therefore contribute more to the final.

A. Significance for Driver Observation
Although CARING consistently improves the realism of confidence values, the results vary greatly depending on the behaviour type ( Figure 6). As it comes to real-life applications inside the vehicle, the maturity level of the proposed model depends on the concrete use-case. Drive&Act is a fine-grained dataset with both, manual and fully automated driving, and therefore covers a high number of secondary activities. Some of these behaviours were almost unthinkable behind the steering wheel until now, but will become more common in the future (such as working on laptop). For the use-case of identifying driver distraction, the most significant Drive&Act category is sitting still, which comprises both, (1) driving and (2) sitting with the hands not on the steering wheel, while the car is in the self-driving mode (without any distractive activities). This category is inherently linked to lower distraction and distinguishing it from other driver states is crucial for identifying distraction at SAE levels 0 to 3. Recognition of this behaviour, as well as most of other behaviours prevalent in manual driving, (e.g., using multimedia display, fastening seat belt) consistently yields high-quality confidence estimates. The rather long-term usecase of increased comfort through automatic driver-centered adaptation, (e.g., softer driving if the person is drinking tea or sleeping at SAE levels 4 and 5), on the other hand, might require finer granularity of driver behaviours. In this case, the readiness level of our system strongly depends on the concrete application and significant improvement would still be required if very concise recognition is desired (for example, opening vs. closing bottle). Nevertheless, the most fundamental categories, such as eating, reading or interacting with phone achieve ECE < 10%, which might be sufficient for most of the applications.
Our experiments indicate that previously used driver observation models do not provide proper uncertainty estimates, therefore ignoring their own limits. Figure 9 illustrates an example of average confidence estimates during a single driving session of the Drive&Act dataset for the original (blue line) and CARING (red line) models. The original model consistently stays in the area > 95%, indicating strong overconfidence, since the average Drive&Act accuracy is clearly below this value. Two qualitative examples on the right showcase very high confidence values (99.9% and 96.7%) of the original model in cases of both, correct predictions and misclassifications. Such overly confident models provide a false sense of security and are dangerous if affecting the overall driving dynamics. Furthermore, such false-positives predictions are very damaging for the driving experience and human-vehicle interaction. In the vast majority of cases, the uncertainty error was towards overconfidence, which is clearly improved though our CARING model. In the example of 9, CARING clearly lowers the average confidence estimate (red line). In the qualiative examples on the right, CARING estimate is much lower in case of misclassification (59.1% vs. 88.0%). Still, one might argue that a value of 59.1% is relatively high and finding a good threshold for acceptance of the recognition result remains an open question.
Classification uncertainty plays a significant role in driver observation, as the the models are deployed in a dynamic world where domain shifts, novel behaviours and other unforeseen situations may occur at any time. Besides being potentially dangerous, false-positives caused by overly confident models are often highly disturbing for the user. For example, in the use-case of driver-centered adaptation, repeated false recognition that the human is, e.g., reading triggering a reaction like turning on the light would strongly bother the user. Apart from the direct benefits of proper confidence values for decision-making systems, good assessment of uncertainty enhances model interpretability. For example, in the realistic scenario of open-world recognition, low-confidence input might be passed to human experts, which would provide the correct annotations (i.e. active learning) and therefore improve the decision boundary. In summary, obtaining realistic uncertainty estimates is important in real-life driving systems due to (1) safety, (2) better human-machine interaction (through avoidance of false positives triggering an unwanted response), and (3) better interpretability.

B. Discussion of Limitations
While our method leads to much more reliable confidence estimates in driver behaviour analysis, it is not without limitations. First, we observe, that the accuracy-confidence mismatch is still relatively large in case of activities with little training examples. Secondly, while we achieve the best results with the proposed CARING approach, we acknowledge, that this comes with increased computational cost due to an additional external calibration network. This overhead of course strongly depends on the architecture choice and is comparably small in our case (66.7K Parameters and 0.13 MFLOPS for our two-layer calibration network using 1024 dimensional input representation vector holding the intermediate I3D representations). Furthermore, identifying misclassifications among the training classes is not the same as identifying novelty [78]. The essence of calibration-based methods, such as temperature scaling or our CARING model, is learning realistic confidence values on a held-out validation set. As shown in a recent study from the area of image classification [78], the reliance on this held-out validation set also becomes the greatest weakness of such models when facing domain shifts. In other words, confidence calibration is effective, as long as the test data roughly reflects the distribution of the validation set. Producing probability estimates of the observed behavior class that was previously unseen during training is therefore a different challenge that we aim to address in the future. Nevertheless, our work takes a step towards driver observation models which are not only accurate, but also to determine, how likely they are to be right in their prediction, which is vital for reliable and transparent decision systems within the vehicle.

C. Outlook: Reliable and Secure Driver Observation
The goal of driver observation is to delegate more actions and decisions to the vehicle itself and reacting to the captured driver states accordingly. As in any decision process, the reliability and security of the incoming information become important. Our current work provides an accurate method for measuring the uncertainty of this information. Taking this as a starting point, one could follow different research directions which are currently rather overlooked.
Adversarial attacks are one of such examples. Though thoroughly explored for signals coming from the exterior of the vehicle [82], [83], it is still not known how extensive the risk is of an attack against the cameras inside the vehicle cabin. Unfortunately, deep learning research suggests that raw Softmax confidences are highly unreliable in case of adversarial attacks [12]. Analyzing the uncertainty of the networks can reduce the effect of such attacks and provide a way to detect them. Still, how much additional effort is indeed needed to penetrate this second layer of protection for action recognition models remains an open question.
A related direction is that of interpretability [84]. As we move towards end-to-end approaches, it is easier for dataset biases to influence predictions. In the case of driver observation, a movement of the hand towards the mouth could be for example misinterpreted as eating [60]. Visualizing the features which determine the predictions can help build trust and ensure that situations as the aforementioned will not occur. The CARING model allows for a second interpretation, namely that of the uncertainty estimates which could lead to additional insights into model reasoning.
Last but not least comes security and privacy [85], [86]. Monitoring the inside of a vehicle exposes a lot of private sensitive information. Aside form the video feed itself, the processed information is also of high concern, especially when used to evaluate professional drivers, resolve accident disputes, or used for marketing purposes. In all those cases, knowing the reliability of predictions can help to better quantify the benefits and dangers of using the driver observation information.

VI. CONCLUSION
While conventional driver observation research targets highaccuracy frameworks in the first place, our goal is to develop driver activity recognition models which are not only accurate, but also produce uncertainty estimates that can safely be interpreted as probabilities of a correct outcome. First, we study the reliability of model confidences of existing driver activity recognition models and come to worrying conclusions: there is a significant discrepancy between the original confidence estimates of the networks and the empirically measured probabilities of a correct prediction. To remedy this, we implement two methods for calibrating the network estimates: leveraging the temperature scaling approach often used in image recognition for such purposes and our newly proposed model, which we refer to as CARING. Our CARING model learns to dynamically generate values used for scaling the model confidences based on input representation with an external calibration network. Our extensive experiments indicate strong improvement through temperature scaling alone, while our CARING model consistently yields the best results. Our study provides encouraging evidence, that the proposed uncertainty-aware models can be efficiently used to develop reliable driver observation systems.