matlab中newrb函数用途,神经网络matlab函数使用

%实现的分类结果真的不好,才0.3+,这里只是简单的说明怎么使用函数,至于实现达不到效果的问题,后续会研究

clear all

clc

%% 读入数据

xlsfile='train.txt';

x = load(xlsfile);

[m,n] = size(x);

traind = x(:,1:n-1);

label = x(:,n);

testl = load('result.txt');

testd = load('test.txt');

%% 数据处理

%标准化处理

% [traind,MU,SIGMA] = zscore(traind);

% [testd,MU,SIGMA] = zscore(testd);

%归一化处理

[traind,G] = mapminmax(traind);

[testd,G] = mapminmax(testd);

%%

P = traind';

T = label';

test_p = testd';

test_pl = testl';

%% 使用newff函数

ff=newff(P,T,30); % 建立一个BP网络,包含一个20个节点的隐含层

ff.trainParam.epochs = 50;

ff = train(ff,P,T); % 训练

Y1= sim(ff,test_p); % 仿真

Y1_init = Y1;

% 取整

Y1(Y1<0.5)=0;

Y1(Y1>=0.5)=1;

rate1 = sum(Y1 == test_pl)/length(Y1);

%% 使用newcf函数

% cf=newcf(P,T,20); % 用newcf建立前向网络

% cf.trainParam.epochs = 50;

% cf = train(cf,P,T); % 训练

% Y2 = sim(cf,test_p);% 仿真

%

% Y2_init = Y2;

%

% % 取整

% Y2(Y2<0.5)=0;

% Y2(Y2>=0.5)=1;

% rate2 = sum(Y2 == test_pl)/length(Y2);

%% 使用newfftd函数

% net = newfftd(P,T,[0 1],5);% 创建隐含层包含5个神经元的BP网络

% net.trainParam.epochs = 100;

%

% net.trainParam.lr=0.1;

% net.trainParam.goal=0.0000004;

%

% net = train(net,P,T);

% Y3 = net(test_p);

%

% Y3_init = Y3;

%

% % 取整

% Y3(Y3<0.5)=0;

% Y3(Y3>=0.5)=1;

% rate3= sum(Y3 == test_pl)/length(Y3);

%% 使用newrb或者newgrnn函数

%net=newrb(P,T,0,0.6);

% net = newgrnn(P,T);

% Y4=sim(net,test_p);

%

% Y4_init = Y4;

% % 取整

% Y4(Y4<0.5)=0;

% Y4(Y4>=0.5)=1;

% rate4= sum(Y4 == test_pl)/length(Y4);

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值