## 3 Design of Proposed Intelligent FSO System
### Transmitter Module
```
1:Input: Eye diagram image \(\mathbf{I}\in\mathbb{R}^{256\times 192}\) (grayscale)
2:Output: Binary label \(y\in\{0,\;1\}\), where \(y=1\) if \(\text{BER}\geq\text{BER}_{\text{th}}\), else \(y=0\)
3:Procedure Binary BER Classifier CNN (\(\mathbf{I}\))
4://Preprocessing
5:Normalize pixel values of \(\mathbf{I}\) to range \([0,\;1]\)
6:Reshape I to shape (256, 192, 1) for CNN compatibility
7://CNN Architecture Definition
8:Define Sequential CNN model \(\boldsymbol{\mathcal{M}}\) with the following layers
9:Input Layer: shape (256, 192, 1)
10:Conv2D Layer 1: 32 filters, kernel size (\(3\times 3\)), activation = Relu
11:MaxPooling2D Layer 1: pool size (\(2\times 2\))
12:Conv2D Layer 2: 64 filters, kernel size (\(3\times 3\)), activation = Relu
13:MaxPooling2D Layer 2: pool size (\(2\times 2\))
14:Platten Layer
15:Dense Layer: 128 units, activation = Relu
16:Output Layer: Dense(1), activation = Sigmoid
17://Model Training
18:Train model \(\boldsymbol{\mathcal{M}}\) using:
19:Loss function: Binary Cross-Entropy
20:Optimizer: [PERSON]
21:Training labels \(y\in\{0,\;1\}\) (based on \(\text{BER}_{\text{th}}\))
22://Inference
23:\(\hat{y}\leftarrow\boldsymbol{\mathcal{M}}(\mathbf{I})\) //Predict label from input image
24:Return:\(\hat{y}\in\{0,\;1\}\)
25:End Procedure
```
**Algorithm 2**CNN for binary BER classification

Algorithm 3 outlines an LeNet-based CNN framework for predicting continuous-valued signal quality metrics, such as the BER or Q-factor, from eye diagram images. The architecture is trained using MSE loss and leverages a compact convolutional structure to perform efficient and accurate regression. ```
1:Input: Eye diagram image \(\mathbf{I}\in\mathbb{R}^{H(height)\times W(width)}\)(black & white scale)
2:Output: Predicted value \(\hat{y}\in\mathbb{R}\), representing either BER or Q-factor
3:Procedure Predict Metric with LeNet (\(\mathbf{I}\))
4://Preprocessing
5: Resize input image \(\mathbf{I}\) to shape (64\(\times\)64)
6:Normalize pixel values of \(\mathbf{I}\) to the range \([0,\ 1]\)
7:Reshape I\(\rightarrow\)(64, 64, 1) for LeNet input
8://LeNet Architecture Definition
9:Define LeNet model \(\mathcal{L}\) as follows:
10:Input Layer: shape (64, 64, 1)
11:Conv2D Layer 1: 6 filters, kernel size (5 \(\times\) 5), activation = Relu
12:MaxPooling2D Layer 1: pool size (2 \(\times\) 2)
13:Conv2D Layer 2: 16 filters, kernel size (5 \(\times\) 5), activation = Relu
14:MaxPooling2D Layer 2: pool size (2 \(\times\) 2)
15:Flatten Layer
16:Dense Layer 1: 120 units, activation = Relu
17:Dense Layer 2: 84 units, activation = Relu
18:Output Layer: Dense(1), linear activation (for regression output)
19://Model Training
20:Train model \(\mathcal{L}\) using:
21:Loss function: MSE
22:Optimizer: Adam
23:Target values: Continuous BER or Q-factor measurements
24://Prediction
25:\(\hat{y}\leftarrow\mathcal{L}(\mathbf{I})\)//Predict BER or Q-factor
26:Return:\(\hat{y}\in\mathbb{R}\)
27:End Procedure
```
**Algorithm 4** Wide ResNet for Q-prediction

Algorithm 4 details a Wide ResNet regression model developed for Q-factor prediction from eye diagram images. The model consists of an initial convolutional layer followed by multiple wide residual blocks with increasing filter dimensions, global average pooling, and a fully connected regression head. The network is trained using MSE loss and it is validated with early stopping to optimize generalization performance.