# Evolving Long Short-Term Memory Network-Based Text Classification

Authors: Arjun Singh; Shashi Kant Dargar; Amit Gupta; Ashish Kumar; Atul Kumar Srivastava; Mitali Srivastava; Pradeep Kumar Tiwari; Mohammad Aman Ullah
Journal: Computational Intelligence and Neuroscience
 (2022)

---

## Abstract

Recently, long short-term memory (LSTM) networks are extensively utilized for text classification. Compared to feed-forward neural networks, it has feedback connections, and thus, it has the ability to learn long-term dependencies. However, the LSTM networks suffer from the parameter tuning problem. Generally, initial and control parameters of LSTM are selected on a trial and error basis. Therefore, in this paper, an evolving LSTM (ELSTM) network is proposed. A multiobjective genetic algorithm (MOGA) is used to optimize the architecture and weights of LSTM. The proposed model is tested on a well-known factory reports dataset. Extensive analyses are performed to evaluate the performance of the proposed ELSTM network. From the comparative analysis, it is found that the LSTM network outperforms the competitive models.


---

## Body

## 1. Introduction

With exponential growth in text documents available on Internet, the manual labeling of textual contents in digital form into various classes is extremely challenging to realize. Therefore, many automatic text classification models have been developed such as hierarchical multilabel text classification (HMLTC) [1] and coattention model with label embedding (CMLE) [2]. These models are trained on historical datasets and processed according to a group of labeled data. These models require efficient text encoding models which decompose the text to sequence vectors [1]. The existing text classification models extract a highly discriminative text representation. But these models are generally computationally extensive in nature [2].Recently, multilabel text classification models were designed. These models are complex compared to single-label classification models [3]. Many researchers have utilized deep learning models for text classification such as recurrent neural network (RNN) and long short-term memory (LSTM). But these models are unable to handle data imbalanced problems [4].Recently, many researchers have designed label space dimension reduction to classify text with multiple classes. However, the majority of the models have ignored the sequential details of texts and label correlation with the original label space. Thus, labels were assumed to be meaningless vectors [5]. Also, for the classification of long text, there were a lot of redundant details in textual data. This redundant detail may contain some sort of knowledge too. Thus, the classification of long text requires an efficient model [6].Mostly, the text details are available in unstructured form. Therefore, the extraction of required details from a huge number of documents becomes a challenging problem [7]. In [8], a bidirectional gated temporal convolutional attention network (BGTCAN) was designed. During the extraction of features, this model has utilized a BGTCAN to obtain the bidirectional temporal features. The attention process was also used to distinguish the significance of various while preserving the maximum text features. In [9], an efficient text classification model was proposed. It has integrated the context-relevant features with a multistage attention model by considering TCN and CNN.In [10], an efficient hybrid feature selection model was designed. Binary poor and rich optimization (HBPRO) was utilized to compute the significant subset of required features. A Naive Bayes classifier was then used for classification. HBPRO is based on people's wealth such as rich and poor in the world. The rich group tries to widen their group gap by computing from those in the poor group. Every solution in the poor group moves towards the global optimal solution in the search space by learning from the rich group. In [11], an in-memory processor for Bayesian text classification was designed by considering a memristive crossbar model. Memristive switches were utilized to hold the required details for the text classification. In [12], a hybrid model was proposed. It has integrated the gated attention-based BLSTM and the regular expression-based classifier. BLSTM and an attention layer were utilized to weigh tokens according to their perceived significance and focus on critical fractions of a string.In [13], a backdoor keyword identification model was proposed to overcome the backdoor attacks with LSTM-based models. In [14], label-based attention for hierarchical multilabel text classification neural network was proposed. An efficient label-based attention module was proposed to obtain significant details from the text using labels from various hierarchy levels. In [15], support vector machines (SVM) were utilized to recognize text and documents.From the existing literature, it is found that the LSTM network suffers from the parameter tuning problem. Generally, initial and control parameters of LSTM are selected on a trial and error basis. It means the parameters of LSTM models are selected by manually selecting some possible values. Whichever combination shows better performance is followed as control parameters of LSTM. Parameter tuning deals with the optimization of the control parameters of the LSTM model. It can improve the performance of LSTM, but it comes up with additional computations during the model building time. Therefore, in this paper, an evolving LSTM (ELSTM) network is proposed. The key contributions of this paper are as follows:(1)
An evolving long short-term memory (LSTM) (ELSTM) network is proposed for text classification.(2)
Multiobjective genetic algorithm (MOGA) is used to optimize the architecture and weights of LSTM.(3)
The proposed model is tested on a well-known factory reports dataset. Extensive analyses are performed to evaluate the performance of the proposed ELSTM network.The remaining paper is organized as follows. Section2 discusses the related work. Section 3 presents the proposed ELSTM network for text classification. Section 4 presents the performance analysis of the proposed ELSTM network on a well-known factory reports dataset. Section 5 concludes the paper.


