{'fraction_non_alphanumeric': 0.03799278273302921, 'fraction_numerical': 0.011302512425954927, 'mean_word_length': 4.9009642426677384, 'pattern_counts': {'":': 0, '<': 0, '<?xml version=': 0, '>': 2, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 1, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
RES-HD: Resilient Intelligent Fault Diagnosis Against Adversarial Attacks Using Hyper-Dimensional Computing

Industrial Internet of Things (I-IoT) enables fully automated production systems by continuously monitoring devices and analyzing collected data. Machine learning methods are commonly utilized for data analytics in such systems. Cyber-attacks are a grave threat to I-IoT as they can manipulate legitimate inputs, corrupting ML predictions and causing disruptions in the production systems. Hyper-dimensional computing (HDC) is a brain-inspired machine learning method that has been shown to be sufficiently accurate while being extremely robust, fast, and energy-efficient. In this work, we use HDC for intelligent fault diagnosis against different adversarial attacks. Our black-box adversarial attacks first train a substitute model and create perturbed test instances using this trained model. These examples are then transferred to the target models. The change in the classification accuracy is measured as the difference before and after the attacks. This change measures the resiliency of a learning method. Our experiments show that HDC leads to a more resilient and lightweight learning solution than the state-of-the-art deep learning methods. HDC has up to 67.5% higher resiliency compared to the state-of-the-art methods while being up to 25.1% faster to train.


I. INTRODUCTION
I NDUSTRY 4.0 revolutionized monitoring, analysis, and automation of production systems through smart technology [1]. It is mainly powered by the Industrial Internet of Things (I-IoT). I-IoT is the interconnection of smart devices that enables full automation, remote monitoring, and predictive maintenance. However, small-scale I-IoT devices with their limited computation and communication capabilities make I-IoT system an easy target for possible cyberattacks. System vulnerabilities (e.g., network protocols, insecure data transfer and storage) can be discovered by an attacker, and used to sabotage communication, do physical damage, alter existing data, or prevent asset availability [2]. The average estimated losses were $10.7 million per breach of data among manufacturing organizations in Asia Pacific in 2019 [3]. To minimize Onat  these costs, cyber-security measures should be taken such as cyber-security awareness training, keeping software updated, installing firewalls, using strong passwords and others [4].
Abundant system monitoring data in I-IoT systems makes data-driven predictive maintenance (PDM) popular. Machine learning (ML) methods are commonly used for identifying best maintenance schedules [5]. Relationship between past data and failure characteristics of a piece of equipment have been studied extensively [6]- [9]. Intelligent fault diagnosis (IFD) is a key data-driven PDM application that finds and classifies different fault types before they occur. The success of these ML-based methods heavily depends on input data. Adversarial attacks against ML methods manipulate legitimate inputs and force the trained model to produce incorrect outputs leading to incorrect predictions. Since ML is in the center of intelligent fault diagnosis, these attacks may have serious consequences such as undetected failures [10]. There is a need for novel intelligent learning solutions that can stay resilient against various adversarial attacks.
Hyper-dimensional computing (HDC) was introduced as a brain-inspired learning solution for robust and efficient learning [11]. HDC encodes raw data into high-dimensional vectors (i.e., hypervectors) and then performs simple operations in this space, e.g., element-wise addition, dot product. HDC has been employed in a range of applications such as activity recognition [12], speech recognition [13], and biomedical signal processing [14]. To the best of our knowledge, it has not been used for intelligent fault diagnosis.
In this work, we propose HDC as a resilient learning solution against different black-box adversarial attacks for intelligent fault diagnosis (IFD). Our black-box attack is based on a transferable attack strategy [15]. We first train a substitute deep learning model, a wide deep convolutional neural network (WDCNN), and create artificial test samples using this trained model. We then transfer these instances to the target methods (e.g., LSTM, GRU, HDC). In testing, we measure the classification accuracy of the target models before and after the attacks. The accuracy change gives us the resiliency of a target method. We show that HDC is the most resilient and lightweight method, outperforming all deep learning (DL) methods on commonly used CWRU Bearing dataset [16]. HDC is up to 67.5% more resilient and 25.1× faster during training compared to the state-of-the-art deep learning methods.

II. RELATED WORK
Industrial Internet of Things (I-IoT) is an adaptation of traditional IoT for production environments focusing on machineto-machine communication, big data, and machine learning for higher system efficiency and reliability [17]. I-IoT systems are often insufficiently secure and vulnerable due to off-theshelf communication protocols [2], [18], [19]. Furthermore, there are many assets that are vulnerable to cyber-attacks such as operating systems, application software, communication protocols, and smart devices [18]. An adversary, attacker, can exploit these vulnerabilities to arrange a cyberattack. There is an increasing cyberattack trend in recent years, for example, in 2019, cyberattacks against factories increased by more than 200% [20]. There are various cyberattacks against I-IoT systems such as denial of service, eavesdropping, side channel, and attacks against machine learning [2]. We focus on attacks against ML in this paper where an attacker corrupts the collected data or model parameters leading to worse prediction performance. These attacks are dangerous since data analytics is an indispensable part of I-IoT systems. They can result in serious outcomes, e.g., undetected failures in a system [10].
Predictive maintenance determines an optimal maintenance schedule based on time-to-failure prediction of industrial assets [5]. Data-driven predictive maintenance utilizes historical data to create ML models which are then used for fault diagnosis of industrial assets. Intelligent fault diagnosis (IFD) is a branch of data-driven PDM which discovers and classifies different fault types in advance. There are various IFD methods, such as convolutional neural network (CNN) [6], long short-term memory (LSTM) [7], gated recurrent unit (GRU) [8], ensemble learning [9], etc. However, adversarial attacks against deployed ML models can lead to serious consequences for a PDM system such as delayed maintenance or replacement of a machine [10]. Mode and Hoque [10] analyze the impact of different adversarial attacks against ML for remaining useful life (RUL) prediction. They implement Fast Gradient Sign Method (FGSM) and Basic Iterative Method (BIM) to craft adversarial examples and compare different DL model performances under those attacks. They use the NASA C-MAPSS dataset [21] and show that these attacks can cause up to 5× worse prediction performance. This work is limited in terms of the number of attack methods and DL models. Besides, they did not propose a novel methodology that can stay resilient against adversarial attacks. In our paper, we propose a novel learning solution which can stay resilient against different adversarial attacks. Our results are also more generalizable because we increase the number of attack scenarios and deep learning models significantly compared to the state-of-the-art.
Brain-inspired Hyperdimensional computing (HDC) was proposed as a light-weight computing method to perform cognitive tasks on devices with limited resources [11]. HDC has three main stages [22]: 1) encoding: mapping data into high dimensional vectors, called hypervectors (HVs). 2) training: combining encoded HVs to create a model representing each class with a HV. 3) inference: comparing the test sample with the trained model to find the most similar class. The key property of HD is that it can provide strong robustness to noise [23] which might be really beneficial for I-IoT systems since collected sensor data contains noise in general [24]. There are many applications using HD such as multimodal sensor fusion [12], language recognition [25], and speech recognition [13]. To the best of our knowledge, HD has not been used in PDM domain where it can provide both lightweight and robust learning solution. In our work, we propose HD as a resilient and efficient learning solution to adversarial attacks. Our experiments show that HD is more resilient against various adversarial attacks compared to the state-of-the-art DL methods while bringing significant computational advantage.

