# Generation of Flat Optical Frequency Comb Using Cascaded Electro-Optic Modulators
## 3 Methods and Results  
The magnitude of optical power is proportional to the square of the electric field intensity. Flatness is defined as the difference between the maximum and minimum values of this squared intensity. We explored the ranges of the parameters \(A_{1}\), \(A_{2}\), \(A_{3}\), \(\theta\), and \(\Delta\varphi\) using an algorithm to determine the optimal parameter values that resulted in the lowest flatness. Our training code used a Residual Neural Network (ResNet) architecture to learn the mapping of the input parameters \(A_{1}\), \(A_{2}\), \(A_{3}\), \(\Delta\varphi\), and \(\theta\) to the output parameter flatness. We used the Adam optimizer to help the model escape local minima and find better solutions. Additionally, Bayesian optimization served as a powerful tool for the hyperparameter tuning, which could further enhance the effectiveness of model training. This approach ensured the selection of the optimal combination of hyperparameters, ultimately improving the performance and generalization ability of the final model. We opted for a well-established, lightweight network architecture that maintained accuracy while minimizing the computational complexity. The training cost of the neural network depended on the size of the dataset and various hyperparameters, including the batch size, number of epochs, and learning rate. By combining neural networks with Bayesian optimization, we could effectively accelerate the search process in the parameter space while significantly reducing the computational costs. This innovative approach merges machine learning technology with traditional optimization algorithms, enhancing both the computational efficiency and the accuracy of the optimization results. This method provides an efficient and reliable solution for optimizing complex multi-parameter systems. In this work, we propose an efficient multi-parameter optimization method that combines a ResNet with Bayesian optimization to identify the parameter combination that achieves the lowest flatness in the system. The structure of the neural network is illustrated in Figure 2.  
Specifically, ResNet serves as a nonlinear mapping model between parameters and the objective function (flatness). Its deep architecture and residual connections address the gradient vanishing problem commonly found in complex multi-parameter systems. This enables the network to capture high-dimensional nonlinear relationships in large-scale parameter systems while reducing the training difficulty. Figure 2: Scheme of ResNet and Residual Block structure. Following the structure above, the Bayesian optimization utilizes the predicted values and uncertainties of the neural network's output as the input. It constructs a proxy model based on Gaussian processes to progressively narrow down the optimal solution range for the objective function. The flatness of the system can be obtained through simulation or experimentation. Here, we used the results obtained from the simulation. For each sample, the flatness results were fed back into the neural network model to update its weights and gradually improve its predictive capability. Simultaneously, the proxy model used in the Bayesian optimization was updated to increase the sampling efficiency further. Compared with traditional methods, such as grid search or Monte Carlo simulations, our approach significantly reduces the number of samples required and the computational cost associated with parameter searches. It offers a practical and universal solution for optimization problems in complex multi-parameter systems. We added more constraints to our calculations, specifically concerning the input voltage, total power, and cascaded configuration of the control modulator. These adjustments aimed to achieve better flatness while also reducing the power consumption. In particular, we explored the following optimization strategies:  
First, we limited the input voltage of each modulator to a maximum of 2 \(V_{\pi}\).