# Using Hybrid LSTM Neural Networks to Detect Anomalies in the Fiber Tube Manufacturing Process
## 2 Materials and Methods
### Preprocessing of Input Data for Training Set  
A fundamental problem faced by research teams working on anomaly detection is the inability to precisely construct a training sequence, due to the fact that the vast majority of defects caused by anomalies are detected only after the completion of the production process during the final product quality checks. Usually, determining the precise temporal coincidence of a specific moment in the production process is either impossible or associated with a large spatial localization error. To address this, an initial assessment of the input data was performed by analyzing the significance of features in the recorded process state vector using the Discrete Wavelet Transform (DWT) with a Haar wavelet basis function, applying a 4-octave wavelet decomposition level. This resulted in sets of 32 features for successive windows, which illustrate different process states. For the purposes of further discussion, the following mathematical notation have been assumed. Let \(x_{i}(t)\) represent the discrete input signal registered from the \(i\)-th sensor channel of the RLM production line, where: \(i=1,2,\ldots,S_{N}\), \(t=0,1,2,\ldots,W_{s}\), \(S_{N}=232\)--denotes the number of mounted sensors in RLM line, \(W_{s}=256\)--denotes the window size, (i.e., 256 time stamps in the moving window of length 256). The matrix representation of the complete signal data from all sensors of consecutive channels within the moving window can be represented as a matrix:  
\[X(t)= \begin{bmatrix}x_{1}(t)\\ x_{2}(t)\\ \ldots\\ x_{S_{N}}(t)\end{bmatrix}  \tag{1}\]  
where \(X(t)\in R^{S_{N}\times W_{S}}\). The moving window mechanism we assume respectively: \(t_{w}\) denote the moving window size (here \(t_{w}=W_{S}\)). For every sensors channels \(i\), the windowed segment can be expressed to as: \(x_{i}(t)=\{x_{i}(k)\mid k=t,\;t+1,\;\ldots,\;t+t_{w}-1\}\). The initial research assumptions were that a pyramidal wavelet decomposition would be performed on the process coordinates so recorded, which, due to the absence of constraints on the periodicity and continuity of the signal characteristic of Fourier frequency decomposition, allows the extraction of selected components of the transformed signal into complementary components. For this purpose, we used the algorithm proposed by [41] which uses signal decomposition \(x_{i}(t)\) into approximations and details at various levels j: \(j:DWT\{x_{i}(t)\}=\{A_{j},D_{j}\}_{j=1}^{J}\), where \(A_{j}\) is the approximation coefficients at level \(j\), \(D_{j}\) is the detail coefficients at level \(j\) and \(J\) is the maximum decomposition level, depending on the length of \(x_{i}(t)\). Taking into account the technological requirements determined by the size of the analyzed window, it was assumed for the purposes of the preliminary analysis that the \(J\in\{2,3,4,5,6\}\). The multi-sensor processing with DWT is applied to each feed individually:  
\[DWT\{X(t)\}= \begin{bmatrix}DWT\{x_{1}(t)\}\\ DWT\{x_{2}(t)\}\\ \ldots\\ DWT\{x_{S_{N}}(t)\}\end{bmatrix}  \tag{2}\]  
Presented above mathematical framework ensures clarity in processing, accommodating the 232 sensor channels, 256--sample moving window, and 1--second sampling interval. Below (Figure 2) are sample fragments of the signal recorded from the RLM production line for wavelet decomposition using the Haar mother wavelet with 2 and 4 octave sizes, respectively. Figure 2: _Cont._  
Figure 2: Preliminary analysis of the manufacturing process aimed at using the Haar-based DWT transform clustering algorithm. For all waveforms in Figure 2, the designations 1, 2 and 3 stand for: the waveform of the components \(\left\{A_{j},D_{j}\right\}\) of the DWT transform, the waveforms of the leading 40 components of the production process, and the membership of the RLM line signal to the different classes extracted in the clustering process.