III. ADVERSARIAL ATTACK METHODS
Data-driven predictive maintenance (PDM) heavily uses deep learning models due to their great prediction performance [26]. Deep learning, as a branch of ML, has many security vulnerabilities such as program errors (e.g., memory depletion), and attacks at the time of its testing (e.g., worse prediction performance) [27]. Adversarial attacks against ML modify input data slightly in a way that is intended to cause an ML classifier to misclassify it.
There are three types of adversarial attacks against ML in the literature: evasion, poisoning, and exploratory [28]. Evasion attacks target compromising the test data, poisoning attacks contaminate the training data, and exploratory attacks gain knowledge about the learning algorithm without changing the data. We focus on evasion attacks since it is the most common type of attack in an adversarial setting [28]. Evasion attacks can further be categorized into two groups: white-box and black-box attacks. While white-box attacks have detailed knowledge about the model (e.g., type of neural network along with the number of layers), algorithm used in training (e.g., gradient-descent optimization), the training data distribution, and the parameters of the fully trained model architecture, black-box attacks assume no knowledge about the underlying model. Hence, black-box attacks reflect more realistic scenarios in the sense that the attacker can be an outsider, with limited knowledge about the internal system details [15]. An adversary can craft a black-box attack using (1) a transferable attack strategy which trains a substitute model to emulate the original (target) model and (2) a query feedback mechanism that starts with random input to be sent to the target model. Based on the confidence score of inputs, attacker adds noise to the input under the acceptable perturbation error level.
In this work, we adapt a transferable attack strategy where we select a single substitute model and craft examples using this model. We then transfer the created examples to target models. In this strategy, attacker does not need to know anything about the target models, yet have an access to input data. Adversary solely trains the substitute model and transfer created examples as the perturbed inputs start misclassified by the substitute model. We select 4 different state of the art adversarial attack methods using the gradient information of the loss function: fast gradient sign method (FGSM), basic iterative method (BIM), momentum iterative method (MIM), and robust optimization method (ROM). Our problem is intelligent fault diagnosis (IFD) where our models predict fault types before they actually happen. IFD is a time series classification problem since input is a time series sensor data, and output is a certain fault type (which is discrete). We define the following variables to explain different attack strategies: • θ: parameters of the substitute model • x: input data (collected sensor data) • y: labels (fault types) • J(θ, x, y): cost function to train the substitute model FGSM was proposed as an efficient adversarial attack method to fool the GoogLeNet model [29]. FGSM first calculates the gradient of the cost function with respect to the input of the neural network. Adversarial examples are then created based on the gradient direction: whereẍ represents the crafted adversarial examples and denotes the amount of the perturbation.