## 2. Related Work

In [16], a bidirectional LSTM (BiLSTM) was proposed for text classification. The word embedding vectors and BiLSTM were utilized to obtain both the succeeding and preceding context information. Softmax was also utilized to obtain classification results. In [17], an attention LSTM (ALSTM) network was proposed for text data classification. The ALSTM has shown significant performance in terms of generalization. In [18], deep contextualized attentional bidirectional LSTM (DCABLSTM) was proposed. By utilizing the contextual attention mechanism, DCABLSTM has the ability of learning to attend to the valuable knowledge in a string. In [19], two hidden layers-based LSTM model (THLSTM) was proposed. The first layer was utilized to learn the strings to demonstrate the semantics of tokens with LSTM. The second layer has encoded the relations of tokens. In [20], a recurrent attention LSTM (RALSTM) was proposed to iteratively evaluate an attention region considering the key sentiment words. Attention and number of tokens were minimized in an efficient manner. The TSLSTM leveraged the coefficients of tokens for classification. A joint loss operator was also used to highlight significant attention regions and keywords. In [21], CNN and LSTM were combined for better performance. It has been found that the integrated model can outperform many competitive models. In [22], LSTM fully convolutional network (LSTMFCN) and attention LSTM-FCN (ALSTMFCN) were designed. The fully convolutional block with a squeeze-and-excitation block was used to improve the performance. These models require significantly lesser preprocessing. In [23], convolutional LSTM (CLSTM) network was designed. CLSTM has been found to be adaptable in evaluating big data, keeping scalability. Additionally, CLSTM was free from any specific domain. However, [16–23] are sensitive to its initial parameters.To overcome parameter sensitivity issues with LSTM variants, in [24], particle swarm optimization (PSO) was utilized to optimize the LSTM model. PSO was utilized to tune the initial and control parameters of the LSTM network. It has been found that the PSO-based LSTM achieves remarkable results. In [25], a genetic algorithm was utilized to optimize the LSTM. This model can automatically learn the features from sequential data. In [26], a genetic algorithm was utilized to compute the epoch size, number of layers, units size in every layer, and time window size. However, [24–27] suffer from the stuck in local optima and poor convergence speed issues.It is found that the LSTM network suffers from the parameter tuning problem. The initial and control parameters of LSTM are generally selected on a trial and error basis. Therefore, in this paper, an ELSTM network is proposed.


## 3. Proposed Methodology

This section discusses the proposed ELSTM model. Initially, LSTM is discussed. Thereafter, MOGA is presented. Finally, MOGA-based LSTM, i.e., ELSTM is discussed. Figure1 shows the diagrammatic flow of the proposed model. Initially, the dataset is loaded, and preprocessing operation is applied to it.Figure 1
Histogram distribution of the target classes.Since the data is textual in nature, therefore, word encoding is used to convert the strings to numeric sequences. Finally, the proposed ELSTM is trained on the dataset by using a word embedding layer.


