神经网络不同激活函数比较--读《Understanding the difficulty of training deep feedforward neural networks》

  various activation functions performance
  这篇论文比较了不同激活函数的中间各隐层输出值分布、梯度值分布、测试准确度等,从上图看出,至少在mnist和cifar10测试集下,看起来tanh和softsign都要好于sigmoid。

Read More

神经网络参数优化

1.学习缓慢问题

  激活函数采用sigmoid,代价函数采用二次项时,会存在学习缓慢即梯度下降较慢的问题。对此,可以使用交叉熵代价函数,或者使用ReLU、Softmax激活函数等,如下图。    
  

Read More

回归初心-读《Deep Big Simple Neural Nets Excel on Hand-written Digit Recognition》

  Mnist做为手写数字识别的基准数据集,one Hidden Layer Perceptron已可以取得较好性能(Error rate 2%-5%),更有诸多新型网络结构如CNN、RNN不断改善性能(Error rate 1%以下)。
  而这篇论文,则进一步回归初心,挖掘纯粹MLP的性能,通过可变学习速率,旋转、畸变数据以扩展训练集,更多隐藏层等,观察性能如下:
  MLP performance
  
  没有花拳绣腿,纯粹的MLP,同样可以得到错误率0.5%以下的性能,唯一的缺点就是计算量,方法上简单、粗暴、有效!

Read More

数据科学家路线图

网上搜到的,感谢原作者。
  

Read More

LeNet简介

  LeNet做为CNN的经典网络结构,如下。
  LeNet-5架构
  S2到C3的映射
  LeNet-5参数量

Read More

如何改进深度学习的性能?

摘自:How To Improve Deep Learning Performance

Read More

链家大数据使用到的机器学习算法

摘自: InfoQ对链家网大数据架构师蔡白银的访谈

Read More

BP算法摘要与代码分析

  反向传播算法是神经网络中的重要组成部分,是对权重和偏置变化影响代价函数过程的理解,目标是计算代价函数C 分别关于w 和b的偏导数,从而更新w、b,影响前向过程,最小化代价函数。
  神经网络结构示意图
  BP算法的4个方程
  公式BP1与BP2在nielsen的书Neural Networks and Deep Learning中已有证明,下面补充BP3与BP4的证明:
  BP3 and BP4 Proof
  BP算法过程如下:
  BP算法过程
  在m大小的mini_batch内进行一次梯度更新,过程如下:
  mini_batch内的一次梯度更新   
  
  以mnist识别,三层网络[784,30,10]为例,nielsen的书中代码如下,添加了部分注释:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
class Network(object):
def update_mini_batch(self, mini_batch, eta):
"""Update the network's weights and biases by applying
gradient descent using backpropagation to a single mini batch.
The ``mini_batch`` is a list of tuples ``(x, y)``, and ``eta``
is the learning rate."""
nabla_b = [np.zeros(b.shape) for b in self.biases] # idx0:30*1; idx1:10*1
nabla_w = [np.zeros(w.shape) for w in self.weights] # idx0:30*784; idx1:10*30
for x, y in mini_batch: # loop 10, BP calc and update gradient 10 times
delta_nabla_b, delta_nabla_w = self.backprop(x, y) # delta b,delta w , their dimension is same as b,w
nabla_b = [nb+dnb for nb, dnb in zip(nabla_b, delta_nabla_b)] # bj:zip two column vector, but list output row by row
nabla_w = [nw+dnw for nw, dnw in zip(nabla_w, delta_nabla_w)]
self.weights = [w-(eta/len(mini_batch))*nw
for w, nw in zip(self.weights, nabla_w)] # update w, sum the average 10 changes
self.biases = [b-(eta/len(mini_batch))*nb
for b, nb in zip(self.biases, nabla_b)] # update b,
def backprop(self, x, y):
"""Return a tuple ``(nabla_b, nabla_w)`` representing the
gradient for the cost function C_x. ``nabla_b`` and
``nabla_w`` are layer-by-layer lists of numpy arrays, similar
to ``self.biases`` and ``self.weights``."""
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) # middle variable z before sigmoid, z1,z2
activation = sigmoid(z)
activations.append(activation) # activation output, x, s1,s2
# backward pass
delta = self.cost_derivative(activations[-1], y) * \ # C=1/2 *(s2-y).^2, so dc/ds=(s2-y)
sigmoid_prime(zs[-1]) # delta 10*1
nabla_b[-1] = delta
nabla_w[-1] = np.dot(delta, activations[-2].transpose()) # s1: 30*1, s1':1*30; delta:10*1, dot:10*30
# 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) #sp1: dz1, 30*1
delta = np.dot(self.weights[-l+1].transpose(), delta) * sp # w[1]: 10*30; delta update to 30*1
nabla_b[-l] = delta
nabla_w[-l] = np.dot(delta, activations[-l-1].transpose()) # delta 30*1, l=2, s0=x,784*1, ze w[-2]=w[0]=30*784
return (nabla_b, nabla_w)
def cost_derivative(self, output_activations, y):
"""Return the vector of partial derivatives \partial C_x /
\partial a for the output activations."""
return (output_activations-y)

Read More

Deep Dream 初体验 - 神经网络模型眼中的世界

  2015年年中Google发布了Deep Dream的新闻,展示了google神经网络模型对输入图片的理解,类似于“深度盗梦”,并引发了后续的艺术风格作画。
  Deep Dream,其原理并不是尽可能地去正确识别图片对象,而是在网络识别对象模式的中间过程时,忽略确认操作,这样就解除了最小梯度限制,Test loss不再越来越小;而是让网络在已识别出的错误对象上,继续去强化认知和理解,最终找出了新图像的模板,而这迥异于原图的风格,形成了类似于创造梦境的效果。
  Google的示例如下:
  google deep dream example 1
  google deep dream example 2 - 原图
  google deep dream example 2 - 转换图
  google deep dream example 3 - 原图
  google deep dream example 3 - 转换图   

Read More

机器学习相关的Awesome系列

原文链接:[原创]机器学习相关的Awesome系列

Read More