# Optimization of a Multi-Type PMSM Based on Pyramid Neural Network
## 3 Prediction Model and HPMSM Optimization
### PNN Prediction Model
#### 3.1.1 PNN Structure  
The network structure of the PNN algorithm includes a visible layer and a hidden layer. The visible layer includes the input layer and the output layer. The basic structure of the PNN is shown in Figure 4.  
The idea behind this encoder-decoder structure was to convert low-dimensional input parameters into very high-dimensional spaces through the encoder to increase the number of degrees of freedom and to facilitate the handling of nonlinear input-output relationships associated with PMSM structures. The information was then submitted to a lower dimensional space using the decoder. This process can actually be thought of as a dimensional evolution between input and output parameters. The PNN adopted in this paper had a multilevel feature and context pyramid network, in which each layer could be represented as the weight \(W\) multiplied by the vector \(x\) composed of neurons, plus the deviation \(b\). We considered a regular grid of \(N\) elements, of which the value of parameter \(i\) said for \(y_{i}\in[0,1]\), and our goal was to optimize the parameter value \(y_{i}\in[0,1]\) in order to obtain an optimal structure. \begin{table}
\begin{tabular}{c c c c c c c} \hline \hline
**Motor Scheme** & \begin{tabular}{c} **Slot Opening** \\ **Width** \\ \end{tabular}  & \begin{tabular}{c} **Slot Width** \\ \end{tabular}  & \begin{tabular}{c} **Tooth Tip** \\ **Height** \\ \end{tabular}  & \begin{tabular}{c} **Slot Depth** \\ \end{tabular}  & \begin{tabular}{c} **PM Width** \\ \end{tabular}  & \ \begin{tabular}{c} **Angle of** \\ **Magnetic Pole** \\ \end{tabular}  & \begin{tabular}{c} **Pole Pair** \\ **Number** \\ \end{tabular}  \\ \hline Case1 & 0.5 & 1.0 & 1.0 & 10.0 & 3.0 & 0 & 1 \\ Case2 & 0.5 & 1.0 & 1.0 & 10.0 & 3.0 & 0 & 1 \\ Case3 & 0.5 & 1.0 & 1.0 & 10.0 & 3.0 & 0 & 1 \\ Case4 & 0.5 & 1.0 & 1.0 & 10.0 & 4. In order to realize the mapping of the PNN model from the parameter space to an objective function, and to effectively model both simple linear mapping and highly nonlinear problems, activation functions were added to each layer of the PNN in this paper:  
\[y_{i}=\sigma(x_{i}+\bar{b}(X)),i\in\{1,2,\ldots,N\} \tag{1}\]  
\[\sum_{i=1}^{N}y_{i}=V_{0} \tag{2}\]  
\[\sigma(x)=\frac{1}{1+e^{-x}} \tag{3}\]  
where \(X=\{x_{1},x_{2},\ldots,x_{N}\}\in R^{N}\), the functions \(\sigma\) makes sure the magnetic potential in [0, 1], and the function \(b(x)\) is set up to ensure that the PNN meets the volume constraint of the optimization problem. This project intended to adopt a deep neural network with layer L + 1, and the number of neurons in each layer (\(u_{0}\), \(u_{1}\),..., \(n_{L}\)) and activation function \(\mu\):\(R\)\(\rightarrow\)\(R\). The activation function \(a^{l}\in R^{n_{l}}\) and the pre-activation function \(\widehat{a}^{l}\in R^{n_{l}}\) were defined recursively on all \(l\) layers, as shown in Equation (4). \[ \begin{array}{l}a^{0}(x)=x\\ \widehat{a}^{l+1}(x)=\frac{\alpha}{\sqrt{n}}W^{l}(x)a^{l}(x)+\beta b^{l}\\ a^{l+1}(x)=\mu(\widehat{a}^{l+1}(x))\end{array}  \tag{4}\]  
In Equation (4), super parameters \(\alpha,\ \beta\in[0,1]\) indicate the contribution of the weight item and bias item, respectively. Parameter \(\theta=\left(\theta_{p}\right)_{p}\) of the weight matrix \(W^{l}\) and the deviation vector \(b^{l}\) is an independent and equally distributed standard normal random variable \(N(0,1)\). The output of the network was \(f_{\theta}(x)=\widehat{a}^{l}(x)\). In order to ensure that the variance of neurons at each layer was equal to 1 when initializing, we set \(\alpha\) and \(\beta\) to satisfy \(\alpha^{2}+\beta^{2}=1\) and \(E_{X\sim N(0,1)}[\mu(X)^{2}]=1\). In this paper, the loss function was defined as  
\[\theta\mapsto C(Y^{NN}(\theta))=C(\sum{(X(\theta))}) \tag{5}\]  
Since the initial value in the optimization method was usually determined, but the neural network was initialized randomly, the initial density field in the deep learning-based optimization method was random and non-constant.