Demonstration of a fast-training feed-forward machine learning algorithm for studying key optical properties of FBG and predicting precisely the output spectrum

In this article, we propose and demonstrate a generalized machine learning (ML) approach to analyse the various optical properties of the Fiber Bragg grating (FBGs), namely effective refractive index, bandwidth, reflectivity and wavelength. For this purpose, three commonly used variants of FBG, namely conventional, π phase-shifted and chirped ones are investigated and the reflected spectra of the aforementioned FBGs are predicted using ab initio artificial neural networks (ANNs). We implemented a simple and fast-training feed-forward ANN and established the efficacy of our model by predicting the output spectrum with minute details for unknown device parameters along with non-linear and complex behaviour of the spectrum. Thus, our proposed ANN model is capable of predicting various key optical properties and reproducing the exact spectrum accurately and quickly, providing a cost-effective solution for efficient and precise modelling.


Introduction
Fiber Bragg gratings (FBGs) form a unique class of inline fiber optic components which are in extensive use in many crucial applications in today's fiber optic communication and photonic sensing (Orthonos and Kalli 1999;Zhang et al. 2016;Dey et al. 2021a). One of the key features driving wide-scale R&D with new methods and implementation of FBGs is that it can be widely and precisely tuned by varying their associated geometrical parameters. Various types of FBGs are realized and implemented in a range of applications in the field of fiber-based communication and sensor systems. Conventional FBGs with periodic refractive index (RI) are successfully used for dispersion compensation as well as in a large number of sensors covering various physical perturbations such as acoustic, magnetic, temperature, strain, refractive index, rotation etc. (Su et al. 2019;Sun et al. 2021;Dey et al. 2021b). A π phase-shifted FBG can be achieved by slightly modifying the geometry of the conventional FBG structure. It yields an ultra-narrow notch in FBG spectrum which can be explored for enhancing the sensitivity and resolutions (Srivastaba and Das 2020). Another popular type of FBG is chirped FBG which is designed by introducing a nonuniform modulation of the refractive index along with the fiber on the periodic structure. Chirped FBGs (CFBG) is used for FBG interrogation and multiplexing technique along with a high-resolution sensing capability in dynamic measurement. It is also widely used in optical communication due to its dispersion compensation property (Daniele and Tosi 2018). These FBGs are characterized by specific properties such as effective refractive index (n eff ), central Bragg wavelength (λ B ), reflectivity and bandwidth spectrum. Due to distinct geometrical designs and light propagation mechanisms, each type of FBGs requires dedicated numerical modelling for analyzing the structure (Yanyu Zhao and Palais 1997;Phing et al. 2007;Stathopoulos et al. 2019).
Owing to the capabilities of extracting essential information from a multitude of datasets, the machine learning approach has brought a thoroughgoing rehabilitation in the field of photonics. Such investigations to simulate the features of photonic components have been reported for these purposes in the last few years. Several intensity and wavelength division multiplexing-based FBG sensors have been proposed and demonstrated using different deep learning and extreme learning machine methods Dehnaw et al. 2020;Jing et al. 2014;Maine et al. 2018) first time proposed deep learning algorithms for intensity wavelength division multiplexing (IWDM)-based self-healing fiber Bragg grating (FBG) sensor network to improve the accuracy of the sensor signal .
Keeping these in mind, we have proposed here a unified analyzing method covering these three widespread FBGs namely conventional FBG, π phase-shifted FBG and Chirped FBG. We developed the analysis model by exploring and nurturing the machine learning algorithm. The simulation using MATLAB and Artificial Neural Network (ANN) has been put together to compute rapidly and exactly. The main goal is to construct a simple feedforward multilayer perception (MLP) model which can be trained quickly to estimate the effective refractive index, central Bragg wavelength, reflectivity and the bandwidth of the FBGs. Furthermore, we have demonstrated the machine learning technique using a single ANN model to predict the reflection spectrum of different kinds of FBGs such as normal, π phase-shifted and chirped FBG accurately for a large amount of data. Moreover, we show how our model can handle the non-linearity and complexity of the output spectrum exactly.
The paper has been organized as follows: Sect. 2 describes the simulation setup employed to perform the simulation. Section 3 describes the ANN modelling. Here two different models for analyzing the important parameters of FBG along with predicting the reflected spectra of different FBGs have been demonstrated. Section 4 presents the optimization of the epochs. Section 5 describes the different numerical results. The computation performance in terms of computational runtime is shown in Sect.6 and finally, the paper is concluded in Sect.7.

