神经网络与深度学习笔记(三)python 实现反向传播算法
来源:互联网 发布:wps2009筛选重复数据 编辑:程序博客网 时间:2024/06/03 14:55
1、BP方程式
2、计算步骤
3、代码
def backprop(self, x, y):"""Return a tuple "(nabla_b, nabla_w)" representing thegradient for the cost function C_x. "nabla_b" and"nabla_w" are layer-by-layer lists of numpy arrays, similarto "self.biases" and "self.weights".""" # 分配 w 、b 的空间 nabla_b = [np.zeros(b.shape) for b in self.biases] nabla_w = [np.zeros(w.shape) for w in self.weights]# feedforward activation = x activations = [x] # list to store all the activations, layer by layer zs = [] # list to store all the z vectors, layer by layer for b, w in zip(self.biases, self.weights): z = np.dot(w, activation)+b zs.append(z) activation = sigmoid(z) activations.append(activation)# backward pass delta = self.cost_derivative(activations[-1], y) * \ sigmoid_prime(zs[-1]) nabla_b[-1] = delta nabla_w[-1] = np.dot(delta, activations[-2].transpose())# Note that the variable l in the loop below is used a little # differently to the notation in Chapter 2 of the book. Here, # l = 1 means the last layer of neurons, l = 2 is the# second-last layer, and so on. It's a renumbering of the# scheme in the book, used here to take advantage of the fact # that Python can use negative indices in lists. for l in xrange(2, self.num_layers): z = zs[-l] sp = sigmoid_prime(z) delta = np.dot(self.weights[-l+1].transpose(), delta) * sp nabla_b[-l] = delta nabla_w[-l] = np.dot(delta, activations[-l-1].transpose()) return (nabla_b, nabla_w)
阅读全文
0 0
- 神经网络与深度学习笔记(三)python 实现反向传播算法
- July深度学习笔记之神经网络与反向传播算法
- 神经网络与深度学习 笔记3 反向传播算法
- 神经网络与深度学习(三)——反向传播算法
- 深度学习笔记三:反向传播(backpropagation)算法
- 神经网络与深度学习笔记——第2章 反向传播算法
- 神经网络与深度学习学习笔记:正向传播与反向传播(未完)
- Python实现人工神经网络(反向传播算法)
- Deep Learning 学习笔记(三):神经网络反向传播算法推导
- 神经网络与深度学习第四天读书笔记-----迈向深度学习:反向传播算法
- <深度学习系列>基于numpy和python的反向传播算法的实现与分析
- 深度学习笔记2:反向传播算法
- 深度学习笔记(二)---反向传播算法
- 神经网络和深度学习(三)——反向传播工作原理
- 深度神经网络(DNN)反向传播算法(BP)
- 深度神经网络(DNN)反向传播算法(BP)
- 深度神经网络(DNN)反向传播算法(BP)
- 深度神经网络(DNN)反向传播算法(BP)
- JMeter测试工具(一)下载及环境配置
- 为什么要搭建个人网站
- Counting Divisors HDU
- 插入数据到excle的指定位置
- JQuery
- 神经网络与深度学习笔记(三)python 实现反向传播算法
- Terark面试总结
- HDU3265 Posters(线段树+扫描线——面积交)
- Tokenizer类的框架
- 排序算法总结
- 前端常用网站
- 求次数
- Eclipse Oxygen集成的Gradle的使用
- java读取xml