matlab程序提示参数不足,运行该程序时老是提示输入参数不足

该博客介绍了一个使用遗传算法调整情感神经网络(ENN)权重以进行风力预测的方法。通过主函数`main`,作者应用了遗传算法进行1000代的优化,种群规模为4000,并使用`fminsearch`作为混合函数。训练和测试集的提取以及适应度函数`myf2`被用来评估网络性能,最终计算RMSE以衡量预测误差。
摘要由CSDN通过智能技术生成

function [net,RMSE,Y] = main(xapp_alli,yapp_alli)

%This main function adjusts the learning weights of an ENN structure(emotinalNets)for a fitting problem. This main function applies genetic algorithm (ga) and uses the adjusted weights in feedforward computing of ENN (simENN)

%该主函数调整ENN结构(emotinalNets)的学习权重以用于拟合问题。 这个主要功能应用遗传算法(ga)并在ENN的前馈计算中使用调整后的权重(simENN)

%Written by Ehsan Lotfi esilotf@gmail.com

%Related Paper: Lotfi, E., Khosravi, A., Akbarzadeh-T, M. R., & Nahavandi, S. (2014, October). Wind power forecasting using emotional neural networks. In Systems, Man and Cybernetics (SMC), 2014 IEEE International Conference on (pp. 311-316). IEEE.

%Authorship: Ehsan Lotfi, esilotf@gmail.com

xapp_all = xapp_alli;

yapp_all= yapp_alli;

[ns,nf] = size(xapp_alli); %ns is number of samples and nf is number of features ,size表示获取矩阵的行数和列数,分别返回ns和nf

[ns,nC] = size(yapp_alli);%ns是目标向量的数量,nC是目标向量?

net = emotionalNets(xapp_all',yapp_all');%创建脑情绪网络

net = initEnn(net,'purelin','purelin');%初始化脑情绪网络

ooTra = zeros(1,1);

ooTes = zeros(1,1);%?

for ci = 1:nC%?

options = gaoptimset(@ga);

options = gaoptimset(options,'Generations',1000,'PopulationSize',4000,'PlotFcns',{@gaplotbestf},'TolFun',0.00,'HybridFcn',@fminsearch); % you can changed these parameters

%种群大小为4000,进化代数为1000

[TraP,TraT,TesP,TesT]=my_get_TraTes(xapp_all,yapp_all); %Training and test sets extraction function: It should be rewritten, according to your application.

%训练集和测试集提取,根据不同应用场景可改写

for i=1:size(TraP,1)

TraP(i,nf+1)=max(TraP(i,1:nf));

end

for i=1:size(TesP,1)

TesP(i,nf+1)=max(TesP(i,1:nf));

end

%%%%%%%%%%%%%%%%%%%%%%%%%% To adjust the learning weights, use GA %%%%%%%%%

f=@(x) sum((myf2(x,TraP,nf)-TraT(:,ci)').^2);%f为适应度函数句柄,myf2的调用?

[x, fval] = ga(f,2*nf+2,options);%遗传算法调用格式,x为遗传算法得到的最优个体,fval为最优个体x对应的适应度函数值,2*nf+2为个体所含变量数目,options为设置好的参数

%%%%%%%%%%%%%%%%%%%%%%%% Set the adjusted learning weights to net and testing%%%%%%%

net = set_weightArray_x(net,x);

Y.train = simEnn(net,TraP');

Y.test = simEnn(net,TesP');

targetTemp = TesT';

outputTemp = Y.test;

RMSE = (sum((targetTemp - outputTemp).^2)/size(targetTemp,2))^0.5;

ooTra(ci,1:size(TraP,1)) = myf2(x,TraP(1:size(TraP,1),1:nf+1),nf);

ooTes(ci,1:1:size(TesP,1)) = myf2(x,TesP(1:size(TesP,1),1:nf+1),nf);

f = figure(2);

plotregression(TraT',Y.train,'Training',...

TesT',Y.test,'Test');

end

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值