
权重更新:个中l为进修率
偏向更新:

3、终止前提
侧重的更新低于某个阈值;
猜测的缺点率低于某个阈值;
达到预设必定的轮回次数;
4、非线性转化函数
膳绫擎提到的非线性转化函数f,一般情况下可以用两种函数:
(1)tanh(x)函数:
- tanh(x)=sinh(x)/cosh(x)
- sinh(x)=(exp(x)-exp(-x))/2
- cosh(x)=(exp(x)+exp(-x))/2
(2)逻辑函数,本文膳绫擎用的就是逻辑函数
五、BP神经收集的python实现
须要先导入numpy模块
- import numpy as np
定义非线性转化函数,因为还须要用到给函数的导数情势,是以一路定义
- def tanh(x):
- return np.tanh(x)
- def tanh_deriv(x):
- return 1.0 - np.tanh(x)*np.tanh(x)
- def logistic(x):
- return 1/(1 + np.exp(-x))
- def logistic_derivative(x):
- return logistic(x)*(1-logistic(x))
设计BP神经收集的情势(几层,每层若干单位个数),用到了面向对象,主如果选择哪种非线性函数,以及初始化权重。layers是一个list,琅绫擎包含每一层的单位个数。
- class NeuralNetwork:
- def __init__(self, layers, activation='tanh'):
- """
- :param layers: A list containing the number of units in each layer.
- Should be at least two values
- :param activation: The activation function to be used. Can be
- "logistic" or "tanh"
- """
- if activation == 'logistic':
- self.activation = logistic
- self.activation_deriv = logistic_derivative
- elif activation == 'tanh':
推荐阅读
【技巧沙龙】AI开辟者拭魅战营-7分钟打造1个定制技能。7月22号,我们等你一路! 定义强化进修是机械进修的一个重要分支,是多学科多范畴交叉的一个产品,它的本质是解决 decision making>>>详细阅读
本文标题:神经网络理论基础及Python实现
地址:http://www.17bianji.com/lsqh/36265.html
1/2 1

网友点评
精彩导读
科技快报
品牌展示