A list,

1 BP neural network prediction principle introductionBP neural network is a multi-layer feed-forward neural network, commonly used as a three-layer structure of input layer – single hidden layer – output layer, as shown in the figure below.The main idea of BP neural network training: the input signal characteristic data is first mapped to the hidden layer (activation function implementation), and then mapped to the output layer (default linear transfer function), to get the expected output value. The expected output value is compared with the actual measured value, the error function J is calculated, and then the error is back propagated, and the weight and threshold of BP network are adjusted by the algorithm such as gradient descent. This process is repeated until the set goal error or the maximum number of iterations is met and the training is stopped.

Use the following example to understand what each layer does.

1) Input layer: it is equivalent to human facial features, which obtain external information and correspond to the process of neural network model input port receiving input data. 2) Hidden Layer: corresponding to the human brain, the brain analyzes and thinks about the data transmitted by the five senses. The hiddenLayer of the neural network maps the data X from the input Layer, which can be simply understood as a formula hiddenLayer_output=F(w*x+b). Where, w and b are weight and threshold parameters, F() is a mapping rule, also known as activation function, and hiddenLayer_output is the output value of the hidden layer to the transmitted data map. In other words, the hidden layer maps the input influence factor data X and generates the mapping value. 3) Output layer: it can correspond to human limbs. After thinking about the information from the facial features (hidden layer mapping), the brain controls the limbs to perform actions (respond to the outside). Similarly, the output layer of the BP neural network maps hiddenLayer_output again, outputLayer_output=w *hiddenLayer_output+b. Where w and B are weight and threshold parameters, and outputLayer_output is the output value (also called simulation value and predicted value) of the output layer of the neural network (understood as the external execution of the human brain, such as the baby tapping the table). 4) Gradient descent algorithm: Calculate the deviation between outputLayer_output and the y value passed in by the neural network model, and use the algorithm to adjust parameters such as weight and threshold accordingly. And what happens is, you can think of it as the baby slaps the table, misses it, adjusts its body according to how far it misses it, so that the arm that moves again gets closer and closer to the table and hits it.

Function of BP neural network

“If you can use all the stars, you can know all the chess positions.” Go embodies the ways of nature. When AlphaGo defeated a human go champion, it used algorithms to find the ways of go and realized a man-machine battle. BP neural network training results: get the law between the multidimensional data X and Y, namely to achieve the mapping from X to approximate y. Whether the model trained by BP is reliable or not depends on whether more accurate predictive values can be output for other untrained data when input into BP. Therefore, after the training of BP neural network, it is also necessary to add index factor X1 to the trained BP network to get the corresponding BP output value (predicted value), predicT1, and calculate indicators such as Mse, Mape and R square by plotting, etc., to compare the closeness of PREDICT1 and Y1. You can tell if the model is accurate. This is the test process of the BP model, that is, the prediction process.

In summary, BP neural network realizes: a). A model is trained according to the training set data, b). The reliability and accuracy of the model are predicted by the test set (different from the training sample data), and the accuracy of the prediction is verified by comparing with the actual value. C). Only input is given and predicted value is obtained (it can be understood that measured value is lost in the data of test set, which is essentially the same. Input is put into BP and output is obtained). Since there is no output in this case, pure prediction, unable to test the accuracy of qualified, writing a paper without much significance and need not realize the steps of this case.

2 whale optimization algorithm to optimize the BP neural network prediction steps and flow chart of design for the BP neural network in the process of training the initial weights and threshold value generated by the random number, the network structure has influence to the training, the whale optimization algorithm to optimize the BP neural network’s initial weights and thresholds, and relatively stable WOA – BP neural network model.

2.1 Steps of WOA optimization of BP neural network:

Step1: initialize the weights and thresholds of the BP neural network Step2: calculate the decision variable length of the whale optimization algorithm WOA, and select the mean square error as the objective function of optimization. Step3: Set the algorithm stop criteria, and use whale optimization algorithm to optimize the weight and threshold parameters of the neural network. Step4: Assign the optimized weight and threshold parameters to the BP neural network. Step5: the optimized BP neural network training and testing, and the optimized BP neural network error analysis and precision comparison.

2.2 Flowchart design of WOA optimized BP neural network

3 parameter setting of WOA-BP prediction algorithm3.1 Data description Using building energy data set, establish BP neural network regression prediction and whale optimization algorithm WOA optimization BP neural network regression prediction algorithm.

3.2 Data Format3.3 Selection of optimization variables and Fitness function Design The weights and threshold parameters of BP neural network were optimized, and the overall mean square error of the training set and the test set was taken as the fitness function. The smaller the fitness function value is, the more accurate the training is, and the prediction accuracy of the considering model is better.Where, TraingingSet and TestingSet are samples of training set and test set respectively.

3.4 Algorithm Parameter Settings

A) Parameter setting of BP neural network

net=newff(inputn,outputn,hiddennum_best,{'tansig'.'purelin'},'trainlm'.'learngdm'); % Model building % Network parameter configuration net.trainparam. epochs=1000; % Training times net.trainparam. lr=0.01; % Learning rate net.trainparam. goal=0.00001; % Minimum error of training target net.trainparam.show =25; % Display frequency net.trainparam.mc =0.01; % Momentum factor net.trainparam.min_grad =1e-6; % Minimum performance gradient net.trainparam.max_FAIL =6; % Maximum number of failuresCopy the code

B) WOA parameter setting

% Initializes the WOA parameter popsize=30; % Initial population size maxgen=50; Dim =inputnum*hiddennum_best+hiddennum_best+hiddennum_best*outputnum+outputnum; % number of arguments lb=repmat(- 3.1,dim); % independent variable limit ub=repmat(3.1,dim); % Upper limit of independent variablesCopy the code

3.5 Use THE BP neural network optimized by WOA for prediction, and make error analysis and comparison with the prediction results of BP neural network

Ii. Source code

** a).mian. M is the main program, including the realization of BP prediction and whale optimization algorithm WOA optimization BP prediction two parts. Change your own data set in the external data EXCEL, and set the corresponding data range in the MATLAB program to run the results. The code is clearly annotated in Chinese. B). The data set is in EXCEL format. When changing data, set the corresponding reading range of EXCEL data in THE MATLAB program. C). Empirical formula is adopted to determine the number of nodes in hidden layer by using cycles, and the process is provided for the number of neuron nodes in input layer, hidden layer and output layer. ** Data introduction: The code is implemented using the data set samples of chemical sensors commonly used in deep learning. The data format is EXCEL. Direct set of data running. There is no limit to the number of input indicators, and the output is single. A). Replace your own data set in the external data EXCEL file of the program; C % read data= xlsRead (' Sheet1',' Sheet1','A1:I498'); Input =data(:,1:end-1); Output =data(:,end); The last column of %data is the output index valueCopy the code

Third, the operation result

Error analysis and comparison of WOA optimized BP neural network prediction

Fourth, note

Version: 2014 a