当前位置:网站首页>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小知识,大家一起来学习进步阿!
边栏推荐
- Rules for using init in golang
- Implementation principle of redis string and sorted set
- Explanation of for loop in golang
- Global and Chinese market of sampler 2022-2028: Research Report on technology, participants, trends, market size and share
- Get the source code in the mask with the help of shims
- 20220701 Barbalat引理证明
- How to display √ 2 on the command line terminal ̅? This is actually a blog's Unicode test article
- 2022-2028 global special starch industry research and trend analysis report
- AMLOGIC gsensor debugging
- Review of last week's hot spots (6.27-7.3)
猜你喜欢
2022-2028 global protein confectionery industry research and trend analysis report
2022-2028 global gasket plate heat exchanger industry research and trend analysis report
mmclassification 标注文件生成
[C Advanced] file operation (2)
QTreeView+自定义Model实现示例
法向量点云旋转
How should PMP learning ideas be realized?
自动化的优点有哪些?
Svg image quoted from CodeChina
PHP book borrowing management system, with complete functions, supports user foreground management and background management, and supports the latest version of PHP 7 x. Database mysql
随机推荐
Launchpad x | mode
Write a jison parser from scratch (3/10): a good beginning is half the success -- "politics" (Aristotle)
PHP book borrowing management system, with complete functions, supports user foreground management and background management, and supports the latest version of PHP 7 x. Database mysql
《网络是怎么样连接的》读书笔记 - WEB服务端请求和响应(四)
Analysis report on the development status and investment planning of China's modular power supply industry Ⓠ 2022 ~ 2028
Leetcode (Sword finger offer) - 35 Replication of complex linked list
《网络是怎么样连接的》读书笔记 - Tcp/IP连接(二)
If you can quickly generate a dictionary from two lists
Dede plug-in (multi-function integration)
How to write unit test cases
"How to connect the Internet" reading notes - FTTH
In depth investigation and Strategic Research Report on China's motion controller Market (2022 Edition)
Review of last week's hot spots (6.27-7.3)
法向量点云旋转
Write a jison parser from scratch (6/10): parse, not define syntax
Lauchpad x | MODE
《网络是怎么样连接的》读书笔记 - 认识网络基础概念(一)
Global and Chinese markets for laser assisted liposuction (LAL) devices 2022-2028: Research Report on technology, participants, trends, market size and share
Report on research and investment prospect prediction of China's electronic grade sulfuric acid industry (2022 Edition)
C language - Introduction - Foundation - syntax - [main function, header file] (II)