约定:

所有的初始化权值范围,如下,就是说更换激活函数的情况,没有过大的调整初始权重。

         if(randomMode==1):
numpy.random.seed(seedWih)
self.wih = numpy.random.rand(self.hNodes, self.iNodes)-0.5
numpy.random.seed(seedWho)
self.who = numpy.random.rand(self.oNodes, self.hNodes)-0.5
else:
numpy.random.seed(seedWih)
self.wih = numpy.random.normal (0.0, pow(self.hNodes,-0.5), (self.hNodes, self.iNodes))
numpy.random.seed(seedWho)
self.who = numpy.random.normal (0.0, pow(self.oNodes,-0.5), (self.oNodes, self.hNodes))

证明神经网络具有学习能力的方案:

为了减少测试时间,

将MNIST_100迭代训练较多次。

然后将其作为测试数据。如果出现了过拟合状态,承认通过训练其具有学习能力。可以进行下述测试:

参数含义:

输入层节点/隐层结点/输出层节点/学习率/初始化权重的分布方案/输入层和隐层的初始化种子/输出层和隐层的初始化种子/使用的激活函数

激活函数为:softmax:

训练1代,达到95.17%的测试识别率。参数为:784/100/10/0.1、rand、4、5、softmax.

训练2代,达到96.16%的测试识别率。参数为:784/100/10/0.1、rand、4、5、softmax.

训练3代,达到96.52%的测试识别率。参数为:784/100/10/0.1、rand、4、5、softmax.

训练4代,达到96.43%的测试识别率。参数为:784/100/10/0.1、rand、4、5、softmax.

训练5代,达到96.56%的测试识别率。参数为:784/100/10/0.1、rand、4、5、softmax.

训练6代,达到96.41%的测试识别率。参数为:784/100/10/0.1、rand、4、5、softmax.

调试参数如下:

inputs = numpy.asfarray( all_values [1:])/255.0*0.99+0.01
targets = numpy.zeros(self.nN.oNodes) + 0.01
targets[int (all_values[0])] = 0.99

fx1=numpy.exp(-final_inputs)/((1+numpy.exp(-final_inputs))*(1+numpy.exp(-final_inputs)))
fx2=numpy.exp(-hidden_inputs)/((1+numpy.exp(-hidden_inputs))*(1+numpy.exp(-hidden_inputs)))

self.who += self.lr * numpy.dot((output_errors * fx1),numpy.transpose(hidden_outputs))
self.wih += self.lr * numpy.dot((hidden_errors * fx2),numpy.transpose(inputs))

激活函数为:softsign:

一点说明:

为什么学习率取值这样

sigmoid*2-1

训练5代,达到65.58%的测试识别率。参数为:784/80/10/0.05、normal、4、5、softsign.

训练10代,达到74.39%的测试识别率。参数为:784/80/10/0.05、normal、4、5、softsign.

训练15代,达到76.49%的测试识别率。参数为:784/80/10/0.05、normal、4、5、softsign.

训练20代,达到83.34%的测试识别率。参数为:784/80/10/0.05、normal、4、5、softsign.

训练25代,达到91.8%的测试识别率。参数为:784/80/10/0.05、normal、4、5、softsign.

训练30代,达到92.43%的测试识别率。参数为:784/80/10/0.05、normal、4、5、softsign.

训练35代,达到92.54%的测试识别率。参数为:784/80/10/0.05、normal、4、5、softsign.

调试参数如下:

inputs = numpy.asfarray( all_values [1:])/255.0*0.5
targets = numpy.zeros(self.nN.oNodes) -0.99
targets[int (all_values[0])] = 0.99

fx1=numpy.exp(-final_inputs)/((1+numpy.exp(-final_inputs))*(1+numpy.exp(-final_inputs)))
fx2=numpy.exp(-hidden_inputs)/((1+numpy.exp(-hidden_inputs))*(1+numpy.exp(-hidden_inputs)))

self.who += self.lr * numpy.dot((output_errors * fx1),numpy.transpose(hidden_outputs))
self.wih += self.lr * numpy.dot((hidden_errors * fx2),numpy.transpose(inputs))

激活函数为:tanh:

训练1代,达到93.57%的测试识别率。参数为:784/80/10/0.05、normal、4、5、tanh.

训练2代,达到94.44%的测试识别率。参数为:784/80/10/0.05、normal、4、5、tanh.

训练3代,达到94.73%的测试识别率。参数为:784/80/10/0.05、normal、4、5、tanh.

训练4代,达到94.47%的测试识别率。参数为:784/80/10/0.05、normal、4、5、tanh.

训练5代,达到95.05%的测试识别率。参数为:784/80/10/0.05、normal、4、5、tanh.

