## 3 Proposed ML-Based Rotor Observer
### Modified ENN  
In this study, the ENN was used as the core of the ML-based observer. The ENN is a network with memory neurons and a context layer [24]. The context-layer neurons store data generated by the hidden-layer neurons during each cycle; the stored data are then  
Figure 3: Machine learning (ML) flowchart.  
used as inputs for the hidden-layer neurons in the next cycle. The context and hidden layers have the same number of neurons.  
Figure 4 shows how values from the output layer are fed back to the input layer to improve ML performance. The number of input neurons is increased to handle this feedback. The initial four neurons (\(v_{\alpha},v_{\beta}\)\(I_{a}\) and \(I_{\beta}\)) were increased to six neurons due to the additional feedback of \(sin\)\(\theta\) and \(cos\)\(\theta\).  
During the training process, the updating weight in this algorithm is the difference between the output neuron value and target output value. This process is the same as that in the BPNN. However, because the modified ENN has more input neurons and has a context layer, the required training time and execution time are longer than for the BPNN. Nonetheless, with the addition of this input, the observer's performance becomes much better because it can overcome the problem of speed transition.  
The modified ENN algorithm depicted in Figure 4 was developed with the following steps:  
* Step 1. The number of neurons in each layer is initially established. The input layer has six neurons (\(k+n\)), the output layer (\(n\)) has two neurons, and both the hidden layer and the context layer have seven neurons (\(m\)). The learning-rate value (\(lr\)) is 0.001.
* Step 2. The weights for each input layer (\(wil\)), context layer (\(wcl\)), and hidden layer (\(whl\)); the bias value of the hidden layer (\(bhl\)) and output layer (\(bol\)); and the memory coefficients of the context layer (\(mclo\) and \(mcl\)) are randomly generated.
* Step 3. In the first iteration of the training process, the context-layer neuron values must be initiated (\(z^{\prime}\)).
* Step 4. Each neuron from the input layer (\(x\) and \(y^{\prime}\)) and context layer (\(z^{\prime}\)) is distributed to the input of each neuron in the hidden layer. Finally, these values are summed with an appropriate bias value (\(vb\)). The summation results are then input into the activation function to obtain the output value of each hidden-layer neuron (\(z\)).  
Figure 4: Scheme of the proposed modified ENN.  
Step 5. The output values of the hidden-layer neurons (\(z\)) are fed back to the context layer and become \(z^{\prime}\) for the next iteration. Moreover, \(z\) is weighted (\(w\)) and is distributed to the next layer for each neuron in the output layer (\(y\)). All inputs from each hidden-layer neuron (\(z\)) are summed with an appropriate bias (\(wb\)). The summation results are then used on the activation function to obtain the value of each output-layer neuron (\(y\)).
* Step 6. The activation function calculation result for the output-layer neurons is the output of the network. This output is fed back to the input layer as \(y^{\prime}\) and is compared with the target output to obtain an error value.
* Step 7. The weights and biases of the network are updated on the basis of the error values and learning rate.
* Step 8. Steps 4-7 are repeated until the desired number of training cycles (maximum epoch) is reached or the convergence condition is met.  
Next, the generated model had to be tested using actual learning data. Data were obtained by running a sensored PMSM-FOC simulation on MATLAB Simulink.