B. Basic Iterative Method (BIM)
BIM is an improved version of FGSM where FGSM is applied multiple times with really small step size [30]. BIM perturbs the original data in the direction of the gradient multiplied by the step size α: where α is obtained by dividing the amount of perturbation ( ) by the number of iterations (I): α = /I. Then, BIM clips the obtained time series elements to ensure that they are in the -neighborhood of the original time series:

C. Momentum Iterative Method (MIM)
Momentum Iterative Method (MIM) solves underfitting and overfitting problems in FGSM and BIM respectively by integrating momentum into the BIM [31]. At each iteration i, the variable g i gathers the gradients with a decay factor µ: where the gradient is normalized by its L 1 distance. The perturbed data for the next iteration is created in the direction of the sign of g i+1 with a step size α: In MIM, the algorithm also ensures that the crafted adversarial examplesẍ satisfy the

D. Robust Optimization Method (ROM)
The goal of a supervised learning problem is to find model parameters θ that minimize the empirical risk E (x,y)∼Ξ [J(θ, x, y)] where Ξ is the underlying supervised data distribution. However, this formulation cannot handle the change in input data. To solve this problem, set of allowed perturbations ∆ is introduced. Then, empirical risk formulation is modified by feeding samples from the distribution Ξ directly into the loss function J leading to the following minmax (saddle point) optimization formulation [32]: Here, while inner maximization finds an adversarial version of a given data point x that achieves a high loss, outer minimization discovers model parameters to minimize the adversarial loss given by the inner attack problem. To solve the robust optimization problem, ROM replaces every instance with its FGSM-perturbed counterpart.
The selected methods utilize loss gradient information to craft adversarial examples by adding different amounts of perturbation. In that sense, they represent different attack scenarios. An adversary, who is able to access the I-IoT system data (e.g., collected sensor measurements), can implement these methods using a substitute model and harm the prediction performance of target models without being detected.

