✅作者简介:热爱科研的Matlab仿真开发者,修心和技术同步精进,matlab项目合作可私信。
🍎个人主页:Matlab科研工作室
🍊个人信条:格物致知。
更多Matlab仿真内容点击👇
⛄ 内容介绍
随着信息时代的发展,网络上每天都产生数以亿万计的新数据.为了有效地处理和分辨这些数据,识别其中隐含的有用信息,人们需要使用各种分类器对这些数据进行学习,分类,甄别与过滤.针对网络上数据规模的持续增加,讨论热点的不断迁移现象,传统分类器已不能自适应网络环境需求,人们希望对传统分类器进行改进使之具备相应的能力,能够随着网络环境与信息的不断变化而发生改变,即改进的分类器具有连续学习能力. 在现今的增量学习算法研究中,学者们多通过对各分类器增加增量学习机制来提高单次输入的训练精度或效率,而对能适应连续学习的连续增量学习机制的研究尚少.此外,本文所依托的项目采用了特殊的级联分类机制,而目前缺乏相关研究将增量学习算法应用于此分类机制. 本文主要对以上两点进行研究讨论,具体针对现有的分类器进行研究,改进,为其以及改进的分类判别算法增加合适的增量学习机制,使之适应不断更新的网络数据,并据此提出解决方案.本文研究了当前经典的DT,NN,KNN,SVM等分类器,以及基于分类器的各种增量学习算法,分析了各算法的优缺点以及对本文所研究的分类器对象的筛选;
⛄ 部分代码
function [Network2 BestCost] = TrainPSO(Network,Xtr,Ytr)
% Statement
IW = Network.IW{1,1}; IW_Num = numel(IW);
LW = Network.LW{2,1}; LW_Num = numel(LW);
b1 = Network.b{1,1}; b1_Num = numel(b1);
b2 = Network.b{2,1}; b2_Num = numel(b2);
TotalNum = IW_Num + LW_Num + b1_Num + b2_Num;
NPar = TotalNum;
VarMin = -1*ones(1,TotalNum);
VarMax = +1*ones(1,TotalNum);
CostFuncName = 'NNCost';
%% PSO Parameters
SwarmSize = 9;
MaxIteration = 20;
C1 = 2; % Cognition Coefficient;
C2 = 4 - C1; % Social Coefficient;
%
% Initial Population
GBest.Cost = inf;
GBest.Position = [];
GBest.CostMAT = [];
for p = 1:SwarmSize
Particle(p).Position = rand(1,NPar) .* (VarMax - VarMin) + VarMin;
Particle(p).Cost = feval(CostFuncName,Particle(p).Position,Xtr,Ytr,Network);
Particle(p).Velocity = [];
Particle(p).LBest.Position = Particle(p).Position;
Particle(p).LBest.Cost = Particle(p).Cost;
if Particle(p).LBest.Cost < GBest.Cost
GBest.Cost = Particle(p).LBest.Cost;
GBest.Position = Particle(p).LBest.Position;
end
end
% Optimization
for Iter = 1:MaxIteration
% Velocity update
for p = 1:SwarmSize
Particle(p).Velocity = C1 * rand * (Particle(p).LBest.Position - Particle(p).Position) + C2 * rand * (GBest.Position - Particle(p).Position);
Particle(p).Position = Particle(p).Position + Particle(p).Velocity;
Particle(p).Position = max(Particle(p).Position , VarMin);
Particle(p).Position = min(Particle(p).Position , VarMax);
Particle(p).Cost = feval(CostFuncName,Particle(p).Position,Xtr,Ytr,Network);
if Particle(p).Cost < Particle(p).LBest.Cost
Particle(p).LBest.Position = Particle(p).Position;
Particle(p).LBest.Cost = Particle(p).Cost;
if Particle(p).LBest.Cost < GBest.Cost
GBest.Cost = Particle(p).LBest.Cost;
GBest.Position = Particle(p).LBest.Position;
end
end
end
% Plot
disp(['In Itration Number = ' num2str(Iter) '; Highest Cost Is = ' num2str(GBest.Cost) ';'])
GBest.CostMAT = [GBest.CostMAT GBest.Cost];
end
GBest.Position;
figure
set(gcf, 'Position', [450, 250, 900, 350])
plot(GBest.CostMAT,'-.',...
'LineWidth',2,...
'MarkerSize',8,...
'MarkerEdgeColor','g',...
'Color',[0.6,0.1,0]);
title('Particle Swarm Pptimization Train')
xlabel('PSO Iteration Number','FontSize',10,...
'FontWeight','bold','Color','m');
ylabel('PSO Best Cost Result','FontSize',10,...
'FontWeight','bold','Color','m');
legend({'PSO Train'});
Network2 = NetConstruct(Network,GBest.Position);
BestCost = GBest.Cost;
end
⛄ 运行结果
⛄ 参考文献
[1] 唐银凤黄志明黄荣娟姜佳欣卢昕. 基于多特征提取和SVM分类器的纹理图像分类[J]. 计算机应用与软件, 2011, 028(006):22-25,46.
[2] 刘健, 薛蒙. 基于K最近邻决策的支持向量机分类算法及仿真[J]. 舰船电子工程, 2009(3):4.
[3] 佟雨兵, 张其善, 常青,等. 基于NN与SVM的图像质量评价模型[J]. 北京航空航天大学学报, 2006, 32(9):4.