Get the App
SLTechnology News&Howtos  ›  Internet Technology  › 

How to use matlab Neural Network to fit nonlinear function

Shulou Source: shulou.com Published: 2022-06-01 03:23:24 10月25日 Update

This article "matlab neural network fitting nonlinear function how to use" most people do not understand, so the editor summarized the following content, detailed, clear steps, with a certain reference value, I hope you can get something after reading this article, let's take a look at this "matlab neural network fitting nonlinear function how to use" article.

%% construct fitting data

For iTunes 114000

Input (iPermine:) = 10*rand (1penny 2)-5

Output (I) = input (iMagne 1) ^ 2+input (iMagazine 2) ^ 2

End

Output=output'

Save data input output

% clear environment variables

Clc

Clear

Tic

%% 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 4000)

[mmaine n] = sort (k)

% find training data and forecast data

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

Output_train=output (n (1 3900),:)'

Input_test=input (n (3901 4000),:)'

Output_test=output (n (3901 4000),:)'

% 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)

Net.trainParam.epochs=100

Net.trainParam.lr=0.1

Net.trainParam.goal=0.0000004

% 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'}, 'fontsize',12)

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

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

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

Print-dtiff-r600 4-3

% prediction error

Error=BPoutput-output_test

Figure (2)

Plot (error,'-*')

Title ('neural network prediction error')

Figure (3)

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

Title ('neural network prediction error percentage')

Errorsum=sum (abs (error))

Toc

Save data net inputps outputps

The above is about the content of this article "how to use matlab neural network to fit nonlinear function". I believe we all have a certain understanding. I hope the content shared by the editor will be helpful to you. If you want to know more related knowledge, please pay attention to the industry information channel.

Tags: Network data output neural neural network content training function nonlinearity error article sample knowledge article input network structure value variables most of which are Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Linux Shulou Tech Info Apple MariaDB Shulou Information