### 3.1. LSTM Network

LSTM is a special kind of variant of recurrent neural network (RNN). It was proposed to overcome the long dependency period problem with RNN. Thus, it can preserve information for a longer period.Consider a sequence inputS=s1,s2,s3,…,sp,s1,s2,s3,…,sp showing each token in the textual data. Mathematically, LSTM can be computed as follows:(1)fk=σWf⋅ik−1+Wf⋅sk+bf,where σ shows a sigmoid function. W and s represent the weight matrices and bias vector attributes. ik is the hidden state and can be computed as(2)ik=σWi⋅ik−1+Wi⋅sk+bi.The current layer’s memoryM˜ can be computed as(3)M˜=tanhWc⋅ik−1+Wc⋅sk+bc.Forkth token, the memory cell Ck block can be computed as(4)Ck=fk⋅Ck−1+ik⋅M˜.The activation vectorok of the output gate can be computed as(5)ok=σWo⋅ik−1+Wo⋅sk+bo.The output vector so-called hidden state vectorik can be computed as(6)ik=ok⋅tanhCk.


### 3.2. Fitness Function

The main objective of this paper is to optimize the architecture in such a way that it achieves better performance with less number of hidden layers for the LSTM network [28–30]. Therefore, a multiobjective fitness function is designed by using validation accuracy Ac and the number of hidden nodes of LSTM. The fitness function ft can be defined as(7)ft=MaximizeVA,MinimizeHN.Here,VA shows the validation accuracy. HN shows the number of hidden nodes used by the LSTM network.


### 3.3. Multiobjective Genetic Algorithm

This section discusses the MOGA-based LSTM (ELSTM) network. Since (7) is a Pareto optimal problem, Algorithm 1 shows step-by-step procedure of the optimization of LSTM.Algorithm 1: Optimization of LSTM.
(i)
Output:Pf/∗PF shows a Pareto front.(ii)
Input: factory reports datasetFRD, LSTM, and initial population IP.(iii)
begin(iv)
UseIP as initial parameters of LSTM(v)
Implement LSTM on training fraction ofFRD;(vi)
ValidateFRD on validation fraction of FRD;(vii)
ComputeVA and HN;(viii)
EvaluatePf=max.VA,min.HN;(ix)
Ns← Apply nondominated sorting on Pf;(x)
returnPf(xi)
endThe genetic algorithm contains a group of operators to optimize the given fitness function [31, 32]. Initially, the normal distribution is used to obtain the random population. These random solutions act as initial parameters of the LSTM network [33–35]. Fitness function (see Eq. mop) is then used to evaluate the fitness of the computed solutions. Nondominated sorting is then used to rank the solutions. Mutation and crossover operators are then utilized to compute the child solutions [36–39]. Mutation and crossover operators are used to obtain child solutions from the parent solutions for evolving process of genetic algorithms. The nondominated solution with a better trade-off between validation accuracy and the number of hidden nodes is used as a final solution for LSTM. Algorithm 2 shows the step-by-step procedure of the MOGA-based LSTM network.Algorithm 2: Evolving long short-term memory networks.
(i)
Output: optimized population(ii)
Input: {initial parameters of MOGA}(iii)
begin(iv)
Obtain initial random solutionsIP ;(v)
ft← Call Algorithm 1 by considering IP;(vi)
SP← Sort IP according to ft;(vii)
/∗ Selection operator∗/(viii)
FP←SP ;Whilece≠0‖lG==1 do(ix)
/∗lG and ce indicate final generation and children elimination ∗/(x)
Randomly selectc;/∗c mutation point ∗/(xi)
ce←0 ;(xii)
forc do(xiii)
Evaluate fitness ofc(xiv)
iffc≤fFP1, then(xv)
removec;(xvi)
ce←ce+1 ;(xvii)
else(xviii)
FP←c ;(xix)
end(xx)
end/∗ Mutation ∗/for crossover doConsider two solutions randomly asc1 and c2;/∗c1, c2, and c3 are children ∗/c3←c1⊕c2 ;Computer fitness ofc3iffc3≤fc1‖fc2 thenremovec3;elseremovec1,c2;endendend/∗ Ranking ∗/ FP← Apply nondominated sorting on FP;returnFP1end


