资源简介
lvq学习算法源码(matlab)lvq学习算法源码(matlab)
代码片段和文件信息
clear
clc
%获取训练样本点
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
feature_num=2;
sample_num=200;
mu = [0 1];
sigma=[0.65*0.65 0; 0 0.65*0.65];
mu1 = [0 1];
mu2 = [0 -1];
r1_=mvnrnd(mu1sigmasample_num);
r2_=mvnrnd(mu2sigmasample_num);
% axis([-3 3 -3 3]);
p_train = [r1_;r2_];
p_train = p_train‘;
t_train = ones(12*sample_num);
t_train (sample_num+1:2*sample_num) = t_train (sample_num+1:2*sample_num) - 1;
plotpv(p_train t_train);
t_train = ones(12*sample_num);
t_train (sample_num+1:2*sample_num) = t_train (sample_num+1:2*sample_num) + 1;
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%lvq算法对其进行优化
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
k=2;%隐中心的数目
% p_cluster(:1:k) = em(p_train(:1:sample_num) k feature_num sample_num);
% p_cluster(:k+1:2*k) = em(p_train(:sample_num+1:2*sample_num) k feature_num sample_num);
net_lvq = newlvq(minmax(p_train)2*k[.5 .5]0.01‘learnlv‘);
net_lvq.trainParam.epochs=100;
tc_train = ind2vec(t_train);
net_lvq = train(net_lvqp_traintc_train);
p_cluster = net_lvq.IW{11}‘;
t_cluster = ones(12*k);
t_cluster(1k+1:2*k)=t_cluster(1k+1:2*k)-1;
plotpv(p_cluster t_cluster);
% plotpv(p_cluster t_cluster);
t_cluster = ones(12*k);
t_cluster(1k+1:2*k)=t_cluster(1k+1:2*k)+1;
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%建立网络
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
p=p_cluster;
t=t_cluster;
% p=p_train;
% t=t_train;
net = network;
net.n
- 上一篇:FBMC OQAM matlab code
- 下一篇:pca源码matlab
评论
共有 条评论