# An Application of the Associate Hopfield Network for Pattern Matching in Chart Analysis
## 3 Materials and Methods
### Learning Associate Hopfield Network  
The Hopfield network is an important tool for memory retrieval. Traditional discrete HNN [16] can be defined by using Hebb's rule. In 2011, [PERSON] et al. [20] firstly proposed the Learning Associate Hopfield Network, which can be applied in continuous-time real-world problems. They adopted the \(m\) energy function method to analyze the retrieval property of the CHNN and proposed sufficient conditions for local and global asymptotic  
Figure 4: A time-series subsequence is represented by a 10-by-10 grid [13], which with the cell containing the data points of the sequence. The array \([0,5,5,6,8,9,8,2,4,0]\) is the pattern identification code (PIC) of the time series sequence, which is the data points’ vertical positions of the line during the time.  
stability in [19]. Based on that theorem, the given patterns can be assigned as locally asymptotically stable equilibria of the learning associate Hopfield network (LAHN) by error back-propagation algorithm. The neural dynamics of LAHN can be described as following equations:  
\[\dot{x}(t)=A^{-1}(WF(x(t))+\Theta) \tag{8}\]  
\[\Delta x(t)=\dot{x}(t)-x(t) \tag{9}\]  
\[x(t+1)=x(t)+\alpha\Delta x(t) \tag{10}\]  
where \(x\) denotes the initial neuron states, \(\Theta\in\mathbb{R}^{n}\) is a real constant vector. \(A\in\mathbb{R}^{n\times n}\) is a positive diagonal matrix, \(W\in\mathbb{R}^{n\times n}\) is the asymmetric weight matrix that can be learned from the error back-propagation algorithm. \(F(x)\) denotes a continuous activation function that is differentiable [20], \(\alpha\) is the growing rate.  
In [19], a sufficient condition is given for the local stability of the equilibria.  
**Theorem 1**.: \(X^{(i)}\) _is locally asymptotically stable if \(\lambda_{1}[H-A\Phi(X^{(i)})]<0\)._  
In Theorem 1, \(\Phi(X)=diag(f_{1}^{{}^{\prime}}(x_{1}),\cdots,f_{n}^{{}^{\prime}}(x_{n}))^{-1}\), \(H=(W+W^{T})\), \(\lambda_{1}(\cdot)\) denotes the maximum eigenvalue of a matrix. In order to train the LAHN, we choose a proper differentiable activation function. The training datasets are the stored patterns, and the label of the stored pattern \(X^{(i)}\) is \(AX^{(i)}\). Based on that, we could describe the training data as this form: \(D=\{(X^{(1)},AX^{(1)}),\cdots,(X^{(m)},AX^{(m)})\}\). The training process of LAHN would be described in Algorithm 2.  
In this paper, we propose a pattern matching approach by LAHN that is tailored for our pattern representation method, for different representations we choose different activation functions and different initialization of \(A\) and \(W\). The growing rate \(\alpha\) is also variant with different neuron sizes. The detailed parameter setting would be described in Section 4.2.  
```
0: the predefined patterns \(P=(p_{1},\cdots,p_{m})\), activation function \(f(x)\), diagonal matrix \(A\), the threshold of squared error \(T\), learning rate \(lr\);
0: the asymmetric weight \(W\) and bias \(\Theta\);
0: Initialize \(W\) and \(\Theta\), squared error (SE) = 0;
0:while\(SE>T\)do for each stored pattern \(p_{i}\) in \(P\)do
0:\(out\gets Wf(p_{i})+\Theta\); \(y_{i}\gets Ap_{i}\);
0: Get the training loss of each training sample: \(loss\leftarrow(y_{i}-out)^{2}\);  Compute the derivative of \(W\) and \(\Theta\);
0:\(W\gets W-lr\times\frac{\partial loss}{\partial W}\), \(\Theta\leftarrow\Theta-lr\times\frac{\partial loss}{\partial\Theta}\); endfor
10: Calculate overall squared error; endwhile
12:return\(W,\Theta\);
```  
**Algorithm 2** Training process of LAHN.