可以使用硬限幅
>> test
e =
10000
e =
-1 0 -1 -1 -1
Wij =
-1.0428 -1.5146
b =
-1 0 -1 -1 -1
e =
0 1 0 0 0
Wij =
-0.0428 -0.5146
b =
-1 1 -1 -1 -1
e =
0 0 0 0 0
Wij =
-0.0428 -0.5146
b =
-1 1 -1 -1 -1
net =
-1.5146 0.4425 -1.5146 -1.0428 -1.0428
y =
0 1 0 0 0
%感知机的学习过程,and运算
P=[0 1 0 1 1;1 1 1 0 0];
T=[0 1 0 0 0];
[M,N]=size(P);
[L,N]=size(T);
%权值矩阵
Wij=rand(L,M);
%阈值矩阵
b=zeros(L,1);
e=10000
while (mae(e)>0.0015)
net=netsum(Wij*P,b);
y=hardlim(net);
e=T-y
Wij=Wij+e*P'
b=b+e
end
net=netsum(Wij*P,b)
y=hardlim(net)
help netsum
NETSUM Sum net input function.
Syntax
N = netsum({Z1,Z2,...,Zn},FP)
dN_dZj = netsum('dz',j,Z,N,FP)
INFO = netsum(CODE)
Description
NETSUM is a net input function. Net input functions calculate
a layer's net input by combining its weighted inputs and bias.
NETSUM({Z1,Z2,...,Zn},FP) takes Z1-Zn and optional function parameters,
Zi - SxQ matrices in a row cell array.
FP - Row cell array of function parameters (ignored).
Returns element-wise sum of Z1 to Zn.
NETSUM('dz',j,{Z1,...,Zn},N,FP) returns the derivative of N with
respect to Zj. If FP is not supplied the default values are used.
if N is not supplied, or is [], it is calculated for you.
NETSUM('name') returns the name of this function.
NETSUM('type') returns the type of this function.
NETSUM('fpnames') returns the names of the function parameters.
NETSUM('fpdefaults') returns default function parameter values.
NETSUM('fpcheck',FP) throws an error for illegal function parameters.
NETSUM('fullderiv') returns 0 or 1, if the derivate is SxQ or NxSxQ.
Examples
Here NETSUM combines two sets of weighted input vectors and a bias.
We must use CONCUR to make B the same dimensions as Z1 and Z2.
z1 = [1 2 4; 3 4 1]
z2 = [-1 2 2; -5 -6 1]
b = [0; -1]
n = netsum({z1,z2,concur(b,3)})
Here we assign this net input function to layer i of a network.
net.layers{i}.netFcn = 'compet';
Use NEWP or NEWLIN to create a standard network that uses NETSUM.
hardlim通过计算网络的输入得到该层的输出,如果网络的输入达到门限,则输出1,否则输出0,
配合netsum函数,可以构造感知机的学习过程
help hardlim
HARDLIM Hard limit transfer function.
Syntax
A = hardlim(N,FP)
dA_dN = hardlim('dn',N,A,FP)
INFO = hardlim(CODE)
Description
HARDLIM is a neural transfer function. Transfer functions
calculate a layer's output from its net input.
HARDLIM(N,FP) takes N and optional function parameters,
N - SxQ matrix of net input (column) vectors.
FP - Struct of function parameters (ignored).
and returns A, the SxQ boolean matrix with 1's where N >= 0.
HARDLIM('dn',N,A,FP) returns SxQ derivative of A w-respect to N.
If A or FP are not supplied or are set to [], FP reverts to
the default parameters, and A is calculated from N.
HARDLIM('name') returns the name of this function.
HARDLIM('output',FP) returns the [min max] output range.
HARDLIM('active',FP) returns the [min max] active input range.
HARDLIM('fullderiv') returns 1 or 0, whether DA_DN is SxSxQ or SxQ.
HARDLIM('fpnames') returns the names of the function parameters.
HARDLIM('fpdefaults') returns the default function parameters.
Examples
Here is how to create a plot of the HARDLIM transfer function.
n = -5:0.1:5;
a = hardlim(n);
plot(n,a)
Here we assign this transfer function to layer i of a network.
net.layers{i}.transferFcn = 'hardlim';
Algorithm
hardlim(n) = 1, if n >= 0
0, otherwise
>> help hardlims
HARDLIMS Symmetric hard limit transfer function.
Syntax
A = hardlims(N,FP)
dA_dN = hardlims('dn',N,A,FP)
INFO = hardlims(CODE)
Description
HARDLIMS is a neural transfer function. Transfer functions
calculate a layer's output from its net input.
HARDLIMS(N,FP) takes N and optional function parameters,
N - SxQ matrix of net input (column) vectors.
FP - Struct of function parameters (ignored).
and returns A, the SxQ +1/-1 matrix with +1's where N >= 0.
HARDLIMS('dn',N,A,FP) returns SxQ derivative of A w-respect to N.
If A or FP are not supplied or are set to [], FP reverts to
the default parameters, and A is calculated from N.
HARDLIMS('name') returns the name of this function.
HARDLIMS('output',FP) returns the [min max] output range.
HARDLIMS('active',FP) returns the [min max] active input range.
HARDLIMS('fullderiv') returns 1 or 0, whether DA_DN is SxSxQ or SxQ.
HARDLIMS('fpnames') returns the names of the function parameters.
HARDLIMS('fpdefaults') returns the default function parameters.
Examples
Here is how to create a plot of the HARDLIMS transfer function.
n = -5:0.1:5;
a = hardlims(n);
plot(n,a)
Here we assign this transfer function to layer i of a network.
net.layers{i}.transferFcn = 'hardlims';
Algorithm
hardlims(n) = 1, if n >= 0
-1, otherwise
hardlims达到门限输出为1,否则输出-1
>> a=[-5:0.5:5]
a =
Columns 1 through 6
-5.0000 -4.5000 -4.0000 -3.5000 -3.0000 -2.5000
Columns 7 through 12
-2.0000 -1.5000 -1.0000 -0.5000 0 0.5000
Columns 13 through 18
1.0000 1.5000 2.0000 2.5000 3.0000 3.5000
Columns 19 through 21
4.0000 4.5000 5.0000
>> c=hardlim(a)
c =
Columns 1 through 11
0 0 0 0 0 0 0 0 0 0 1
Columns 12 through 21
1 1 1 1 1 1 1 1 1 1
>> d=hardlims(a)
d =
Columns 1 through 11
-1 -1 -1 -1 -1 -1 -1 -1 -1 -1 1
Columns 12 through 21
1 1 1 1 1 1 1 1 1 1
>>
分享到:
相关推荐
1、资源内容:NJUST机器学习课后作业python实现-朴素贝叶斯-神经网络-感知机-softmax回归-逻辑回归+源代码+文档说明 2、代码特点:内含运行结果,不会运行可私信,参数化编程、参数可方便更改、代码编程思路清晰、...
MATLAB快速入门,单层感知器,线性神经网络,BP神经网络,反馈神经网络,随机神经网络,GUI设计神经网络等等
2.2 感知器神经网络模型与学习算法 2.2.1 单层感知器 2.2.2 单层感知器的学习算法 2.2.3 单层感知器的MATLAB实现 2.2.4 多层感知器 2.3 线性神经网络模型与学习算法 2.3.1 线性神经元网络模型 2.3.2 线性神经网络的...
神经网络理论与MATLAB7实现.part1的下载地址: http://download.csdn.net/source/663471 第1章 概述 1.1 MATLAB语言简介 1.1.1 MATLAB概述 1.1.2 MATLAB语言特点 1.1.3 MATLAB 7的安装 1.1.4 MATLAB 7的新特点 ...
1.版本:matlab2019a,不会运行可私信 2.领域:基础教程 3.内容:Matlab实现反向传播学习的多层感知器 (MLP) 神经网络算法 4.适合人群:本科,硕士等教研学习使用
感知器(Perceptron),是神经网络中的一个概念,在1950s由Frank Rosenblatt第一次引入。 单层感知器(Single Layer Perceptron)是最简单的神经网络。它包含输入层和输出层,而输入层和输出层是直接相连的。 与最早...
第1章 概述 1.1 MATLAB语言简介 1.1.1 MATLAB概述 1.1.2 MATLAB语言特点 1.1.3 MATLAB 7的安装 ...第8章 基于神经网络的故障诊断 第9章 基于神经网络的预测 第10章 基于神经网络的模糊控制 参考文献
目标检测模型、智能优化算法、神经网络预测、信号处理、元胞自动机、图像处理、智能控制、路径规划、无人机等多种领域的算法仿真实验,更多源码,请上博主主页搜索。 ---------------------------------------------...
第1章 概述 神经网络理论与MATLAB7实现.part2的下载地址: ...1.1 MATLAB语言简介 1.1.1 MATLAB概述 ...第8章 基于神经网络的故障诊断 第9章 基于神经网络的预测 第10章 基于神经网络的模糊控制 参考文献
│1 matlab感知器神经网络初步学习 │2 matlab使用建立好的神经网络进行分类 │3 matlab线性神经网络预测 │4 BP神经网络matlab信号拟合 │5 matlab径向基神经网络预测 │6 matlab广义回归神经网络预测 │7 matlab...
BP神经网络解决异或逻辑的两种方法,matlab的源代码程序文件,这是初学BP神经网络会碰到的一个比较棘手的问题,本代码提供了两种不同的方法实现BP神经网络解决异或逻辑,可能比较基础,方法也不是很牛逼,纯自己瞎玩...
基于matlab程序的各种回归、分类算法实现 ...Ganzhiji - 感知机(perception) PSO - 粒子群优化 KNN - K_近邻 Bayes - 贝叶斯 OSC - 正交信号校正 GDescent - 梯度下降 ANN - 人工神经网络 BOOSTING - 提升算法
单层感知器matlab代码--MATLAB神经网络原理与实例精解
感知机的matlab代码,这是.m文件,把中文名改成英文的就能用了,因为老版本的matlab不能识别中文名 感知机是二分类的线性模型,其输入是实例的特征向量,输出的是事例
本书主要讲述神经网络的...同时本书包含大量例题、习题,并配有基于MATLAB软件包的“神经网络设计演示”程序。本书可以作为大学高年级本科生或一年级研究生的神经网络课程教材,也可供从事相关研究工作的科技人员参考。
本实验旨在掌握Weka 多层感知机模型实践操作;了解多层感知机算法在各领域的应用;掌握Matlab 神经网络工具箱实践操作;了解Matlab 神经网络工具箱在各领域的应用。
深度学习 神经网络 BP 多层感知机 非线性函数 拟合 matlab
Ganzhiji - 感知机(perception) PSO - 粒子群优化 KNN - K_近邻 Bayes - 贝叶斯 OSC - 正交信号校正 GDescent - 梯度下降 ANN - 人工神经网络 BOOSTING - 提升算法 1、资源内容: 2、代码特点:内含运行结果...
适合在校大学生初步实验使用,将此程序直接粘贴到Matlab的m文件中,便可直接运行,得到结果,本人已在博客中发表“与”运算实验,神经网络网址如https://blog.csdn.net/weixin_41529093/article/details/86713335,...
基于matlab程序的各种回归、分类算法实现项目源码(高分课程设计).zip 包括:MLR - 多元线性回归、PCA - 主成分分析、PLS - 偏最小二乘、LogisticR - 逻辑斯蒂回归、Ganzhiji - 感知机(perception)、PSO - 粒子群...