当前位置:网站首页>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小知识,大家一起来学习进步阿!
边栏推荐
- How to ensure the uniqueness of ID in distributed environment
- 什么是uid?什么是Auth?什么是验证器?
- "How to connect the network" reading notes - Web server request and response (4)
- Write a jison parser from scratch (3/10): a good beginning is half the success -- "politics" (Aristotle)
- Nurse level JDEC addition, deletion, modification and inspection exercise
- Research Report on research and investment prospects of China's testing machine industry (2022 Edition)
- Global and Chinese market of wheel hubs 2022-2028: Research Report on technology, participants, trends, market size and share
- UML sequence diagram [easy to understand]
- Mantis creates users without password options
- Write a jison parser from scratch (2/10): learn the correct posture of the parser generator parser generator
猜你喜欢
回复评论的sql
How to ensure the uniqueness of ID in distributed environment
26. Delete duplicates in the ordered array (fast and slow pointer de duplication)
Markdown syntax
[C Advanced] file operation (2)
Some points needing attention in PMP learning
C语言-入门-基础-语法-数据类型(四)
How to batch change file extensions in win10
PHP personal album management system source code, realizes album classification and album grouping, as well as album image management. The database adopts Mysql to realize the login and registration f
Leetcode (Sword finger offer) - 35 Replication of complex linked list
随机推荐
C language - Introduction - Foundation - syntax - data type (4)
Flutter 小技巧之 ListView 和 PageView 的各種花式嵌套
GoLand environment variable configuration
Report on investment analysis and prospect trend prediction of China's MOCVD industry Ⓤ 2022 ~ 2028
Investment analysis and prospect prediction report of global and Chinese high purity tin oxide Market Ⓞ 2022 ~ 2027
el-table单选并隐藏全选框
Reading notes on how to connect the network - hubs, routers and routers (III)
【leetcode】540. A single element in an ordered array
Dede plug-in (multi-function integration)
Flutter tips: various fancy nesting of listview and pageview
Solve the problem of "Chinese garbled MySQL fields"
Implementation principle of redis string and sorted set
pcl::fromROSMsg报警告Failed to find match for field ‘intensity‘.
Sword finger offer 30 contains the stack of Min function
Solution to null JSON after serialization in golang
Leetcode (Sword finger offer) - 35 Replication of complex linked list
Reload CUDA and cudnn (for tensorflow and pytorch) [personal sorting summary]
HMS core helps baby bus show high-quality children's digital content to global developers
lolcat
In depth research and investment strategy report on China's hydraulic parts industry (2022 Edition)