基础概念
- 来源 : 《神经网络与深度学习》(Neuralnetworks and Deeplearning)
常用名词
-
偏置 ( bias )
-
阈值 ( threshold )
-
梯度下降法( gradient descent )
-
平方损失( quadratic cost )
-
向量化(vectorizing)
-
批梯度下降 ( Batch gradient descent )
-
随机梯度下降 ( stochastic gradient descent )
-
小批的梯度下降 ( mini-batch gradient decent )
mini batch 下的梯度下降中降样本被分为一个个子集进行梯度下降 -
奇异值分解( Singular Value Decomposition )
感知机规则
Sigmoid神经元
-
Sigmoid多存在于分类评定模型(Logit model),逻辑回(Logistic regression)模型
-
使用Sigmoid主要是避免阈值效应,减小微小变化对结果的影响.
梯度下降
代价函数
衡量我们当前取得的结果距离目标结果的好坏程度
数字越大说明训练效果越差
迭代过程
n为学习率(learning rate)
实现代码
weights = [w-(eta/len(mini_batch))*nw for w,nw in zip(weights, nabla_w)]
反向传播算法
四个基本公式
实现代码
def backprop(self, x, y):
"""
反向传播计算梯度
:param x: 单个输入
:param y: 期望输出
:return: 梯度
"""
nabla_b = [np.zeros(b.shape) for b in self.biases]
nabla_w = [np.zeros(w.shape) for w in self.weights]
activation = x
activations = [np.array(x)]
zs = []
for b, w in zip(self.biases, self.weights):
z = np.dot(w, activation)+b
zs.append(z)
activation = sigmoid(z)
activations.append(activation)
delta = self.cost_derivative(activations[-1], y) * sigmoid_prime(zs[-1])
nabla_b[-1] = delta
nabla_w[-1] = np.dot(delta, activations[-2].transpose())
for l in range(2, self.num_layers):
z = zs[-l]
delta = np.dot(
self.weights[-l+1].transpose(), delta) * sigmoid_prime(z)
nabla_b[-l] = delta
nabla_w[-l] = np.dot(delta, activations[-l-1].transpose())
return nabla_b, nabla_w
交叉熵代价函数
- 函数定义
n是训练数据个数 - 化简过程
通用结果
线性代数
施密特正交化
![](DLmath/8.jpg)
![](DLmath/9.jpg)
向量范数
- L0范数 : 向量中非零元素个数
- L1范数 : 绝对值之和,曼哈顿距离.
- l2范数 : 欧几里得距离.
- l正无穷 : 绝对值最大值.
- l负无穷 : min.
矩阵范数
矩阵范数应用 : 推荐系统正则化.