基于PSO优化的CNN多输入分类预测(Matlab)粒子群算法优化卷积神经网络分类预测

本文详细介绍了一种在Matlab中结合PSO粒子群算法和CNN的代码,用于多输入数据的分类预测。代码具有详细注释、数据归一化和优化功能,适合初学者学习。同时包含了实际运行效果和数据处理的部分代码。
摘要由CSDN通过智能技术生成

目录

一、程序及算法内容介绍:

基本内容:

亮点与优势:

 二、实际运行效果:

 三、部分代码:

四、完整代码+数据下载:


一、程序及算法内容介绍:

基本内容:

  • 本代码基于Matlab平台编译,将PSO(粒子群算法)与CNN(卷积神经网络)结合,进行多输入数据分类预测

  • 输入训练的数据包含12个特征1个响应值,即通过12个输入值预测1个输出值(多变量分类预测,输入输出个数可自行指定)

  • 归一化训练数据,提升网络泛化性

  • 通过PSO算法优化CNN网络的学习率、卷积核个数参数,记录下最优的网络参数

  • 训练CNN网络进行回归预测,实现更加精准的预测

  • 迭代计算过程中,自动显示优化进度条,实时查看程序运行进展情况

  • 自动输出多种多样的的误差评价指标,自动输出大量实验效果图片

亮点与优势:

  • 注释详细,几乎每一关键行都有注释说明,适合小白起步学习

  • 直接运行Main函数即可看到所有结果,使用便捷

  • 编程习惯良好,程序主体标准化,逻辑清晰,方便阅读代码

  • 所有数据均采用Excel格式输入,替换数据方便,适合懒人选手

  • 出图详细、丰富、美观,可直观查看运行效果

  • 附带详细的说明文档(下图),其内容包括:算法原理+使用方法说明

 二、实际运行效果:

 三、部分代码:

clc;
clear;
warning off;
%% 导入数据
Data = table2array(readtable("数据集.xlsx"));
% 本例数据集中包含:
% 1. 总共357个样本(每一行表示一个样本)
% 2. 每个样本12个特征值(即前12列每一列表示样本的一个特征,即输入的变量)
% 3. 每个样本1个响应值(第13列为表示样本的响应值,即被预测的变量)

%% 划分训练集和测试集
Temp = randperm(size(Data,1)); % 打乱数据的顺序,提升模型的泛化性。
InPut_num = 1:1:12; % 输入特征的列数,数据表格中前12列为输入值,因此设置为1:1:12,若前5个为输入则设置为1:1:5
OutPut_num = 13; % 输出响应列数,本例仅一个响应值,为数据表格中第13列,若多个响应值参照上行数据格式设置为x:1:y

% 选取前327个样本作为训练集,后30个样本作为测试集,即(1:327),和(328:end)
Train_InPut = Data(Temp(1:327),InPut_num); % 训练输入
Train_OutPut = Data(Temp(1:327),OutPut_num); % 训练输出
Test_InPut = Data(Temp(328:end),InPut_num); % 测试输入
Test_OutPut = Data(Temp(328:end),OutPut_num); % 测试输出

%% 数据归一化
% 将输入特征数据归一化到0-1之间
[~, Ps] = mapminmax([Train_InPut;Test_InPut]',0,1); 
Train_InPut = mapminmax('apply',Train_InPut',Ps);
Test_InPut = mapminmax('apply',Test_InPut',Ps);

四、完整代码+数据下载:

This add-in to the PSO Research toolbox (Evers 2009) aims to allow an artificial neural network (ANN or simply NN) to be trained using the Particle Swarm Optimization (PSO) technique (Kennedy, Eberhart et al. 2001). This add-in acts like a bridge or interface between MATLAB’s NN toolbox and the PSO Research Toolbox. In this way, MATLAB’s NN functions can call the NN add-in, which in turn calls the PSO Research toolbox for NN training. This approach to training a NN by PSO treats each PSO particle as one possible solution of weight and bias combinations for the NN (Settles and Rylander ; Rui Mendes 2002; Venayagamoorthy 2003). The PSO particles therefore move about in the search space aiming to minimise the output of the NN performance function. The author acknowledges that there already exists code for PSO training of a NN (Birge 2005), however that code was found to work only with MATLAB version 2005 and older. This NN-addin works with newer versions of MATLAB till versions 2010a. HELPFUL LINKS: 1. This NN add-in only works when used with the PSORT found at, http://www.mathworks.com/matlabcentral/fileexchange/28291-particle-swarm-optimization-research-toolbox. 2. The author acknowledges the modification of code used in an old PSO toolbox for NN training found at http://www.mathworks.com.au/matlabcentral/fileexchange/7506. 3. User support and contact information for the author of this NN add-in can be found at http://www.tricia-rambharose.com/ ACKNOWLEDGEMENTS The author acknowledges the support of advisors and fellow researchers who supported in various ways to better her understanding of PSO and NN which lead to the creation of this add-in for PSO training of NNs. The acknowledged are as follows: * Dr. Alexander Nikov - Senior lecturer and Head of Usaility Lab, UWI, St. Augustine, Trinidad, W.I. http://www2.sta.uwi.edu/~anikov/ * Dr. Sabine Graf - Assistant Professor, Athabasca University, Alberta, Canada. http://scis.athabascau.ca/scis/staff/faculty.jsp?id=sabineg * Dr. Kinshuk - Professor, Athabasca University, Alberta, Canada. http://scis.athabascau.ca/scis/staff/faculty.jsp?id=kinshuk * Members of the iCore group at Athabasca University, Edmonton, Alberta, Canada.
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值