## 3.1. LSTM Network

LSTM is a special kind of variant of recurrent neural network (RNN). It was proposed to overcome the long dependency period problem with RNN. Thus, it can preserve information for a longer period.Consider a sequence inputS=s1,s2,s3,…,sp,s1,s2,s3,…,sp showing each token in the textual data. Mathematically, LSTM can be computed as follows:(1)fk=σWf⋅ik−1+Wf⋅sk+bf,where σ shows a sigmoid function. W and s represent the weight matrices and bias vector attributes. ik is the hidden state and can be computed as(2)ik=σWi⋅ik−1+Wi⋅sk+bi.The current layer’s memoryM˜ can be computed as(3)M˜=tanhWc⋅ik−1+Wc⋅sk+bc.Forkth token, the memory cell Ck block can be computed as(4)Ck=fk⋅Ck−1+ik⋅M˜.The activation vectorok of the output gate can be computed as(5)ok=σWo⋅ik−1+Wo⋅sk+bo.The output vector so-called hidden state vectorik can be computed as(6)ik=ok⋅tanhCk.


## 3.2. Fitness Function

The main objective of this paper is to optimize the architecture in such a way that it achieves better performance with less number of hidden layers for the LSTM network [28–30]. Therefore, a multiobjective fitness function is designed by using validation accuracy Ac and the number of hidden nodes of LSTM. The fitness function ft can be defined as(7)ft=MaximizeVA,MinimizeHN.Here,VA shows the validation accuracy. HN shows the number of hidden nodes used by the LSTM network.


## 3.3. Multiobjective Genetic Algorithm

This section discusses the MOGA-based LSTM (ELSTM) network. Since (7) is a Pareto optimal problem, Algorithm 1 shows step-by-step procedure of the optimization of LSTM.Algorithm 1: Optimization of LSTM.
(i)
Output:Pf/∗PF shows a Pareto front.(ii)
Input: factory reports datasetFRD, LSTM, and initial population IP.(iii)
begin(iv)
UseIP as initial parameters of LSTM(v)
Implement LSTM on training fraction ofFRD;(vi)
ValidateFRD on validation fraction of FRD;(vii)
ComputeVA and HN;(viii)
EvaluatePf=max.VA,min.HN;(ix)
Ns← Apply nondominated sorting on Pf;(x)
returnPf(xi)
endThe genetic algorithm contains a group of operators to optimize the given fitness function [31, 32]. Initially, the normal distribution is used to obtain the random population. These random solutions act as initial parameters of the LSTM network [33–35]. Fitness function (see Eq. mop) is then used to evaluate the fitness of the computed solutions. Nondominated sorting is then used to rank the solutions. Mutation and crossover operators are then utilized to compute the child solutions [36–39]. Mutation and crossover operators are used to obtain child solutions from the parent solutions for evolving process of genetic algorithms. The nondominated solution with a better trade-off between validation accuracy and the number of hidden nodes is used as a final solution for LSTM. Algorithm 2 shows the step-by-step procedure of the MOGA-based LSTM network.Algorithm 2: Evolving long short-term memory networks.
(i)
Output: optimized population(ii)
Input: {initial parameters of MOGA}(iii)
begin(iv)
Obtain initial random solutionsIP ;(v)
ft← Call Algorithm 1 by considering IP;(vi)
SP← Sort IP according to ft;(vii)
/∗ Selection operator∗/(viii)
FP←SP ;Whilece≠0‖lG==1 do(ix)
/∗lG and ce indicate final generation and children elimination ∗/(x)
Randomly selectc;/∗c mutation point ∗/(xi)
ce←0 ;(xii)
forc do(xiii)
Evaluate fitness ofc(xiv)
iffc≤fFP1, then(xv)
removec;(xvi)
ce←ce+1 ;(xvii)
else(xviii)
FP←c ;(xix)
end(xx)
end/∗ Mutation ∗/for crossover doConsider two solutions randomly asc1 and c2;/∗c1, c2, and c3 are children ∗/c3←c1⊕c2 ;Computer fitness ofc3iffc3≤fc1‖fc2 thenremovec3;elseremovec1,c2;endendend/∗ Ranking ∗/ FP← Apply nondominated sorting on FP;returnFP1end


