深度学习基础(三)—— 权值矩阵的初始化

权值矩阵初始化的方式与激励函数的类型有关:

对于 隐层 i

  • tanh 型激励函数

    对称区间上的均匀分布 [6fanin+fanout,6fanin+fanout]

    • sigmoid 型激励函数

      对称区间上的均匀分布 [46fanin+fanout,46fanin+fanout]

    • 其中 fanin 为第 i1 层的神经元的数目,则 fanout 为第 i <script type="math/tex" id="MathJax-Element-27">i</script> 层的神经元的数目。

      这种权值初始化机制确保你了,在模型训练的初期,信息很容易前向传播(传播的是激励activation)和后向传播(传播的是梯度gradients)。

      1. 普通全连接层

      class HiddenLayer(object):
          def __init__(self, rng, inpt, 
                       n_in, n_out, W=None, b=None, activation=T.tanh):
               self.inpt = inpt
               if not W:
                   W_values = np.asarray(
                       rng.uniform(
                           low=-np.sqrt(6/(n_in + n_out)),
                           high=np.sqrt(6/(n_in + n_out)),
                           size=(n_in, n_out)
                       ),
                       dtype=theano.config.floatX
                   )
                   if activation == T.nnet.sigmoid:
                       W_values *= 4
                   W = theano.shared(value=W_values, name='W', borrow=True)
              if not b:
                  b_values = np.asarray(np.zeros(n_out,), dtype=theano.config.floatX)
                  b = theano.shared(value=b, name='b', borrow=True)
              self.W = W
              self.b = b

      2. 卷积层

      Convolutional Neural Networks (LeNet)

      filter_shape,是长度为 4 的 tuple:

      • number of filters,
      • num input feature maps,
      • filter height,
      • filter width
      fan_in = np.prod(filter_shape[1:])
      fan_out = filter_shape[0]*np.prod(filter_shape[2:])
              # 把池化层也包括在内;
              # fan_out = flter_shape[0]*np.prod(filter_shape[2:])//poolsize

      References

      Understanding the difficulty of training deep feedforward neuralnetworks

      Going from logistic regression to MLP

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

五道口纳什

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值