Simulation setup
In this section, we will discuss the simulation setup employed to generate a huge chunk of datasets that have been incorporated into the ANN modelling for further studies.

For analyzing optical properties
The main optical characteristics of FBG namely, the central Bragg wavelength, effective refractive index, reflectivity and bandwidth have been analyzed here. The governing equations used for performing the simulation using MATLAB are as follows.
We assume a grating having a uniform refractive index and period with a grating length of L . The reflectivity ( R ) of the grating is expressed as (Othonos et al. 1999) where k is the coupling coefficient and is defined as For uniform FBG w(z) =1 and the fringe visibility v is also 1. Hence the ac coupling coefficient becomes is the core propagation constant and Δ is the wave vector detuning. If the grating is uniformly written, the detuning factor becomes zero. The reflectivity function becomes From the above equation it can be concluded that, as the grating length increases, the resultant reflectivity also increases.
The reflective bandwidth of the uniform grating can be calculated as

For predicting the output spectrum of different FBGs
The reflection spectrum for normal FBG is defined as described in eq. (1). The reflected spectrum for π phase-shifted FBG (Srivastava Deepa and Das 2020) is given by , λ is the wavelength. Similarly for the chirped FBG (Tosi 2018) (1) R NFBG L, B = k 2 sinh 2 ( L) , n eff denotes the amplitude of modulation of refractive index. The above equations are employed to generate the dataset which is nothing but individual points using MATLAB that has to be fed as input to the ANN.

FBG modeling with ANN
ANN, a machine learning technique, is formulated on the structure of the biological neural network. This technique has the potential to solve a complex problem even though the input data set includes errors and is incoherent. Furthermore, it can estimate variables that cannot be measured directly. Figure 1 shows the flowchart for the detailed implementation of our proposed ANN model. The pre-processing of the collected data involved the normalization of the input variables along with the shuffling to avoid the biasing towards a specific dataset.
The MLP architecture is used in this section for generating the dataset. The datasets which have been produced primarily play a key role in developing the basic structure of the ANN. The precision of the model depends only naturally on how well the dataset has been lined up to solve the particular problem. In our research here, two different ANN models are proposed for analyzing the useful optical characteristics of the FBG and to predict the output reflection spectra of different types of FBGs, respectively.

Feature scaling
Since the datasets are not distributed uniformly over a particular range, so it is mandatory to apply the feature scaling property before feeding them to the ANN. Normalization is one type of feature scaling. It is a scaling method where the data are rescaled over [0,1]. For this at first, one needs to employ the MinMaxScalar in the dataset. Thereafter, the maximum value is to be kept to 1 while the minimum value is 0. This is typically accomplished to facilitate the convergence of ANNs. The function could be defined as where X represents the characteristics of the FBG. Fig. 1 Flowchart of the ANN execution

