当前位置:网站首页>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小知识,大家一起来学习进步阿!
边栏推荐
- 保姆级JDEC增删改查练习
- 165 webmaster online toolbox website source code / hare online tool system v2.2.7 Chinese version
- `Example of mask ` tool use
- Explain TCP protocol in detail three handshakes and four waves
- Trim leading or trailing characters from strings- Trim leading or trailing characters from a string?
- HMS core helps baby bus show high-quality children's digital content to global developers
- C language - Introduction - Foundation - syntax - [variable, constant light, scope] (V)
- Review of last week's hot spots (6.27-7.3)
- Reload CUDA and cudnn (for tensorflow and pytorch) [personal sorting summary]
- Go context 基本介绍
猜你喜欢

26. Delete duplicates in the ordered array (fast and slow pointer de duplication)

After unplugging the network cable, does the original TCP connection still exist?

el-table单选并隐藏全选框

HMS core helps baby bus show high-quality children's digital content to global developers

GoLand environment variable configuration

At the age of 30, I changed to Hongmeng with a high salary because I did these three things

How to batch change file extensions in win10
![C language - Introduction - Foundation - syntax - [variable, constant light, scope] (V)](/img/dc/5c8077c10cdc7ad6e6f92dedfbe797.png)
C language - Introduction - Foundation - syntax - [variable, constant light, scope] (V)

2022-2028 global industrial gasket plate heat exchanger industry research and trend analysis report

How should PMP learning ideas be realized?
随机推荐
2022-2028 global industrial gasket plate heat exchanger industry research and trend analysis report
Report on investment analysis and prospect trend prediction of China's MOCVD industry Ⓤ 2022 ~ 2028
The 14th five year plan and investment risk analysis report of China's hydrogen fluoride industry 2022 ~ 2028
Write a jison parser from scratch (1/10):jison, not JSON
Function comparison between cs5261 and ag9310 demoboard test board | cost advantage of cs5261 replacing ange ag9310
Global and Chinese market of bipolar generators 2022-2028: Research Report on technology, participants, trends, market size and share
Launpad | basic knowledge
C language - Introduction - Foundation - syntax - [variable, constant light, scope] (V)
Simulate EF dbcontext with MOQ - mocking EF dbcontext with MOQ
【leetcode】540. A single element in an ordered array
26. Delete duplicates in the ordered array (fast and slow pointer de duplication)
Go context 基本介绍
At the age of 30, I changed to Hongmeng with a high salary because I did these three things
About the for range traversal operation in channel in golang
SSM online examination system source code, database using mysql, online examination system, fully functional, randomly generated question bank, supporting a variety of question types, students, teache
pcl::fromROSMsg报警告Failed to find match for field ‘intensity‘.
20220701 barbarat lemma proof
Upgrading Xcode 12 caused Carthage to build cartfile containing only rxswift to fail
`Example of mask ` tool use
Clion console output Chinese garbled code