Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to increase the hidden layer and reduce the error of matlab

2025-03-29 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >

Share

Shulou(Shulou.com)06/01 Report--

This article mainly introduces "matlab how to increase hidden layer to reduce error". In daily operation, I believe many people have doubts about how to increase hidden layer in matlab to reduce error. Xiaobian consulted all kinds of data and sorted out simple and easy-to-use operation methods. I hope it will be helpful for you to answer the doubt of "how matlab increases hidden layer to reduce error". Next, please follow the editor to study!

BP neural network consists of input layer, hidden layer and output layer. According to the number of layers, hidden layer can be divided into single hidden layer and multi-hidden layer. The multi-hidden layer is composed of multiple single hidden layers. compared with the single hidden layer, the multi-hidden layer has stronger generalization ability and higher prediction accuracy, but the training time is longer. The selection of the number of hidden layers should be comprehensively considered in terms of network accuracy and training time. For simple mapping relations, when the network accuracy meets the requirements, a single hidden layer can be selected to speed up the speed; for complex mapping relations, multiple hidden layers can be selected to improve the prediction accuracy of the network.

%% double hidden layer BP neural network

% clear environment variables

Clc

Clear

%% training data prediction data extraction and normalization

Download input and output data

Load data input output

% randomly sorted from 1 to 2000

K=rand (1JI 2000)

[mmaine n] = sort (k)

% find training data and forecast data

Input_train=input (n (1 1900),:)'

Output_train=output (n (1 1900))

Input_test=input (n (1901 2000),:)'

Output_test=output (n (1901 2000))

% selected sample input and output data normalization

[inputn,inputps] = mapminmax (input_train)

[outputn,outputps] = mapminmax (output_train)

%% BP network training

Initialize network structure

Net=newff (inputn,outputn, [5 5])

Net.trainParam.epochs=100

Net.trainParam.lr=0.1

Net.trainParam.goal=0.00004

% Network training

Net=train (net,inputn,outputn)

% BP Network Forecast

% prediction data normalization

Inputn_test=mapminmax ('apply',input_test,inputps)

% network forecast output

An=sim (net,inputn_test)

% network output is de-normalized

BPoutput=mapminmax ('reverse',an,outputps)

%% result analysis

Figure (1)

Plot (BPoutput,':og')

Hold on

Plot (output_test,'-*')

Legend ('predicted output', 'expected output')

Title ('BP network prediction output', 'fontsize',12)

Ylabel ('function output', 'fontsize',12)

Xlabel ('sample', 'fontsize',12)

% prediction error

Error=BPoutput-output_test

Figure (2)

Plot (error,'-*')

Title ('BP network prediction error', 'fontsize',12)

Ylabel ('error', 'fontsize',12)

Xlabel ('sample', 'fontsize',12)

Figure (3)

Plot ((output_test-BPoutput). / BPoutput,'-*')

Title ('neural network prediction error percentage')

Errorsum=sum (abs (error))

At this point, the study of "how to increase the hidden layer of matlab to reduce errors" is over. I hope to be able to solve your doubts. The collocation of theory and practice can better help you learn, go and try it! If you want to continue to learn more related knowledge, please continue to follow the website, the editor will continue to work hard to bring you more practical articles!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Internet Technology

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report