## 3 Materials and Methods
### The Principle of LSTM-Based Risk Estimation Methodology
#### 3.3.2 The LSTM-Based Deep Learning Network Architecture  
The LSTM-based deep learning network architecture designed for risk estimation is shown in Figure 6, including six layers: _sequecInputLayer_, _wordEmbeddingLayer_, _lstmLayer_, _fullyConnectedLayer_, _softmaxLayer_, and _classificationLayer_. The function of each layer is as follows:  
Figure 6: Architecture of LSTM-based deep learning network for risk estimation.  
sequenceInputLayer: Input the sequences corresponding to the hazardous situation descriptions to the network.  
wordEmbeddingLayer: The word-embedding layer maps the sequence of word indices to embedding vectors and learns the word embedding during training. It processes the sequences into word vectors, representing the sequences of corresponding hazardous situation descriptions with low-dimensional dense vectors. The embedding vectors can effectively capture specific attributes of the related objects, and the distance between these vectors serves as an indicator of the similarity between the objects [30].  
lstmLayer: The output mode of this layer was set to output the last time step of the sequence, realizing sequence (embedding vectors representing hazardous situation description)-to-label (risk index of the corresponding hazard event) classification [31]. See Section 3.3.1 for the principle of thelstmLayer algorithm.  
fullyConnectLayer: A fully connected layer connects the output oflstmLayer to the risk indices, which multiplies the input by a weight matrix and then adds a bias vector. All neurons in a fully connected layer connect to all those neurons in the previous layer. So, this layer combines all of the features (local information) learned by the previous layers to classify the sequence. In Equation (7), \(Z\) denotes the output of the ith node, \(X_{t}\) denotes time step t of \(X\), \(W\) denotes weight matrix, and \(b\) denotes bias matrix.  
\[Z=WX_{t}+b \tag{7}\]  
softmaxLayer: Converts the output of fullyConnectedLayer to the probability corresponding to each risk index. The \"softmax\" function is applied to the input of the layer, and the output value of the multiclass classification can be transformed into a probability distribution within the specified range \([0,1]\). The sum of the probability is 1. Where \(y\) is the output value of the \(i\)th node, \(C\) is the number of output nodes, that is, the number of risk indices for risk estimation, as shown in Equation (8).  
\[softmax(y_{i})=\frac{e^{y_{i}}}{\sum\limits_{c=1}^{C}e^{y_{C}}} \tag{8}\]  
classificationLayer: The classification layer calculates the cross-entropy loss (Equation (9)) for classification tasks with mutually exclusive classes and weighted classification tasks, obtaining the risk index corresponding to the hazardous situation description utilizing sequence-to-label classification. In the classification layer, the training network takes values from the \"softmax\" function. It assigns each input to one of the K mutually exclusive classes using the cross entropy function for a 1-of-K coding scheme [32].  
\[loss=-\frac{1}{N}\sum\limits_{n=1}^{N}\sum\limits_{i=1}^{C}w_{i}t_{ni}\ln y_{ni} \tag{9}\]  
where \(N\) is the size of the training dataset, \(C\) is the number of risk indices, \(w_{i}\) is the weight for risk index \(i\), \(t_{ni}\) is the indicator that the nth hazardous situation belongs to the risk index \(i\), \(y_{ni}\) is the probability that the network associates hazardous situation description n with risk index \(i\), which is the output of softmaxLayer.