# A Hybrid Hidden Markov Model for Pipeline Leakage Detection
## 2 Hybrid HMM Method
### DNN-DBN Pre-Training  
DNN is a feed-forward, conventional artificial neural network with a multi-layer of hidden units, regularly initialized by using the DBN pre-training algorithm. The estimates of the posterior probabilities computed by the neural network are divided by the prior state probabilities, resulting in scaled likelihoods, which are used as emission probabilities in the HMM. When it is trained on a dataset without supervision, a DBN can learn the probabilistic reconstruction of its inputs. The layers then act as feature detectors. After this learning step, a DBN can be further trained with supervision to perform classification [PERSON] et al. (2016).  
Figure 1: A hidden Markov model with three states and three observation states.  
For each hidden unit, the sigmoid function is typically used to map total input from current layer, as shown in Equation (2) [31],  
\[\begin{split} y_{j}=logistic(x_{j})=\frac{1}{1+e^{-x_{j}}}\quad,\\ x_{j}=b_{j}+\sum_{i}y_{i}w_{ij}\quad,\end{split} \tag{2}\]  
where \(j\) is the hidden unit index from range of 0 to \(N\), \(N\) is a finite positive integer, \(x_{j}\) is the current layer state, \(y_{j}\) represents the current layer output, \(b_{j}\) is the bias of current unit, \(i\) is an index over units in the layer below, and \(w_{ij}\) is the weight between two successive hidden units. For multiclass classification, the softmax function is applied to convert the DNN output into a class probability. The cost function is defined as cross-entropy between the target probabilities and the output probabilities from softmax function, as shown in Equation (3):  
\[C=-\sum_{j=0}^{N}d_{j}\log P_{j}\quad, \tag{3}\]  
where \(C\) denotes the cost function, \(d_{j}\) represents the target probabilities and \(P_{j}\) is the probabilities of outputs. Thus, the target probabilities of the HMM states are the learned information provided to train the DNN. One of the benefits of using a DNN is that it can efficiently computes derivatives before updating the weights in proportion to the gradient by dividend large datasets into random minibatches. This stochastic gradient descent method can be further improved by using a momentum coefficient [21].  
DBN provides a new way to train deep generative models by using layer-wise pre-training of RBMs. In this way, the pre-training process will provide proper initial weights for the DBN. A DBN that consists of visible layers and hidden layers is shown in Figure 2.  
Two successive hidden layers in DBN form an RBM. The DBN is composed by stacked modules of RBMs. Low-dimensional features are extracted from input data by pre-training of the DBN without losing much significant information. Each RBM in the DBN is a bipartite graph where there is no connection between each hidden unit on the same layer. The joint probability of an RBM is defined as  
\[P_{h,v}(RBM)=\frac{1}{Z_{h,v}}e^{x^{\prime}Wh+v^{\prime}b+a^{T}h}\quad, \tag{4}\]  
where \(h\) defined as hidden vectors for the Bernoulli-Bernoulli RBM [32] applied to binary \(v\) with a second bias vector \(b\), bias vector \(a\), weight matrices \(W\) and normalization term \(Z_{h,v}\).  
\[P_{h,v}(Gaussian-Bernoulli\ RBM)=\frac{1}{Z_{h,v}}e^{x^{\prime}Wh+(v-b)^{ \prime}(v-b)+a^{T}h}\quad, \tag{5}\]  
Figure 2: DBN structure.  
where Gaussian-Bernoulli RBM (GRBM) [32] is applied to continuous \(v\). In both cases, the conditional probability \(P_{h,v}(h,v)\) has the same form as that in the DNN [20]. The RBM parameters can be efficiently trained in an unsupervised fashion by maximizing the likelihood over training samples with the approximate contrastive divergence algorithm [21].