赞
踩
load data input output
%划分训练集
random_num = rand(1,2000);
[value,index] = sort(random_num);
x_train = input(index(1:1800),:)';
y_train = output(index(1:1800));
x_test = input(index(1801:2000),:)';
y_test = output(index(1801:2000));
%设置BP网络节点数
inputnum = 2;
hiddennum = 5;
outputnum = 1;
%数据归一化
[input_train,inputps] = mapminmax(x_train);
[output_train,outputps] = mapminmax(y_train);
%确定待优化参数的数目
length = inputnum*hiddennum+hiddennum+hiddennum*outputnum+outputnum;
%建立BPNN
net = newff(input_train,output_train,hiddennum);
%设置FOA参数(种群规模sizepop 迭代次数k 种群初始位置x_asis+y_asis)
sizepop = 10;
k = 100;
x_asis = rand(1,length);
y_asis =
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。