当前位置: 首页 > 程序语言 >matlab神经网络函数逼近训练求助

matlab神经网络函数逼近训练求助

作者 18726871687
来源: 小木虫 250 5 举报帖子
+关注

首先,确定一个逼近对象如:f(x)=exp(-1.7*x)*cos(10x).^3,因为目标函数是非线性变换函数(S型函数),所以样本数据与测试数据在【-1,1】之间选取效果较好。
如:样本数据选取:x=-0.8:0.01:0.98;
在MATLAB工作窗口中输入如下命令语句:
clear all;
close all;
x=-0.8:0.01:0.98;
m=-1.7*x;
m=exp(m);
m=m.*sin(10*x).^3;
figure(1);
plot(x,m,'bo');
ylabel('输出样本集m=f(x)','color','r');
xlabel('输入样本集','color','r');
显示的图形如下:
net=newff(minmax(x), 返回小木虫查看更多

今日热帖
  • 精华评论
  • pdl9527

    照着例子改了改,全部数据用来作为train,没有验证和检测,当然可以自己修改比例。

    CODE:
    function question_39
    clear;clc;
    close all;
    inputs=-0.8:0.01:0.98;
    targets=exp(-1.7*inputs).*sin(10*inputs).^3;

    % Create a Fitting Network
    hiddenLayerSize = 15;
    net = fitnet(hiddenLayerSize);
    % Train the Network
    [net,tr] = train(net,inputs,targets);

    % Test the Network
    outputs = net(inputs);
    errors = gsubtract(outputs,targets);
    performance = perform(net,targets,outputs)
    plotfit(net,inputs,targets)


  • pdl9527

    我得到的结果也是无限逼近,你多运行几遍试试,不行的话改成 hiddenLayerSize = 20;

  • 18726871687

    好的,已收到,问题已解决,非常感谢

猜你喜欢