Modelling architecture for analysis of optical properties
In our ANN model, we have taken 5000 data sets that constitute individual data points which are partitioned into 80% training, 10% validation and 10% test data points. The data points consist of input parameters: refractive index of the core and the cladding, periodicity and the grating length, and output parameters, namely, the effective refractive index (n eff ), Bragg wavelength (λ B ), reflectivity and bandwidth. ANN model consists of 3 hidden layers and 40 nodes/neurons in each layer. It has been observed that 3 hidden layers with 40 nodes in each layer are seen to be reasonable to fast procure a stable mean squared error (MSE). Further increase in the number of nodes and layers will increase the computational load and hence be avoided. The popular "Rectifier linear unit" (ReLU) function has been used as an activation function and "Adam" optimizer for "gradient descent back-propagation" optimization with a learning rate of 0.0001. Adam optimizer is employed because it adaptatively accelerates the weights and biases of ANN over each epoch, hence providing a proper trade-off between training time and learning rate. We have trained our model for 500 epochs (iterations) (Fig. 2).

Modelling structure for predicting the output spectrum of different types of FBGs
To predict the output spectrum of different types of FBGs using our proposed ANN model, we considered a total of 10,000 data sets, which constitute individual data points. These data points are split into 80% training, 10% validation and 10% test data points. The data points consist of the input parameter, i.e., a wavelength which has been divided into two different ranges (hence two inputs at the input layer of the model). In order to show the side lobes of the normal and π phase-shifted FBGs, a larger range along the x-axis has been considered over chirped FBG. Hence, the former two FBG datasets contain different step sizes which insisted to divide the wavelength along the x-axis into two parts, and hence adopted into the ANN model as two different input layer nodes. The output parameters are reflectivity of normal, chirped FBG and. The model consists of 7 hidden layers. Each hidden layer consists of 500 nodes. The popular "Rectifier linear unit" (ReLU) function has been used as an activation function and "Adam" optimizer for updating 'weights' and 'biases' by reducing the 'loss function' of the model (Fig. 3).

Optimization of the number of epochs
Training an ML model in a well-fashioned manner to predict the output for unknown parameters accurately is of paramount importance. To achieve a well-trained model, the number of epochs plays a vital role. The number of epochs with the lowest mean squared error (MSE) is always desirable for this purpose. Here, we have optimized the epochs to train the model meticulously for the training data set.
To optimize the epoch for analyzing the optical properties, 500 epochs are taken into consideration for the training and validation data set. From Fig. 4, we can see that as the number of epochs increases the MSE decreases. In our model, epochs of 500 are considered to make the prediction values closer to the actual values. The model is run till the MSE reaches the almost stable value i.e., 0.0000023. Furthermore, it has been observed that 500 epochs can predict different optical properties thoroughly and precisely. The figures in inset shows a clear visualization of fluctuation of the MSE with the number of epochs. Therefore, to attain a stable MSE value, we continued up to 500 epochs. Also, it has been observed that 500 epochs can analyze different properties thoroughly. Moreover, as the input dataset is well organized, hence with a smaller number of epochs, the MSE value closer to zero is obtained which can predict the output accurately.
Similarly, for predicting the output spectrum of different kinds of FBGs, 8000 and 1000 data is used to train and validate the model, respectively. 2000 epochs are fixed for this purpose. From Fig. 5 it can be depicted that, as the no. of epochs increases the MSE loss decreases.

Analysis of various optical properties of FBG
In this section, we describe how we have verified our proposed ANNs. For this, the outputs of the model are assessed for the unknown input parameters. Attention is paid to the effective refractive index, bandwidth, reflectivity and wavelength of the FBG that are the main parameters when used in various sensing applications including multiplexing/ demultiplexing. Figure 6 shows the scattered plot of the predicted n eff values versus the exact values of the n eff . The predicted values of n eff are obtained from our proposed ANN model while the exact values are recorded from the simulation using MATLAB. Due to the overlap of the closely spaced predicted data, a continuous plot can be observed. A linear trained nature clearly reveals the well-trained behaviour of the model.