训练6代,达到95.33%的测试识别率。参数为:784/80/10/0.05、normal、4、5、tanh.

训练7代,达到94.86%的测试识别率。参数为:784/80/10/0.05、normal、4、5、tanh.

调试参数如下:

inputs = numpy.asfarray( all_values [1:])/255.0*0.5
targets = numpy.zeros(self.nN.oNodes) -0.99
targets[int (all_values[0])] = 0.99

fx1=numpy.exp(-2*final_inputs)/((1+numpy.exp(-2*final_inputs))*(1+numpy.exp(-2*final_inputs)))
fx2=numpy.exp(-2*hidden_inputs)/((1+numpy.exp(-2*hidden_inputs))*(1+numpy.exp(-2*hidden_inputs)))

self.who += self.lr * numpy.dot((output_errors * fx1),numpy.transpose(hidden_outputs))
self.wih += self.lr * numpy.dot((hidden_errors * fx2),numpy.transpose(inputs))

激活函数为:relu:

部分说明:

关于学习率。过大的学习率导致学习能力丢失,如0.1的学习率在这里过大。

训练1代,达到95.34%的测试识别率。参数为:784/100/10/0.001、rand、4、5、relu.

训练2代,达到96.12%的测试识别率。参数为:784/100/10/0.001、rand、4、5、relu.

训练3代,达到96.65%的测试识别率。参数为:784/100/10/0.001、rand、4、5、relu.

训练4代,达到96.8%的测试识别率。参数为:784/100/10/0.001、rand、4、5、relu.

训练5代,达到96.95%的测试识别率。参数为:784/100/10/0.001、rand、4、5、relu.

训练6代,达到97.08%的测试识别率。参数为:784/100/10/0.001、rand、4、5、relu.

训练7代,达到97.32%的测试识别率。参数为:784/100/10/0.001、rand、4、5、relu.

训练8代,达到97.23%的测试识别率。参数为:784/100/10/0.001、rand、4、5、relu.

调试参数如下:

inputs = numpy.asfarray( all_values [1:])/255.0*0.99+0.01
targets = numpy.zeros(self.nN.oNodes) + 0.01
targets[int (all_values[0])] = 10

final_inputs[final_inputs>0]=1
hidden_inputs[hidden_inputs>0]=1
final_inputs[final_inputs<0]=0
hidden_inputs[hidden_inputs<0]=0
fx1=final_inputs;fx2=hidden_inputs

self.who += self.lr * numpy.dot((output_errors * fx1),numpy.transpose(hidden_outputs))
self.wih += self.lr * numpy.dot((hidden_errors * fx2),numpy.transpose(inputs))

激活函数为:softplus:

训练1代,达到95.62%的测试识别率。参数为:784/100/10/0.001、rand、4、5、softplus.

训练2代,达到96.47%的测试识别率。参数为:784/100/10/0.001、rand、4、5、softplus.

训练3代,达到96.85%的测试识别率。参数为:784/100/10/0.001、rand、4、5、softplus.

训练4代,达到97.06%的测试识别率。参数为:784/100/10/0.001、rand、4、5、softplus.

训练5代,达到97.18%的测试识别率。参数为:784/100/10/0.001、rand、4、5、softplus.

训练6代,达到97.29%的测试识别率。参数为:784/100/10/0.001、rand、4、5、softplus.

训练7代,达到97.34%的测试识别率。参数为:784/100/10/0.001、rand、4、5、softplus.

训练8代,达到97.39%的测试识别率。参数为:784/100/10/0.001、rand、4、5、softplus.

训练9代,达到97.5%的测试识别率。参数为:784/100/10/0.001、rand、4、5、softplus.

训练10代,达到97.54%的测试识别率。参数为:784/100/10/0.001、rand、4、5、softplus.

训练11代,达到97.61%的测试识别率。参数为:784/100/10/0.001、rand、4、5、softplus.

训练12代,达到97.6%的测试识别率。参数为:784/100/10/0.001、rand、4、5、softplus.

调试参数如下:

inputs = numpy.asfarray( all_values [1:])/255.0*0.99+0.01
targets = numpy.zeros(self.nN.oNodes) + 0.01
targets[int (all_values[0])] = 10

fx1=numpy.exp(final_inputs)/(1+numpy.exp(final_inputs))
fx2=numpy.exp(hidden_inputs)/(1+numpy.exp(hidden_inputs))

self.who += self.lr * numpy.dot((output_errors * fx1),numpy.transpose(hidden_outputs))
self.wih += self.lr * numpy.dot((hidden_errors * fx2),numpy.transpose(inputs))