IV. PROPOSED FRAMEWORK
In this work, we use hyper-dimensional computing (HDC) for intelligent fault diagnosis and measure the resiliency of this method against different adversarial attacks. To the best of our knowledge, HDC has not been used in this context before. Deep learning models, on the other hand, have been used extensively for I-IoT applications [26]. However, these models are vulnerable to adversarial attacks which can deteriorate the prediction performance. HDCs resilience makes it a great alternative. HDC is an emerging computing paradigm inspired by the fact that brains take sensing data and map it into a high dimensional sparse representation before analysis [33]. HDC mimics this by mapping each data point into high-dimensional space D. All computational tasks are performed in D-space using simple operations such as element-wise additions and dot  [34]. HDC is especially suitable for several learning tasks in IoT systems as (1) it is computationally efficient (2) it supports single-pass training (no back-propagation needed), and (3) it provides strong robustness to noise [35]. Fig. 1 illustrates HDC learning framework which contains 3 main stages: encoding, training, and inference.
1) Encoding: The first step of HDC is to encode input data into hyper-vectors. Most of the proposed encoding methods [36], [37] linearly combine the hyper-vectors corresponding to each feature, resulting in sub-optimal classification quality [35]. In this work, we use non-linear encoding which considers the non-linear interactions between the feature values with different weights and exploits the kernel trick. This encoding approach is based on a study which shows that the Gaussian kernel function can be approximated by the dot product of two vectors [38]. Assume that an input vector in original space Ξ = {ξ 1 , ξ 2 , . . . ξ n } ∈ R n . Encoded high-dimensional vector is represented as n. Encoding from Ξ to h i is based on the following equation: where B k s are randomly chosen of dimension D 10k and b i ∼ U(0, 2π). That is, B kj ∼ N (0, 1) and δ( B k1 , B k2 ) 0, where δ is the cosine similarity.
2) Training: The second step of HDC, model training consists of two steps to generate hyper-vectors representing each class. The first step, initial training, performs elementwise addition of all encoded hyper-vectors in each existing class. Let's assume that H i is the encoded hyper-vector of input i. We know that each input i belongs to a class j. Hence, H j i denotes the hyper-vector for input i from class j. In the initial training, HDC simply adds all hyper-vectors of the same class to generate the final model hyper-vector: where η is the learning rate. This process is also called as one-pass training since each input is visited only once and added to class hyper-vectors. The second step of HDC training, retraining, performs model adjustment by iteratively going through the training dataset. Retraining is beneficial for HDC to improve the prediction accuracy. During this step, the encoded hyper-vector of each input is created again, and its similarity with the existing class hyper-vectors is checked. If HDC misclassifies, say that H j from class C j is predicted as class C k , it updates its model as follows: which means that the information of H j causing misclassification to C k is discarded.
3) Inference: In the last step, HDC checks the similarity of each encoded test data with the class hyper-vector. Most commonly, cosine similarity is used for the similarity check although other metrics (e.g., Hamming distance) could be suitable based on the problem. To calculate cosine similarity between hyper-vector H and class hyper-vector C j : which is calculated by the dot product of the H and C j divided by the product of these two vectors' lengths. As an output of this step, HDC provides the most similar class.

B. Black-box Attack Framework
In this work, we use a black-box transferable attack strategy which first trains a substitute model and crafts new test instances using the trained substitute model. For full list of DL methods used in this paper, you can refer to the Section V-B. As our substitute model, we select wide deep convolutional neural network (WDCNN) since it is one of the most commonly used DL methods in intelligent fault diagnosis [9], [39], [40]. For our black-box attack setting, we assume that an adversary has access to the training and test data, yet does not know anything about the attacked (target) models. We illustrate our black-box attack framework in Fig. 2. Attacker first trains the substitute model (WDCNN) and use the trained model to create perturbed test data. Attacker can employ different attack strategies to obtain perturbed test data (see Section III for the attack strategies used in this paper). Afterwards, adversary sends these crafted examples to the target models in testing time. In Fig. 2, we give long short-term memory (LSTM) as the target model for illustration purposes. However, note that there is a pool of pretrained target models (LSTM, GRU, CRNN, CLSTM, CGRU, SCRNN, SCLSTM, SCGRU, HDC) adversary is not aware of (thus black-box attack). Attacker simply sends the created examples to the target models to see if the attack will be successful or not. We measure the attack success based on change in test data classification accuracy before and after the attack where accuracy is defined as:

Accuracy =
Number of correct predictions Total number of test samples (11) Change in accuracy gives us the resiliency of a learning method which we measure by the metric called Compromise which is formulated as: Compromise = Accuracy normal Accuracy perturbed (12) where Compromise > 1 (under the assumption that attacks lead to worse prediction performance). The smaller the compromise value is, the more resilient the model becomes against the adversarial attack. For instance, given two methods CRNN and LSTM, and their compromise values 5 and 2 respectively, we can conclude that LSTM is more resilient against the adversarial attack. If we have M number of adversarial attacks (M > 1), then we need to calculate the mean compromise value for each learning method as follows: Accuracy normal Accuracy i perturbed /M (13) Because we have multiple attack strategies (where M = 4), mean compromise gives a more accurate idea about single model resiliency. Overall, we obtain mean compromise value for each learning method and use this metric for our experimental analysis. Furthermore, to show the HDC resiliency improvement, we define the following improvement metric: 14) where Compromise DL denotes the single DL model mean compromise value, and Compromise HDC is the HDC mean compromise. We report the improvement in percentage (%). Improvement signifies the resiliency of our HDC learner against adversarial attacks compared to a single DL model.

V. EXPERIMENTAL ANALYSIS A. Dataset Description
We use Case Western Reserve University (CWRU) Bearing dataset [16], a widely used benchmark for fault diagnosis. Rolling element bearing (REB) failure is one of the most frequent reasons for machine breakdown leading to severe loss of safety and property [41]. Fig. 3 represents the experimental test apparatus to collect this dataset. The data were collected from both the drive end accelerometer and the fan end accelerometer at 12k samples/second over a range of motor loads (from 0 hp to 3 hp). Both datasets (drive end and fan end) contain 19,800 training and 750 test samples. Bearing used in this experiment has three components: rolling element, inner race, and outer race. 9 different fault types are provided in the dataset based on the fault diameter (0.007, 0.014, and 0.021 inches) and the component (plus the normal bearing condition).

B. Experimental Setup
Selected Deep Learning (DL) Methods: We select 9 deep learning methods from recurrent (LSTM, GRU), convolutional (WDCNN), and hybrid (CRNN, SCRNN) architectures. We cover a good range of DL methods from different architectures, increasing the generalizability of our study.
• Long Short-Term Memory (LSTM) [7]: Our network contains 2 LSTM layers having 64 and 32 units which are consecutively connected to fully connected feed forward neural network with 10 units representing each failure class (we have 10 failure types in total). • Gated Recurrent Unit (GRU) [8]: We use the same network structure as LSTM by updating the LSTM layers to GRU. • Wide Deep Convolutional Neural Network (WDCNN) [43]: WDCNN starts with a convolutional layer using kernel size of 64. It is connected to a pooling layer. This is then connected to multi stage convolutional layers with small kernels (kernel size of 3) and pooling layers. Whole CNN structure is finally connected to fully connected feed forward neural networks with 100 and 10 units. • Convolutional Recurrent Neural Network (CRNN) [42]: CRNN is a hybrid model which has two parallel paths: one path has WDCNN structure and another path has 1D wide convolutional layer (with a kernel size of 64) connected to single RNN layer with 128 units. These two layers are then concatenated and connected to feed forward neural network with 10 units. Here, for the RNN layer, we use RNN (CRNN), LSTM (CLSTM), and GRU (CGRU) models providing 3 different models. • Simplified CRNN (SCRNN) [42]: Here, we remove the WDCNN path from CRNN structure meaning that SCRNN only contains 1D wide convolutional layer (with a kernel size of 64) connected to single RNN layer with 128 units. Similarly, we use RNN (SCRNN), LSTM (SCLSTM), and GRU (SCGRU) models providing 3 different models. Adversarial Attack Methods: We select the following parameters for our adversarial methods: fast gradient sign, basic iterative, momentum iterative, and robust optimization [31], [32], [44]: amount of perturbation ( ): 0.1, step size (α): 0.001, number of iterations (I): 100, decay factor (µ): 1.
Parameter Selection: For both deep learning methods and HDC, we use a sliding time window of size 100. We replicate each experiment 10 times and report average values where we run all experiments on a PC with 16 GB RAM and an 8-core 2.3 GHz Intel Core i9 processor. For DL methods, the following hyper-parameters are selected: Adam optimizer with learning rate 0.001, relu activation function, batch size of 16, and a max number of epochs of 100 where callback is activated (patience is set to 10 for validation data). For HDC, we select the following parameters: encoding: non-linear, hypervector dimension size: 10,000, learning rate: 0.005, number of epochs: 100, similarity metric: cosine.
Number of Training Samples: We measure the selected methods' resiliency by using different number of training samples while using the whole test data. Specifically, our smallest experiment configuration uses 1.2% (240 samples) of the whole training data where we double this ratio until we reach approximately 38.8% (7680 samples). We call this ratio sample training ratio (STR) for the rest of this section. Considering different STRs is crucial for intelligent fault diagnosis (IFD) since it might not always be feasible to label fault data for the whole training dataset. IFD methods should perform well under limited supervision [9].