## 4. Performance Analysis

The experiments are performed using MATLAB 2021a software on GPU. Experiments are performed on benchmark factory reports dataset.


### 4.1. Dataset

In this paper, the experiments are performed on a well-known factory reports dataset. It consists of around 500 reports with various textual features such as textual information of the attributes and categorical label. Figure2 shows the snapshot of the first eight rows of the dataset. Thus, the dataset contains description, category, urgency, resolution, and cost.Figure 2
Screenshot of the factory reports dataset.Figure3 shows the histogram distribution of the target classes. There is a total of four target classes, i.e., electronic failure, leak, mechanical failure, and software failure. It is found that the mechanical failure has a higher frequency than the others. Also, the software failures are significantly lesser than the other failures.Figure 3
Histogram distribution of the target classes.Figure4 shows the histogram distribution of the string tokens. It is found that the majority of the documents have lesser than ten string tokens. Therefore, we have truncated the strings to have length ten.Figure 4
Histogram distribution of the string tokens.Figures5 and 6 demonstrate the frequently utilized words in the training and validation dataset fractions, respectively. Wordcloud in MATLAB is used for visualization purposes. It shows the various words which are frequently, moderately, and least utilized in the factory reports dataset.Figure 5
Frequently utilized words in the training dataset.Figure 6
Frequently utilized words in the validation dataset.Figures7 shows the training analysis of the LSTM network when the Adam optimizer is utilized. It has received 89.58% validation accuracy. The epoch and iteration-wise mini-batch training and validation accuracy analysis along with respective losses and base learning rate are shown in Figure 8. From both Figures 7 and 8, it is found that the Adam optimizer-based LSTM suffers from the overfitting issue.Figure 7
Training and validation analysis of the Adam optimizer-based LSTM network.Figure 8
Epoch and iteration-wise mini-batch training and validation accuracy analysis of the Adam optimizer-based LSTM network along with respective losses and base learning rate.Figures9 shows the training analysis of the LSTM network when the RMSprop optimizer is utilized. It has received 91.67% validation accuracy. The epoch and iteration-wise mini-batch training and validation accuracy analysis along with respective losses and base learning rate are shown in Figure 10. From both Figures 9 and 10, it is found that the RMSprop optimizer-based LSTM achieves better validation accuracy and validation loss than the Adam optimizer-based LSTM. But RMSprop optimizer-based LSTM still suffers from the overfitting issue.Figure 9
Training and validation analysis of the RMSprop optimizer-based LSTM network.Figure 10
Epoch and iteration-wise mini-batch training and validation accuracy analysis of the RMSprop optimizer-based LSTM network along with respective losses and base learning rate.Figures11 shows the training analysis of the proposed ELSTM network when RMSprop optimizer is utilized. It has received 95.83% validation accuracy. The epoch and iteration-wise mini-batch training and validation accuracy analysis along with respective losses and base learning rate are shown in Figure 11. From both Figures 11 and 12, it is found that the proposed ELSTM achieves better validation accuracy and validation loss than the Adam optimizer and RMSprop-based LSTM networks. The proposed ELSTM is least affected by the overfitting issue.Figure 11
Training and validation analysis of the proposed ELSTM network.Figure 12
Epoch and iteration-wise mini-batch training and validation accuracy analysis of the proposed ELSTM network along with respective losses and base learning rate.


