约定:

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

         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. 22. Generate Parentheses (backTracking)

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

  2. 不包含数据和字母的Webshell

        在做php20中的challenge5时学习到了php中可代替数字和字母的符号,悲剧的是这道题没做出来,目前先整理知识点吧555555555555     情况是:很多时候在敏感地方WAF会阻 ...

  3. Chrome格式化JavaScript代码

    很多第三方插件的脚本,是压缩后的代码,甚至时动态加载的,代码只有一行. Chrome提供了格式化脚本代码的功能,方便加断点调试. 1 在Sources面板中,点击脚本名称,打开脚本源码. 2 点击左下 ...

  4. PTA 7-7 六度空间(广搜)

    “六度空间”理论又称作“六度分隔(Six Degrees of Separation)”理论.这个理论可以通俗地阐述为:“你和任何一个陌生人之间所间隔的人不会超过六个,也就是说,最多通过五个人你就能够 ...

  5. 【Linux 线程】常用线程函数复习《三》

    1.关于函数pthraed_join与函数pthraed_detach 在任何一个时间点上,线程是可结合的(joinable)或者是分离的(detached).一个可结合的线程能够被其他线程收回其资源 ...

  6. Django具体操作(四)

    自定义模板语法的标签 首先在django的项目中创建app并且在settings中添加了APP的名称. 在app添加templatetags模块(名字是固定的,也就是说,必须要这样) 如图如何自定义呢 ...

  7. Linux下more命令C语言实现实践 (Unix-Linux编程实践教程)

    1. more第一版 实现基础功能,显示每一页固定24行文本,“q Enter”退出, “Enter” 下一行, “space Enter”下一页. #include<stdio.h> # ...

  8. vmware磁盘空间扩展

    往vmware虚拟机中导入数据库或者文件以后经常出现磁盘空间不够用.这个时候就需要扩展一下磁盘的大小. 笔者本来60G,现在想扩展到100G 命令如下 D:\Program Files (x86)\V ...

  9. Jenkins构建.net项目

    一.环境搭建 1.安装所需软件 Jenkins\JDK\GIT\VS\IIS\nginx(可选) 1.1 安装iis服务: 控制面板—>程序和功能—>启用或关闭windows功能,勾选所有 ...

  10. stl中顺序性容器,关联容器两者粗略解释

    什么是容器 首先,我们必须理解一下什么是容器,在C++ 中容器被定义为:在数据存储上,有一种对象类型,它可以持有其它对象或指向其它对像的指针,这种对象类型就叫做容器.很简单,容器就是保存其它对象的对象 ...