## 5 Results  
As already mentioned, the calculations were performed in the MATLAB environment. On the basis of the experiments performed, the following network options were used: network optimization algorithm: SGDM (stochastic gradient descent with momentum); learning coefficient value: 0.001; maximum number of epochs: 60; number of data analyzed by the network at a given moment (batch size): 4. The network was trained for histogram images with different numbers of classes: 28, 56, 112, and 224. The numbers of classes used are divisors of 224. On the basis of the test set, the trained network was tested and confusion matrices were plotted. These matrices for the abovementioned number of classes are shown in Figure 6. A set of 112 elements was used for training, 96 for testing, and 16 for validation. A plot of the loss function versus epochs for testing and validation is shown in Figure 7. The number of epochs was set to 60. The training process continued until the validation loss stopped fluctuating. The visible slight increase in the validation loss function (overfitting) does not reduce the accuracy of the test data. Figure 5: Examples of histogram images of x(t) signals for flows: (**a**) slug, (**b**) plug, (**c**) plug–bubble, and (**d**) bubble. Figure 6: _Cont_. The following indicators were then calculated: accuracy (_Acc_), sensitivity (_Sen_), specificity (_Spe_), and precision (_Prec_) of the relationship [52,53]:  
\[Acc=\frac{TP+TN}{TP+FP+TN+FN} \tag{3}\]  
\[Sen=\frac{TP}{TP+FN} \tag{4}\]  
Figure 6: Confusion matrices for CNN VGG-16 trained with histogram images with the number of classes: (**a**) 28, (**b**) 56, (**c**) 112, (**d**) 224. BF—bubble flow; SF—slug flow; PBF—plug–bubble flow; PF—plug flow. \[Spe=\frac{TN}{TN+FP} \tag{5}\] \[Prec=\frac{TP}{TP+FP} \tag{6}\]  
where _TP_ (true positive) are the elements that have been labeled as positive by the model and they are actually positive, _FP_ (false positive) are the elements that have been labeled as positive by the model but they are actually negative, _TN_ (true negative) are the elements that have been labeled as negative by the model and they are actually negative, and _FN_ (false negative) are the elements that have been labeled as negative by the model but they are actually positive. The results obtained are presented in Tables 1-4. \begin{table}
\begin{tabular}{c c c c c} \hline
**Number of Classes** & **28** & **56** & **112** & **224** \\ \hline bubble & 0.969 & 0.958 & 0.938 & 0.958 \\ \hline slug & 1 & 1 & 1 & 1 \\ \hline plug–bubble & 0.906 & 0.917 & 0.927 & 0.938 \\ \hline plug & 0.938 & 0.958 & 0.990 & 0.979 \\ \hline \end{tabular}
\end{table} 
Table 1: Values of the “accuracy” indicator. \begin{table}
\begin{tabular}{c c c c} \hline
**Number of Classes** & **28** & **56** & **112** & **224** \\ \hline bubble & 1 & 0.917 & 0.833 & 0.917 \\ \hline slug & 1 & 1 & 1 & 1 \\ \hline plug–bubble & 0.792 & 0.875 & 0.875 & 0.875 \\ \hline plug & 0.833 & 0.875 & 1 & 0.958 \\ \hline \end{tabular}
\end{table} 
Table 2: Values of the “ sensitivity” indicator. Figure 7: Plot of loss function versus epochs for testing and validation. The indicator values in Tables 1-3 indicate good recognition results. Precision (Table 4) indicates how much one can trust the model obtained when it predicts that the recognition result will be positive. On the basis of the precision and sensitivity indicators, the values of the \(F1\) coefficient were calculated (Table 5), which is their harmonic mean and is described by the relationship [53]:  
\[F1=\frac{2\cdot TP}{2\cdot TP+FP+FN} \tag{7}\]  
The values of the \(F1\) indicator are in the interval [0, 1], where the minimum is achieved for \(TP=0\), i.e., when all positive samples are misclassified, and the maximum for \(FN=FP=0\), i.e., for error-free classification. Two main features distinguish \(F1\) from accuracy: \(F1\) is independent of \(TN\) and is not symmetric in the case of class swapping [53]. The obtained values of the \(F1\) indicator are good in all cases, i.e., the coefficient is greater than 0.8.