采用神经网络为什么不能预测呢?
%---------------------------------------------------------%选取1-400个数据
x=1:1:400
y=A(1:1:400)
%选取1-400,间隔为2的200个数据作为样本数据
x_train1=1:2:400
y_train1=A(1:2:400)
%选取2-400,间隔为2的200个数据作为测试数据
x_test1=2:2:400
y_test1=A(2:2:400)
%归一化
= premnmx(x_train1',y_train1);
x_test1 = tramnmx(x_test1,minp,maxp);
y_test2 = tramnmx(y_test1,mint,maxt);
% 设置网络参数
net = newff(minmax(x_train1),,{'tansig' 'purelin'},'trainlm');
net.trainParam.show = 20; % 训练显示间隔
net.trainParam.lr = 0.3; % 学习步长 - traingd,traingdm
net.trainParam.mc = 0.95; % 动量项系数 - traingdm,traingdx
net.trainParam.mem_reduc = 1; % 分块计算Hessian矩阵(仅对Levenberg-Marquardt算法有效)
net.trainParam.epochs = 1000; % 最大训练次数
net.trainParam.goal = 1e-8; % 最小均方误差
net.trainParam.min_grad = 1e-20; % 最小梯度
net.trainParam.time = inf; % 最大训练时间
%---------------------------------------------------
% 训练
net = train(net,x_train2',y_train2');
%---------------------------------------------------
% 测试
y_test3 = sim(net,x_test1)
%---------------------------------------------------
% 反归一
y_test4 = postmnmx(y_test3,mint,maxt);
% 结果作图
plot(x_test1,y_test1,'r-',x_test1,y_test4,'b*')
页:
[1]