C. Resiliency Analysis
Mean Compromise Comparison: We analyze the resiliency of selected DL models and HDC using mean compromise metric defined in Equation 13. Fig. 4 shows the mean compromise values of the 6 most resilient learning methods under different sample training ratios for drive end (Fig. 4a) and fan end (Fig. 4b) datasets. In these figures, x-axis represents the selected STRs and y-axis gives the mean compromise values where each color represents different learning method. Based on these figures, we can observe that the mean compromise of a DL method changes significantly. To illustrate, while SCRNN (represented with purple color) is the most resilient method for really small STRs (e.g., 1.2, 2.4), it becomes the least resilient algorithm as we reach the maximum STR. For drive end dataset, we can observe that HDC is the most resilient method for STRs greater than 2.4%. As the number of training samples increases, HD becomes a more resilient method compared to the DL algorithms.    We can make a similar observation for fan end dataset as well. For STRs larger than 9.6%, HD is the most resilient method against adversarial attacks. To present a single mean compromise value (for better understanding), we calculate the average of mean compromise values over all STRs.    Table III presents target models' training time (in seconds). In this table, each row represents a different target model (where the models are ordered in decreasing training overhead) and each column corresponds to the selected STR. We can observe that HD is the most lightweight model across all STRs. In the last column of this table, we share the average (across sample training ratios) normalized training time with respect to HD. HD can achieve up to 25.1× training speed up compared to DL methods. Compared to the most resilient DL method (GRU), HD brings 23× faster training. By this analysis, we can conclude that HD also provides a computationally efficient learning solution while being resilient to adversarial attacks. Training overhead is especially critical for I-IoT systems since data is collected continuously. When new data arrives, learning models require retraining to keep their prediction performances at a certain level [45]. HD can alleviate this retraining overhead due to its lightweight feature.

VI. CONCLUSION
Industrial Internet of Things (I-IoT) is a notion that facilitates monitoring, automation and reliability of smart devices in production environments. I-IoT ensures that these devices are connected to the Internet which helps collecting big data, and utilizing this data to extract useful information. However, these interconnection brings numerous security vulnerabilities which can be exploited by an attacker to steal information or sabotage communication to harm the system. Attacks against machine learning (ML) is one type of cyberattack to deceive ML methods with fake inputs leading to worse prediction performance. Hyper-dimensional computing (HDC) is a novel learning solution which is robust against noise. In this paper, we utilize HDC to stay resilient against created black-box attack scenarios. Our experiments show that HDC can improve the resiliency of the state-of-the-art DL methods by up to 67.5%. HDC can also achieve up to 25.1× training speed up compared to DL methods, providing a lightweight learning solution. This means that HDC can still perform well and efficiently under adversarial attacks which leads to more accurate replacement and maintenance decisions even under cyberattacks.