## 2 Materials and Methods
### Artificial Intelligence  
In recent years, it has been proved that artificial intelligence can be implemented as a powerful tool for various engineering applications [29; 30; 31; 32; 33; 34; 35; 36; 37; 38; 39; 40; 41; 42; 43; 44; 45; 46; 47; 48; 49; 50; 51; 52; 53; 54; 55; 56; 57; 58; 59; 60; 61; 62; 63; 64; 65]. There are several kinds of ANNs, in which multilayer perceptron (MLP) is the most well-known kind of them. This kind of ANN has a good ability for regression and classification. This network is constructed from at least three layers of neurons: The input layer, the hidden layer (or hidden layers), and the output layer. There are different techniques to calculate the biases and weights of this mathematical network, of which Levenberg Marquardt (LM) is most well-known algorithm in this regard. In the present investigation, two different MLP-LM networks with four inputs and one output were considered. Four features were extracted from the recorded spectra in the detectors and were considered as MLP-LM inputs. The procedure of obtaining gas, oil, and water volume fraction percentages independent of scale layer thickness is indicated in Figure 5. The trained networks can estimate the percentages of gas and oil volume fraction based on input signals independent of scale layer thickness, correctly.  
Figure 4: Experimental setup including 2 NaI detectors and one radioactive source [28].  
Figure 5: The procedure of obtaining gas, oil, and water volume fraction percentage in a three-phase flow independent of scale layer thickness.  
A total of 252 different cases were simulated using MCNPX code; 177 cases were implemented for training the network, and 75 cases were used for testing the efficiency of presented MLP-LM. In order to obtain the optimum structure of proposed networks, different structures with various number of layers, neurons in each layer, epochs, and different activation functions were tested. For this purpose, different loops were defined, and, with trial and error, the optimum architecture was found. The mentioned algorithm is:  
1. The data set, counters, and error are defined.
2. The data set is normalized.
3. The parameters initial values are set.
4. Several loops are created.
5. Different number of layers, neurons in each layer, epochs, and different activation functions are tested.
6. The efficiency of each network is checked.
7. The best network with lowest error is saved.  
The best structure of presented MLP-LM model for gas volume fraction measuring has one hidden layer consists of 9 neurons. The number of epochs was 685. The best structure of presented MLP-LM model for oil volume fraction measuring has one hidden layer consists of 10 neurons. The number of epochs was 750. Architectures of the ANN models were shown in Figure 6.  
The mathematical equations for the first MLP-LM model are as follows. The input to the neuron \(\mathbf{m}\) in the hidden layer is given by:  
\[\eta_{m}=\sum_{u=1}^{4}\left(X_{u}W_{um}\right)+b_{m}\qquad m=1,2,\ldots,\,9 \tag{2}\]  
The output from \(m\)th neuron of the hidden layer is given by:  
\[U_{m}=f(\sum_{u=1}^{4}\left(X_{u}W_{um}\right)+b_{m})\quad\,\,m=1,2,\ldots,\,9 \tag{3}\]  
The output of the neuron in the output layer is given by:  
\[O=\sum_{u=1}^{9}\left(U_{u}W_{u}\right)+b \tag{4}\]  
Figure 6: Architectures of presented MLP-LM models (**a**) for gas volume fraction measuring (**b**) for oil volume fraction measuring.  
where \(X\) is the input vector, \(b\) is the bias term, \(W\) is the weighting factor, and f is the activation function of the hidden layer.