标准BP神经网络算法程序Word文档下载推荐.docx
《标准BP神经网络算法程序Word文档下载推荐.docx》由会员分享,可在线阅读,更多相关《标准BP神经网络算法程序Word文档下载推荐.docx(18页珍藏版)》请在冰豆网上搜索。
![标准BP神经网络算法程序Word文档下载推荐.docx](https://file1.bdocx.com/fileroot1/2023-1/14/bc41170a-168f-4975-8508-ef87f1df5df0/bc41170a-168f-4975-8508-ef87f1df5df01.gif)
-0.51781-0.3674-0.20883-0.0533160.0900180.217280.328750.426390.512260.588080.655120.71430.766290.811550.850420.883110.909790.930560.94550.954680.958170.956060.948480.935610.917660.894960.867890.836910.80260.765610.726660.686510.645970.60580.566690.529240.493920.461020.430710.403020.377870.355110.334530.315910.299030.283660.26960.256680.244740.233650.223290.213560.20440.195730.187510.179680.172210.165080.158260.151720.145460.139440.133670.128130.12280.117690.112780.108060.103520.0991680.0949870.0909740.0871220.0834250.0798790.0764780.0732170.0700910.0670960.0642270.0614790.0588480.0563290.053920.0516150.049410.0473030.0452890.0433640.0415250.039770.0380930.0364930.0349660.0335090.0335090.032120.0307950.0295320.0283280.027180.0260870.0250460.0240550.023110.0222120.0213560.00507480.00507480.00507480.00507480.00507480.00507480.00507480.00507480.00507480.00507480.00507480.00507480.00507480.00507480.00507480.00507480.00507480.00507480.00507480.00507480.00507480.00507480.00507480.00507480.00507480.00507480.00507480.00507480.00507480.0050748;
-2.9024-3.152-3.192-3.0144-2.7059-2.3718-2.0688-1.8102-1.5912-1.4028-1.2371-1.0879-0.95071-0.82207-0.69957-0.58143-0.46641-0.35366-0.24269-0.13334-0.0257320.0797130.18230.281050.374740.46190.540880.609930.667280.711330.740820.755020.753960.738480.710310.671840.625970.575670.523760.472610.424010.379150.338710.30290.271640.244620.221430.201610.184680.17020.157770.147050.137730.129560.122340.115880.110060.104760.0998910.0953820.0911760.0872270.0834990.0799650.0766010.0733890.0703160.0673680.0645370.0618160.0591970.0566750.0542470.0519070.0496530.0474810.0453890.0433740.0414340.0395670.037770.0360420.0343810.0327840.031250.0297780.0283640.0270090.0257090.0244630.0232690.0221270.0210330.0199870.0189870.0189870.0180320.0171190.0162470.0154150.0146220.0138650.0131430.0124560.0118020.0111790.0105861.0512e-0101.0026e-0109.5616e-0119.1193e-0118.6971e-0118.2946e-0117.9107e-0117.5441e-0117.1954e-0116.862e-0116.5437e-0116.2412e-0115.9522e-0115.6766e-0115.414e-0115.163e-0114.9239e-0114.6964e-0114.4791e-0114.2712e-0114.0734e-0113.8847e-0113.705e-0113.5335e-0113.3705e-0113.2149e-0113.0654e-0112.9233e-0112.7884e-0112.6593e-011;
5.72116.25146.35646.02125.424.76424.16773.65753.22412.84992.51922.21981.94251.68081.431.18660.948360.713710.48190.252820.026935-0.19468-0.41042-0.61812-0.81514-0.9984-1.1645-1.3097-1.4307-1.524-1.5872-1.619-1.6193-1.59-1.5346-1.458-1.366-1.2647-1.1598-1.056-0.95706-0.86541-0.7824-0.70853-0.64366-0.58721-0.53837-0.49624-0.4599-0.42846-0.40115-0.37727-0.35623-0.33754-0.32077-0.30558-0.29171-0.27893-0.26707-0.25596-0.24552-0.23564-0.22625-0.21729-0.20872-0.20051-0.19261-0.18502-0.1777-0.17065-0.16385-0.15728-0.15094-0.14482-0.13891-0.13321-0.1277-0.12239-0.11726-0.11232-0.10755-0.10296-0.098531-0.094267-0.090162-0.086211-0.08241-0.078755-0.075241-0.071865-0.068623-0.065509-0.062521-0.059655-0.056905-0.056905-0.05427-0.051745-0.049326-0.047009-0.044792-0.04267-0.040641-0.0387-0.036845-0.035072-0.033378-5.5315e-010-5.2754e-010-5.0313e-010-4.7985e-010-4.5763e-010-4.3646e-010-4.1626e-010-3.9698e-010-3.7862e-010-3.6109e-010-3.4436e-010-3.2843e-010-3.1323e-010-2.9873e-010-2.8491e-010-2.7171e-010-2.5913e-010-2.4715e-010-2.3571e-010-2.2479e-010-2.1439e-010-2.0446e-010-1.95e-010-1.8597e-010-1.7738e-010-1.6918e-010-1.6133e-010-1.5386e-010-1.4675e-010-1.3996e-010];
t=[5.74061.5872-1.5819-3.3978-4.1771-4.5036-4.75-5.0459-5.4062-5.8125-6.2426-6.678-7.1043-7.5095-7.8834-8.2164-8.4991-8.7221-8.8761-8.9522-8.9427-8.8412-8.6438-8.3497-7.9621-7.4882-6.9402-6.3349-5.693-5.0382-4.3953-3.7881-3.2373-2.7579-2.3583-2.0396-1.7966-1.6195-1.4958-1.4128-1.3584-1.3226-1.2977-1.278-1.2598-1.2406-1.2194-1.1955-1.169-1.1401-1.1092-1.0767-1.0431-1.0088-0.9741-0.93938-0.90487-0.87078-0.83727-0.80447-0.77246-0.74132-0.7111-0.68183-0.65351-0.62617-0.5998-0.57439-0.54992-0.52639-0.50378-0.48205-0.4612-0.44119-0.42201-0.40362-0.38601-0.36914-0.353-0.33755-0.32278-0.30866-0.29516-0.28227-0.26996-0.25821-0.24699-0.23629-0.22608-0.21635-0.20707-0.19824-0.18982-0.1818-0.17416-0.17416-0.16689-0.15998-0.15339-0.14713-0.14118-0.13552-0.13014-0.12502-0.12016-0.11554-0.11115-0.030145-0.030145-0.030145-0.030145-0.030145-0.030145-0.030145-0.030145-0.030145-0.030145-0.030145-0.030145-0.030145-0.030145-0.030145-0.030145-0.030145-0.030145-0.030145-0.030145-0.030145-0.030145-0.030145-0.030145-0.030145-0.030145-0.030145-0.030145-0.030145-0.030145];
s1=4;
s2=4;
s3=1;
%输入层,隐层以及输出层各层的神经元数
[R,Q]=size(p);
[S,Q]=size(t);
w1=[-13.2406-8.88831.2111-2.1919;
0.49540.207290.214020.10116;
-0.34757-0.13691-0.15081-0.07379;
-0.39188-0.15828-0.1692-0.079797];
%输入层到隐层的权值
b1=ones(4,137);
%给输入层到隐层的阈值赋全一
[w2,b2]=rands(s3,s2);
b2=ones(1,137);
%给隐层到输出层的阈值赋全一
n1=w1*p+b1;
a1=tansig(n1);
%隐层的输出
n2=w2*a1+b2;
a2=purelin(n2);
%输出层的输出
net=newff(minmax(p),[4,1],{'
tansig'
'
purelin'
},'
traingd'
);
%创建一个新的前向神经网络
%设置训练参数
net.trainParam.lr=0.15;
net.trainParam.show=25;
net.trainParam.epochs=17000;
net.trainParam.goal=0.01;
%对BP网络进行仿真
Y=sim(net,p);
%调用TRAINGD算法训练BP网络
net=train(net,p,t);
%计算仿真误差
E=t-Y;
MSE=mse(E)
plot(T,t,'
r+'
gridon;
holdon
plot(T,Y);
holdoff;
pause
clc
p1=p(1,:
p2=p(2,:
p3=p(3,:
p4=p(4,:
plot(T,p1);
clc
plot(T,p2);
pause
plot(T,p3);
plot(T,p4);
plot(T,E);
2.动量BP算法程序:
%输入样本和目标输出
-2.9024-3.152-3.192-3.0144-2.7059-2.3718-2.0688-1.8102-1.5912-1.