Bragg wavelength (λ B )
The Bragg wavelength of FBG plays a vital role in sensing purposes (Dey et al.2021cand Xiaoyan Sun et al.2021. Accurate measurement of this parameter is of paramount importance in different applications. We have chosen the most useful wavelength range i.e., 1500−1600 nm for our investigation and using our proposed ANN model, we have predicted the wavelength of the FBG. Figure 7 depicts a linear relationship between the actual and the predicted values of Bragg wavelength. 500 epochs are considered to predict the wavelength accurately. Evidently, this signifies how well our model can accurately predict the unknown wavelength. The demodulation technique of FBG-based sensors relies on the precise detection of the wavelength shift of the sensor peak at the Bragg wavelength. Hence, it is important to analyse this aspect of the spectral characteristics of an FBG sensor. It is reported that the grating length plays a significant role to design a high-performance FBG sensor (Phing et al. 2007). Therefore, the two most important parameters of the spectrum i.e., reflectivity and bandwidth are considered for higher order study. To procure the input data, well-known coupled-mode equations are solved by the transfer matrix method.

Reflectivity
The most important parameter to consider, while fabricating a grating for a target application with a set of given geometrical parameters, is the reflectivity of the grating. Reflectivity is quantified as the percentage of light reflected at the Bragg wavelength. It changes with increasing grating length. In this study, the change of reflectivity has been Fig. 6 Scatter plot of a training dataset of predicted and actual for n eff Fig. 7 Scatter plot of a training dataset of predicted and actual wavelength analyzed using our proposed ANN model with the elevation of the grating length. The result is compared with that simulated directly using MATLAB.
For grating lengths varying from 1 to 50 mm, the change in reflectivity is computed and shown in Fig. 8a. The figure depicts the relationship and comparison between MAT-LAB results using the aforesaid parameters and those of our proposed ANN model. Clearly, a very good matching of these results is observed. Reflectivity increases rapidly with the increase in the grating length. The highest reflectivity is observed from the length of the grating of 8.5 mm onwards.
It is worthy to note that, our model can predict the non-linear behaviour of the parameters.
Furthermore, the scatter plot between the actual and the predicted reflectivity has shown in Fig. 8b. A linear relationship between the two parameters ensures the welltrained behaviour of the model. Due to the coherent nature of the input data set, more data are accumulated over the range of 90 to 100% in the plot.

Bandwidth
The bandwidth, a measure of the spectral width of the reflected signal is measured at the full-width half maxima (FWHM). To investigate the dependence of grating length on the bandwidth of the FBG spectrum, the grating length is varied in range from 1 to 50 mm. Figure 4.1.4 shows the relationship between the aforesaid parameters. The tendency is very similar to the results of reflectivity change but in an inverse direction. Here 3-dB bandwidth change shows an exponential decrease over the elevation of the grating lengths. The simulated result is shown in Fig. 9a while an exact match in the relationship is observed while performing using the proposed ANN model. In the case of a 1 mm FBG sensor, the bandwidth is around 1.40 nm. The bandwidth reduces as the grating length increases. The grating length reduces to around 1.03 nm at a grating length of 5 mm. A constant value of the bandwidth is maintained beyond the grating length of 5 mm. The scatter plot between the actual and predicted data for the bandwidth is shown in Fig. 9b. A linear relationship between the actual and the predicted values of bandwidth is observed. Hence the well-trained nature of the proposed model is established.

Predicting the reflection spectrum of the different FBGs
FBGs are distributed Bragg reflectors that reflect a particular wavelength of light and transmit others. This is achieved by the periodic variation of the refractive index along with the core of the fiber.
By changing the periodicity of the gratings, different types of the reflected spectrum of FBGs can be achieved. Chirped FBG is one of these types of FBG having non-uniform periodicity along the length of the fiber (Fu Liu et al. 2014). Furthermore, dynamic strain measurement with higher resolution (pico-strain) is an important area of research and development (Srivastava Deepa and Das 2020). With normal FBG it is quite impossible to breach the limit. π phase-shifted FBG, expected to be used widely in near future is a successful candidate in these aspects. π phase-shifted FBG can be fabricated on a standard FBG by introducing a phase jump at the center of the grating. Due to the very sharp resonance peak, this type of FBG shows a higher resolution and enhance sensing capabilities (Zhai et al. 2019).
Keeping all these aspects in mind, this section is devoted to describing how the proposed ANN model predicts the reflected spectrum of three different types of FBG: normal, π phase-shifted and chirped FBG using.
The reflected spectrum for three different types of FBGs is shown in Fig. 10. The spectra obtained using our proposed ANN model have been compared with those obtained using MATLAB coding of the analytical equations. A nearly exact match between these is observed. Hence it can be concluded that our proposed model can predict the output spectrum of different types of FBGs accurately within seconds, while numerical simulation methods require a few minutes to solve.
Furthermore, it should be noted that our proposed model can predict the non-linear behaviour and complexity of the spectrum entirely as expected. To avoid ambiguity in reading the graphs, it is mentioned that the wavelength values along the x-axis of Fig. 10a and b are not in the range of −0.15 to 0.15 . Each specified value is added by a constant number of + 1.55e3 as depicted at the rightmost end of the x-axis which signifies the wavelength range 1549.85-1550.15 nm. This is considered to be a default plotting feature in the python programming language.
Seven hidden layers with 500 nodes in each are used throughout the code, which offers rapid convergence and sufficient accuracy in predicting the output for unknown dimensions. Thus, it is emphatically inferred that the proposed model will find a wide range of applications in the field of guided wave optics and photonic devices.

Computational performance
In this section, we have described the computational performance in terms of the 'runtime' of our proposed ANN model. For computing using the ANN model, a laptop with Intel Core i7 10th generation, CPU @ 2.30 GHz, 16 GB RAM with GPU configuration: Nvidia RTX 2080 Super Max-Q with 8 GB RAM having Windows 10 operating system. The runtime to train the ANN model fully depends on the parameters such as the size of the input data set, number of the optimized hidden layers, number of neurons in the layers, number of epochs etc. Here two different models are used for two purposes. For analyzing the optical properties of FBG, 3 hidden layers with 40 nodes in each layer running for 500 epochs are optimized. It took around 23 s to train the model with the generated data set. While for predicting the output spectrum, 7 hidden layers with 500 nodes in each layer running for 2000 epochs are optimized. To train, the model took around 7 min. After completing the Fig. 10 Reflected spectrum obtained using MATLAB and proposed ANN model for a normal FBG, b π-phase-shifted FBG and c chirped FBG, respectively training process, weights and parameters are saved on the computer. The prediction and analysis are carried out using the already saved weights. Conversely, the numerical simulation using MATLAB requires a few minutes for calculating each point. It may still take a long time if a denser mesh is considered.

Conclusion and outlook
In summary, we worked out and implemented a supervised machine learning algorithm using the ANN model to accurately and efficiently predict the key optical properties of different types of FBGs along with generating vividly the reflected spectrum. In particular, our proposed models can determine precisely the effective refractive index, central Bragg wavelength, reflectivity and the bandwidth of the FBG. Furthermore, the output spectrum of normal, π phase-shifted and chirped FBG is predicted accurately using a single platform of the algorithm. The hidden layers and the neurons in each layer are optimized to offer rapid convergence with sufficient precision in predicting the outputs for unknown parameters. The comparison between the actual and the predicted values of different types of FBG parameters shows excellent agreement. A straight-line plot reflects the well-trained behaviour of the model. The number of epochs and the neurons in each layer is optimized to avoid overfitting and under-fitting problems. The proposed ANN model can portend within a few seconds while it takes a much longer time when using MATLAB coding and other simulation platforms.
Notably, the proposed algorithm can predict the complex and non-linear behaviour of the spectra. Also, this promising model could be uniquely adopted to solve both the forward and inverse problems and can be extended to different waveguides to analyze associated optical properties and phenomena efficiently and precisely.