BP神经网络测试MNIST记录的更多相关文章

  1. 机器学习入门-BP神经网络模型及梯度下降法-2017年9月5日14:58:16

    BP(Back Propagation)网络是1985年由Rumelhart和McCelland为首的科学家小组提出,是一种按误差逆传播算法训练的多层前馈网络,是目前应用最广泛的神经网络模型之一. B ...

  2. bp神经网络模型推导与c语言实现(转载)

    转载出处:http://www.cnblogs.com/jzhlin/archive/2012/07/28/bp.html BP 神经网络中的 BP 为 Back  Propagation 的简写,最 ...

  3. BP神经网络模型及梯度下降法

    BP(Back Propagation)网络是1985年由Rumelhart和McCelland为首的科学家小组提出,是一种按误差逆传播算法训练的多层前馈网络,是目前应用最广泛的神经网络模型之一. B ...

  4. BP神经网络模型与学习算法

    一,什么是BP "BP(Back Propagation)网络是1986年由Rumelhart和McCelland为首的科学家小组提出,是一种按误差逆传播算法训练的多层前馈网络,是目前应用最 ...

  5. BP神经网络模型及算法推导

    一,什么是BP "BP(Back Propagation)网络是1986年由Rumelhart和McCelland为首的科学家小组提出,是一种按误差逆传播算法训练的多层前馈网络,是目前应用最 ...

  6. Python实现bp神经网络识别MNIST数据集

    title: "Python实现bp神经网络识别MNIST数据集" date: 2018-06-18T14:01:49+08:00 tags: [""] cat ...

  7. 粒子群优化算法对BP神经网络优化 Matlab实现

    1.粒子群优化算法 粒子群算法(particle swarm optimization,PSO)由Kennedy和Eberhart在1995年提出,该算法模拟鸟集群飞行觅食的行为,鸟之间通过集体的协作 ...

  8. Matlab实现BP神经网络预测(附实例数据及代码)

    BP神经网络介绍 神经网络是机器学习中一种常见的数学模型,通过构建类似于大脑神经突触联接的结构,来进行信息处理.在应用神经网络的过程中,处理信息的单元一般分为三类:输入单元.输出单元和隐含单元. 顾名 ...

  9. BP神经网络公式推导及实现(MNIST)

    BP神经网络的基础介绍见:http://blog.csdn.net/fengbingchun/article/details/50274471,这里主要以公式推导为主. BP神经网络又称为误差反向传播 ...

随机推荐

  1. WAS 手动删除server

    有时候WPS Server上的应用会一直start不起来,尝试卸载也会失败.在这种情况下,我们可以手动删除这个文件. 步骤如下: 1. Stop server 2. 进入$Profile_instal ...

  2. NumPy 排序、条件刷选函数

    NumPy 排序.条件刷选函数 NumPy 提供了多种排序的方法. 这些排序函数实现不同的排序算法,每个排序算法的特征在于执行速度,最坏情况性能,所需的工作空间和算法的稳定性. 下表显示了三种排序算法 ...

  3. TOJ 3850: String Function Encoding

    传送门:http://acm.tzc.edu.cn/acmhome/problemdetail.do?&method=showdetail&id=3850 时间限制(普通/Java): ...

  4. 22. Generate Parentheses (backTracking)

    Given n pairs of parentheses, write a function to generate all combinations of well-formed parenthes ...

  5. Mac安装MySQL数据库

    一 下载及安装社区版MySQL和MySQL Workbench. 二 如果MySQL Workbench无法登陆,则系统偏好设置-MySQL-Initialize Database,选择legacy开 ...

  6. [Java学习]面向对象-super关键字;final关键字

    super关键字 super代表的是当前子类对象中的父类型特征,可以看做是this的一部分.与this不同,不是引用,不存储对象内存地址. super可以用在什么位置 1 可以用在成员方法中.不能用在 ...

  7. Unicode编码字符范围和具体文字

    1)标准CJK文字 http://www.unicode.org/Public/UNIDATA/Unihan.html 2)全角ASCII.全角中英文标点.半宽片假名.半宽平假名.半宽韩文字母:FF0 ...

  8. VTP

    VTP VLAN中继协议(Vlan Trunking Protocol),是CISCO专用协议.VTP负责在VTP域内同步VLAN信息,这样就不必在每个交换机上配置相同的VLAN信息.VTP还提供一种 ...

  9. php解析优酷网上的视频资源去广告

    1.过程原理解析: 一.准备工作 所谓工欲善其事必先利其器,做好破解的准备工作会令你事半功倍. 1.首先准备一个Http抓包工具,PC上推荐Fiddler或者Postman,iOS上推荐Surge 2 ...

  10. Js学习(2)数据类型

    Js共有六种数据类型(ES6又增加了第七种Symbol类型的值): 原始类型:数值,字符串,布尔值 合成类型:对象(object):各种值组成的集合 其他undefined,null 对象又可以分成三 ...