## 4.1. Dataset

In this paper, the experiments are performed on a well-known factory reports dataset. It consists of around 500 reports with various textual features such as textual information of the attributes and categorical label. Figure2 shows the snapshot of the first eight rows of the dataset. Thus, the dataset contains description, category, urgency, resolution, and cost.Figure 2
Screenshot of the factory reports dataset.Figure3 shows the histogram distribution of the target classes. There is a total of four target classes, i.e., electronic failure, leak, mechanical failure, and software failure. It is found that the mechanical failure has a higher frequency than the others. Also, the software failures are significantly lesser than the other failures.Figure 3
Histogram distribution of the target classes.Figure4 shows the histogram distribution of the string tokens. It is found that the majority of the documents have lesser than ten string tokens. Therefore, we have truncated the strings to have length ten.Figure 4
Histogram distribution of the string tokens.Figures5 and 6 demonstrate the frequently utilized words in the training and validation dataset fractions, respectively. Wordcloud in MATLAB is used for visualization purposes. It shows the various words which are frequently, moderately, and least utilized in the factory reports dataset.Figure 5
Frequently utilized words in the training dataset.Figure 6
Frequently utilized words in the validation dataset.Figures7 shows the training analysis of the LSTM network when the Adam optimizer is utilized. It has received 89.58% validation accuracy. The epoch and iteration-wise mini-batch training and validation accuracy analysis along with respective losses and base learning rate are shown in Figure 8. From both Figures 7 and 8, it is found that the Adam optimizer-based LSTM suffers from the overfitting issue.Figure 7
Training and validation analysis of the Adam optimizer-based LSTM network.Figure 8
Epoch and iteration-wise mini-batch training and validation accuracy analysis of the Adam optimizer-based LSTM network along with respective losses and base learning rate.Figures9 shows the training analysis of the LSTM network when the RMSprop optimizer is utilized. It has received 91.67% validation accuracy. The epoch and iteration-wise mini-batch training and validation accuracy analysis along with respective losses and base learning rate are shown in Figure 10. From both Figures 9 and 10, it is found that the RMSprop optimizer-based LSTM achieves better validation accuracy and validation loss than the Adam optimizer-based LSTM. But RMSprop optimizer-based LSTM still suffers from the overfitting issue.Figure 9
Training and validation analysis of the RMSprop optimizer-based LSTM network.Figure 10
Epoch and iteration-wise mini-batch training and validation accuracy analysis of the RMSprop optimizer-based LSTM network along with respective losses and base learning rate.Figures11 shows the training analysis of the proposed ELSTM network when RMSprop optimizer is utilized. It has received 95.83% validation accuracy. The epoch and iteration-wise mini-batch training and validation accuracy analysis along with respective losses and base learning rate are shown in Figure 11. From both Figures 11 and 12, it is found that the proposed ELSTM achieves better validation accuracy and validation loss than the Adam optimizer and RMSprop-based LSTM networks. The proposed ELSTM is least affected by the overfitting issue.Figure 11
Training and validation analysis of the proposed ELSTM network.Figure 12
Epoch and iteration-wise mini-batch training and validation accuracy analysis of the proposed ELSTM network along with respective losses and base learning rate.


## 5. Conclusion

From the extensive review, it has been found that the LSTM network suffers from the parameter tuning problem. Initial and control parameters of LSTM have been selected purely on a trial and error basis. To overcome this issue, an ELSTM network has been proposed. MOGA was utilized to optimize the architecture and weights of LSTM. The proposed model has been tested on a well-known factory reports dataset. Extensive analyses have been performed to evaluate the performance of the proposed ELSTM network. From the comparative analysis, it has been found that the LSTM network outperforms the competitive models. Compared to the LSTM variants, the proposed ELSTM network achieves approximately4.2389% validation accuracy.



---

*Source: 4725639-2022-02-21.xml*