3. Recursos de casación y análisis
3.7 Recursos de casación No 497-2010
Initialize all weights to small random numbers. Until satisfied, Do
For each training example, Do
1. Input the training example to the network and compute the network outputs
2. For each output unit 𝑗 𝛿𝑗← 𝑦𝑗(1 − 𝑦𝑗)(𝑑𝑗− 𝑦𝑗) 3. For each hidden unit ℎ
𝛿ℎ← 𝑦ℎ(1 − 𝑦ℎ) ∑ 𝑤𝑗ℎ𝛿𝑗 𝑗∈𝑜𝑢𝑡𝑝𝑢𝑡𝑠 4. Update each network weight 𝑤𝑖,𝑗
𝑤𝑗𝑖 ← 𝑤𝑗𝑖+ ∆𝑤𝑗𝑖 where ∆𝑤𝑗𝑖 = 𝜂𝛿𝑗𝑥𝑖 Note: 𝑤𝑗𝑖 is the weight from 𝑖 to 𝑗 (i.e., 𝑤𝑗←𝑖)
Algorithm 1 was implemented using python package scikit-learn (MLPClassifier, scikit- learn 2017). The results for input sample of 170 feature dimensions are shown in Fig.
27
Fig. 12— Neural network algorithm accuracy
In Fig. 12, we can see that MLP can achieve 98% average training accuracy in the four- fold cross validation techniques. The average validation accuracy is 0.955. The test accuracy of 0.97 was evaluated as the overall criterion for the MLP algorithm. With the aid of NNet algorithm and the architecture parameter settings mentioned above, we have 97% confidence to correctly classify a well given the sample with a production history of 170 months. In addition, we also tested the cases of 24, 48 and 96 months of
28
Fig. 13— Different input neuron number accuracy comparison
Fig. 13 shows that fewer input neurons in the neural network architecture would induce lower accuracies. When the well has only two years’ production history (i.e., 24
months), the accuracy will be less than 0.5; when the production history is 170 months, the accuracy is more than 0.95. As the number of input neurons increases, the network architecture has more prior information, and thus it will be more accurate in predicting the EUR ranges.
However, the main limitation of MLP is that it cannot guarantee the globally optimal solution. It may “stick” in a locally optimal solution and then stop updating the weights for neuron connections. A good option to mitigate this is to have a random start position (e.g., randomly generate the weights for MLP each time) as we did initially in Algorithm 1 to initialize all weights to small random numbers. At the same time, we also added a momentum parameter, as we did when implementing Algorithm 1. This is another option that can help us reach the global optimum.
29
The performance of MLP can also be limited by the number of hidden layer neurons. Too many hidden neurons would cause overfitting problems, and too few may lead to underfitting. This dilemma is resolved by choosing the most suitable value between the number of neurons in the input layer and that in the output. As mentioned earlier, each well’s production history was extrapolated to 170 months for the sake of uniform input dimensionality. Thus, the input layer has 170 neurons, while the output layer has only four neurons. Thus the potential number of hidden layer neurons candidate can be then chosen from the interval [4, 170]. Fig. 14 gives the relationship between the number of hidden neurons and accuracy for validation sets in the cross validation process (i.e., the average four-fold cross validation test accuracy).
Fig. 14 shows that, the accuracy varies rapidly as the number of hidden neurons changes. The highest average validation accuracy was 0.97 when the number of hidden neurons was 167. Although the accuracy oscillates, we observe a generally increasing accuracy as the number of hidden neurons increases. This might be due to the fact that, the more hidden neurons in MLP, the more non-linear relationships it can understand. As we add more than 167 hidden neurons into the neural network architecture, in theory, the model will become more complex, which will further decrease the accuracies of the validation dataset. This is what we commonly call the overfitting problem.
30
Fig. 14— Hidden neuron number determination through cross validation
Since the weights are initialized with random small numbers, each time we start a new training process, the number of hidden neurons that lead to the highest accuracy may vary. The results shown in Fig. 14 reflect only the determination that corresponds to the weights initialization in which 167 hidden neurons can achieve the best performance. Readers may obtain different results as they implement their own network architectures.
2.8.2 SVM
SVM is a classical machine learning algorithm. Its primary objective is to find a plane that can separate the samples with largest margin, i.e., maximize the margin. The margin is defined as the distance of closest samples from the separating hyperplane.
To simplify explanations of the SVM algorithm, assume that we are dealing with a binary classification problem. The possible label involved can only be either 1 or -1. Sometimes the label will be called simply either plus or minus. The multiple class
31
classification can be implemented simply by simply generating multiple SVM classifiers.
Suppose we have several samples that are labelled with minus and plus signs which represent two classes. We separate the samples with a plane that is represented by the dotted black line in Fig. 15(a). The orientation of this plane can be different as long as the plane can separate the two kinds of samples into two different classes. The distance from the plane to the blue line and to the orange line is the same, and the points that are exactly located on the blue lines and orange lines are called support vectors. This is also the source of the classifier name “Support Vector Machine.” The objective of the algorithm is to find such support vectors to maximize the margin (i.e., to minimize the generalization error).
(a) (b)
32
In Fig. 15(b), we add a vector 𝑤⃗⃗ perpendicular to the plane (dotted black line). This vector can be a unit vector. In the coordinate system as shown in Fig. 15(b), the dotted black line can also be represented by a vector 𝑤⃗⃗ . When we need to classify the new sample 𝑢⃗ , we need to compute the length in the direction of 𝑤⃗⃗ , which is 𝑤⃗⃗ ∙ 𝑢⃗ . If the length exceeds a certain constant c, then this new sample will be classified as a plus sign, otherwise, it would be defined as minus. To formally describe this situation, if the new point satisfies Eq. 5,
𝑤⃗⃗ 𝑇𝑢⃗ + 𝑏 > 0………..…(5)
then the point would be labelled a plus. Otherwise, the point will be a minus. Eq. 5 is also called the decision rule. We find a suitable vector 𝑤⃗⃗ and 𝑏 value to maximize the margin. To achieve this, we define
𝑦𝑖(𝑥⃗⃗⃗ 𝑖𝑇𝑤⃗⃗ + 𝑏) − 1 = 0……….. (6)
for each sample 𝑖 between the blue line and the orange line. From Eq. 6, we can derive the width of the margin as in Eq. 7.
𝑤𝑖𝑑𝑡ℎ = (𝑥⃗⃗⃗⃗ − 𝑥+ ⃗⃗⃗⃗ ) ∙− 𝑤⃗⃗ ‖𝑤⃗⃗ ‖=
2
33
Given Eq. 7, to find vector 𝑤⃗⃗ and the 𝑏 value that maximize the margin, we can simply define the objective function as
𝐿 = 1 2‖𝑤⃗⃗ ‖
2……….(8)
With the constraints from Eq. 6, we need to introduce Lagrange multipliers to solve this convex programming problem. In this way, the objective function becomes
𝐿 = 1 2‖𝑤⃗⃗ ‖ 2− ∑ 𝛼 𝑖 𝑖 [𝑦𝑖(𝑥⃗⃗⃗ 𝑖 𝑇 𝑤⃗⃗ + 𝑏) − 1]………...(9)
Eq. 9 is also called the Lagrange primal function, 𝛼𝑖 ≥ 0 ∀𝑖, and this becomes a dual problem. We set the partial derivative to be 0, and obtain
𝑤⃗⃗ = ∑ 𝛼𝑖 𝑖𝑥⃗⃗⃗ 𝑦𝑖 𝑖 ………(10)
∑ 𝛼𝑖 𝑖𝑦𝑖 = 0……….(11)
By substituting Eqs. 10 and 11 into Eq. 9, we obtain the Lagrangian dual function
𝐿 = ∑ 𝛼𝑖 𝑖 − 1 2∑ ∑ 𝛼𝑖𝛼𝑗𝑦𝑖𝑦𝑗𝑥⃗⃗⃗ 𝑖 𝑇 ∙ 𝑥⃗⃗⃗ ………(12) 𝑗 subject to 𝛼𝑖 ≥ 0 ∀𝑖, ∑ 𝛼𝑖 𝑖𝑦𝑖 = 0
34
Eq. 12 indicates that the Lagrangian function depends solely on the pair of sample points when Lagrange multipliers are fixed. This gives us the general algorithm for a SVM classifier:
Algorithm 2 Support Vector Machine