## 6 CNN Model Architecture, Design, and Implementation
### CNN Algorithm  
CNNs are widely used in optical communications and networking. Regarding UWOC, ref [111] proposed a constellation diagram recognition and evaluation method using deep learning (DL). ML is applied in networking systems to address tasks in the physical layers. These tasks include monitoring systems, assessing signal degradation effects, optimising launch power, controlling gain in optical amplifiers, and adapting modulation formats. It is also used in nonlinearity mitigation [15]. The optical receiver can serve as an OPM in addition to its primary function of receiving data. A signal waveform is graphically represented in an eye diagram to locate optical signal impairments. The amplitude distribution over one or more-bit periods is depicted by overlapping the symbols. Eye diagrams are employed to evaluate the strength of high-speed digital signals [53]. A data waveform is typically applied to the sampling oscilloscope's input to create them. Then, all conceivable one-zero combinations are overlapped on the instrument's display to cover three intervals [54]. Pulses are spread out beyond the period of a single symbol because of the ISI, which results from temporal variations between light beams arriving at the receiver from multiple pathways. At data rates greater than 10 Mbps, ISI seriously impairs the system's performance. A clustering algorithm is used to identify anomaly \begin{table}
\begin{tabular}{c c} \hline \hline
**Metadata** & **Values** \\ \hline Water types & Harbour and coastal waters \\ Channel models & DGF, WDGF, CEAPF, and BP \\ Pulse shapes & Gaussian and Rectangular \\ Pulse widths & 0.1, 0.15, 0.2, 0.25, 0.3, 0.35, 0.4, 0.45, 0.5, 0.55, \\  & 0.6, 0.65, 0.7, 0.75, 0.8, 0.85, 0.9, 0.95 \\ Centre positions on the eye diagrams & 0/1 \\ \hline \hline \end{tabular}
\end{table} 
Table 2: The required attributes for generating eye diagram images and calculating SNR. Figure 9: Examples of eye diagram images. attacks without being aware of the attacks beforehand. In ref. [112], a groundbreaking application of ML in optical network security has been reported. The findings showed that ANNs have a significant potential for detecting out-of-band jamming signals of various intensities with an average accuracy of 93%. Using TensorFlow and Keras 2.12.0, were used. The CNN algorithm is used on eye diagram images to predict the values of SNR in different cases based on UWOC. To organise the inputs in a particular way or convert the relationship to a function that might predict an output, a CNN learns associations between the properties of the input data it receives. In this study, eye diagrams represent signals, and the result for SNR prediction and its magnitude is the type of impairment. This study's total number of samples is 576 eye diagram images, split into 404 and 172 for training and testing data, respectively. The structure and implementation of the CNN in this study are as follows:  
1. The dimensions of the input eye diagram images are 2366 \(\times\) 3125 pixels, with a resolution of 600 dpi. 2. The network includes convolutional layers with a filter size of 10 and a stride of 1. The filters range from 16 to 64, increasing by four at each step. There is no activation function applied. 3. There are three non-overlapping max-pooling layers with a size and stride 3. 4. Flattened values refer to the input values that will be fed into the NN. 5. This study refers to the hidden layer as FC and uses the ReLU activation function to reduce the CNN calculations by setting negative values to zero. 6. The ultimate output of the CNN is the prediction of the signal-to-noise ratio (SNR) using a linear activation function, which is appropriate for regression tasks. The Functional API model was used with the Adam optimiser, and the learning rate is equal to \(1\times 10^{-5}\). Figure 10 shows the model structure; each circle represents convolutional and max pooling layers. The architecture contains five convolutional and max pooling layers.