当前位置:网站首页>MATLAB小技巧(25)竞争神经网络与SOM神经网络
MATLAB小技巧(25)竞争神经网络与SOM神经网络
2022-07-04 09:32:00 【mozun2020】
MATLAB小技巧(25)竞争神经网络与SOM神经网络
前言
MATLAB进行图像处理相关的学习是非常友好的,可以从零开始,对基础的图像处理都已经有了封装好的许多可直接调用的函数,这个系列文章的话主要就是介绍一些大家在MATLAB中常用一些概念函数进行例程演示!
竞争型神经网络是基于无监督学习(Unsupervised learning)方法的神经网络的一种重要类型,它经常作为基本的网络形式,构成其它一些具有自组织能力的网络,如自组织映射网络(SOM)、自适应共振理论网络、学习向量量化网络等。
自组织映射(Self-organizing map, SOM)通过学习输入空间中的数据,生成一个低维、离散的映射(Map),从某种程度上也可看成一种降维算法。SOM是一种无监督的人工神经网络。不同于一般神经网络基于损失函数的反向传递来训练,它运用竞争学习(competitive learning)策略,依靠神经元之间互相竞争逐步优化网络。且使用近邻关系函数(neighborhood function)来维持输入空间的拓扑结构。维持输入空间的拓扑结构:意味着 二维映射包含了数据点之间的相对距离。输入空间中相邻的样本会被映射到相邻的输出神经元。
由于基于无监督学习,这意味着训练阶段不需要人工介入(即不需要样本标签),即可以在不知道类别的情况下,对数据进行聚类;可以识别针对某问题具有内在关联的特征。竞争神经网络与SOM神经网络预测分析对比的仿真示例分享给大家,MATLAB版本为MATLAB2015b。
一. MATLAB仿真
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%功能:竞争神经网络与SOM神经网络
%环境:Win7,Matlab2015b
%Modi: C.S
%时间:2022-06-27
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% I. 清空环境变量
clear all
clc
tic
%% II. 训练集/测试集产生
%%
% 1. 导入数据
load water_data.mat
%%
% 2. 数据归一化
attributes = mapminmax(attributes);
%%
% 3. 训练集和测试集划分
% 训练集——35个样本
P_train = attributes(:,1:35);
T_train = classes(:,1:35);
% 测试集——4个样本
P_test = attributes(:,36:end);
T_test = classes(:,36:end);
%% III. 竞争神经网络创建、训练及仿真测试
%%
% 1. 创建网络
net = newc(minmax(P_train),4,0.01,0.01);
%%
% 2. 设置训练参数
net.trainParam.epochs = 500;
%%
% 3. 训练网络
net = train(net,P_train);
%%
% 4. 仿真测试
% 训练集
t_sim_compet_1 = sim(net,P_train);
T_sim_compet_1 = vec2ind(t_sim_compet_1);
% 测试集
t_sim_compet_2 = sim(net,P_test);
T_sim_compet_2 = vec2ind(t_sim_compet_2);
%% IV. SOFM神经网络创建、训练及仿真测试
%%
% 1. 创建网络
net = newsom(P_train,[4 4]);
%%
% 2. 设置训练参数
net.trainParam.epochs = 200;
%%
% 3. 训练网络
net = train(net,P_train);
%%
% 4. 仿真测试
% 训练集
t_sim_sofm_1 = sim(net,P_train);
T_sim_sofm_1 = vec2ind(t_sim_sofm_1);
% 测试集
t_sim_sofm_2 = sim(net,P_test);
T_sim_sofm_2 = vec2ind(t_sim_sofm_2);
%% V. 结果对比
%%
% 1. 竞争神经网络
result_compet_1 = [T_train' T_sim_compet_1']
result_compet_2 = [T_test' T_sim_compet_2']
%%
% 2. SOFM神经网络
result_sofm_1 = [T_train' T_sim_sofm_1']
result_sofm_2 = [T_test' T_sim_sofm_2']
toc
二. 仿真结果
result_compet_1 =
1 1
1 4
1 2
1 1
1 1
1 2
2 4
2 4
2 4
2 4
2 4
2 4
2 4
2 4
2 1
2 1
2 4
2 4
3 3
3 3
3 3
3 3
3 3
3 3
3 3
3 3
3 3
4 2
4 2
4 2
4 2
4 1
4 1
4 1
4 1
result_compet_2 =
1 4
2 4
3 3
4 2
result_sofm_1 =
1 9
1 11
1 12
1 9
1 4
1 12
2 10
2 10
2 10
2 10
2 10
2 10
2 13
2 10
2 9
2 9
2 14
2 10
3 3
3 5
3 1
3 1
3 1
3 2
3 1
3 2
3 1
4 15
4 12
4 16
4 15
4 7
4 7
4 8
4 8
result_sofm_2 =
1 11
2 10
3 1
4 15
时间已过 10.817151 秒。
依次点击Plots中的SOM Topology,SOM Neighbor Connections,SOM Neighbor Distances,SOM Input Planes,SOM Sample Hits,SOM Weight Positions可得如下仿真图示:
三. 小结
竞争神经网络与SOM神经网络进行训练,预测分析的示例仿真,其实在自己的专栏《MATLAB 神经网络43个案例分析》中也有介绍到这两种神经网络,感兴趣的同学也可以移步到专栏,链接在文末。每天学一个MATLAB小知识,大家一起来学习进步阿!
边栏推荐
- Mac platform forgets the root password of MySQL
- PMP registration process and precautions
- Analysis report on the production and marketing demand and investment forecast of tellurium dioxide in the world and China Ⓣ 2022 ~ 2027
- Pueue data migration from '0.4.0' to '0.5.0' versions
- 如何编写单元测试用例
- Simulate EF dbcontext with MOQ - mocking EF dbcontext with MOQ
- Solve the problem of "Chinese garbled MySQL fields"
- Write a jison parser from scratch (2/10): learn the correct posture of the parser generator parser generator
- 2022-2028 global special starch industry research and trend analysis report
- 20220701 barbarat lemma proof
猜你喜欢
2022-2028 global intelligent interactive tablet industry research and trend analysis report
LeetCode 74. Search 2D matrix
Mac platform forgets the root password of MySQL
Some points needing attention in PMP learning
2022-2028 global optical transparency industry research and trend analysis report
C language - Introduction - Foundation - syntax - data type (4)
2022-2028 global special starch industry research and trend analysis report
ArrayBuffer
At the age of 30, I changed to Hongmeng with a high salary because I did these three things
C language - Introduction - Foundation - syntax - [variable, constant light, scope] (V)
随机推荐
法向量点云旋转
C language - Introduction - Foundation - syntax - [variable, constant light, scope] (V)
Dynamic analysis and development prospect prediction report of high purity manganese dioxide in the world and China Ⓡ 2022 ~ 2027
20220701 Barbalat引理证明
China battery grade manganese sulfate Market Forecast and strategic consulting report (2022 Edition)
Solve the problem of "Chinese garbled MySQL fields"
Write a jison parser from scratch (1/10):jison, not JSON
Langage C - démarrer - base - syntaxe - [opérateur, conversion de type] (vi)
UML sequence diagram [easy to understand]
HMS core helps baby bus show high-quality children's digital content to global developers
2022-2028 research and trend analysis report on the global edible essence industry
Ultimate bug finding method - two points
Global and Chinese market of wheel hubs 2022-2028: Research Report on technology, participants, trends, market size and share
Launpad | 基础知识
2022-2028 global visual quality analyzer industry research and trend analysis report
Function comparison between cs5261 and ag9310 demoboard test board | cost advantage of cs5261 replacing ange ag9310
Explanation of for loop in golang
Reading notes of how the network is connected - understanding the basic concepts of the network (I)
Global and Chinese market of sampler 2022-2028: Research Report on technology, participants, trends, market size and share
如何编写单元测试用例