可以使用硬限幅

>> 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-yWij=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

>>

神经网络-感知机(8)[matlab]相关推荐

  1. ann matlab,人工神经网络ann及其matlab仿真.ppt

    人工神经网络ann及其matlab仿真 人工神经网络 的研究方法及应用刘 长 安2004. 12. 31 引 言 利用机器模仿人类的智能是长期以来人们认识自然.改造自然和认识自身的理想. 研究ANN目 ...

  2. matlab newelm,Elman神经网络介绍以及Matlab实现

    Elman神经网络介绍以及Matlab实现 发布时间:2018-06-28 19:27, 浏览次数:745 , 标签: Elman Matlab Elman神经网络介绍 1.特点 Elman神经网络是 ...

  3. 【深度学习的数学】“2×4×1层带sigmoid激活函数的神经网络感知机对三角形平面的分类训练预测”,输出层加偏置b(实时绘制损失函数曲线)(对输入数据归一化)(奇迹出现了!)

    文章目录 前言 代码 修改之前错误的代码 知道为何Z的结果不能拟合到预期的5了 解决办法1:取消输出层神经单元的a和b(直接将z作为输出)(这个办法不行,影响神经单元的完整性,没法计算出输出层神经单元 ...

  4. 【深度学习的数学】接“2×3×1层带sigmoid激活函数的神经网络感知机对三角形平面的分类训练预测”,输出层加偏置b

    文章目录 代码 接:[深度学习的数学]2×3×1层带sigmoid激活函数的神经网络感知机对三角形平面的分类训练预测(绘制出模型结果三维图展示效果)(梯度下降法+最小二乘法+激活函数sigmoid+误 ...

  5. 【深度学习的数学】2×3×1层带sigmoid激活函数的神经网络感知机对三角形平面的分类训练预测(绘制出模型结果三维图展示效果)(梯度下降法+最小二乘法+激活函数sigmoid+误差反向传播法)

    文章目录 训练数据 数据示意 训练数据生成及绘制三维图像代码 训练数据三维图像 搭建神经网络结构 网络结构 利用梯度下降法和误差反向传播法计算损失函数损失值 代码 [灾难降临]代码出现严重问题,已将其 ...

  6. 可用于神经网络的一些matlab函数

    可用于神经网络的一些matlab函数 (来自matlab文档) 1.用于样本初始化等的函数rand %返回一个在区间 (0,1) 内均匀分布的随机数 X = rand; %返回一个 n×n 的随机数矩 ...

  7. matlab 神经网络设计多层隐含层_[rbf神经网络]请教关于MATLAB中RBF神经网络隐含层神经元个数的问题...

    rbf神经网络 请教关于MATLAB中RBF神经网络隐含层神经元个数的问题 问题补充:MATLAB中用newrb(P, T, goal, spread)创建的神经网络,用于数据的预测,程序可以运行并能 ...

  8. BP神经网络原理及Matlab实现(Back Propagation Neural Networks,BPNN)

    BP神经网络原理及matlab实现 一.简介 1.BP 神经网络的信息处理方式的特点 2.BP神经网络的主要功能 二.神经网络的训练 1.神经网络拓扑结构(隐含层)的确定 2.网络的初始连接权值 3. ...

  9. 神经网络控制与matlab仿真,matlab神经网络预测模型

    matlab神经网络43个案例分析第十七章基于SVM的信息粒化运行问题 代码你修改过吗,没有修改过.用的又是原版的SVMLIM工具箱的话,运行应该是无错的,因为所有的案例代码都经过校正. 维数不一致, ...

最新文章

  1. OpenCV 【七】————边缘提取算子(图像边缘提取)——canny算法的原理及实现
  2. 元宇宙和我有什么关系?
  3. ubuntu中如何使用中文输入法
  4. Shell-流程控制
  5. c语言struct_Introduction to CSAPP(十七):复杂数据组织与C语言的 struct与union
  6. 01-java基础加强,eclipse工具使用,快捷键,断点调试,单元测试,jdk5新特性,增强for循环,集合map,list,可变参数,枚举,反射,泛型
  7. 账号类型_3-2-3节 文字创作类之账号类型
  8. 使用Java和Google GSON解析ESPN API
  9. 深度学习案例之基于 CNN 的 MNIST 手写数字识别
  10. Django中的Model模型
  11. rserve php,使用Rserve远程执行R脚本
  12. 推荐一个比FiddlerCore好用的HTTP(S)代理服务器
  13. CoffeeScript简介 二
  14. 用python海龟画图_天呐!python 的乌龟绘图怎么用啊!?
  15. 计算机的组成结构6,计算机组成及结构.6.ppt
  16. 消息 15135,级别 16,状态 8,过程 sp_addextendedproperty,对象无效。不允许有扩展属性,或对象不存在。...
  17. MySQL分表实现上百万上千万记录分布存储的批量查询设计模式
  18. python的xlwt模块_Python xlwt模块
  19. java校园圈子论坛跳蚤市场小程序源码
  20. 天宝AMD 300U物理机安装黑群晖处理内存不足的问题

热门文章

  1. java面向对象编程的实现
  2. 微博季报图解:营收4.5亿美元同比降22% 广告需求短期内承压
  3. 在欧洲如何在日常生活中使用加密货币-TAP万事达卡
  4. elementui踩坑el-dialog
  5. 在线刷题题库微信小程序开发制作功能介绍
  6. android 盒子录屏apk,三种用于安卓录屏的解决方案
  7. WPS加载项系列(1)第一个WPS项目
  8. 《炬丰科技-半导体工艺》介电蚀刻工艺中等离子体的蚀刻处理
  9. 房屋买卖合同纠纷中解约定金的适用
  10. 通过Filter给Request、Response加点料