Caffe激活层参数详解

本文详细解析了Caffe框架中常见的激活函数,包括Sigmoid、ReLU、Leaky ReLU、Tanh、Absolute Value及Power函数,讨论了它们的数学公式与特点,尤其强调了ReLU在深度学习中的广泛使用及其优势。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

一、引言

       在激活层中,对输入数据进行激活操作(实际上就是一种函数变换),是逐元素进行运算的。从bottom 得到一个 blob 数据输入,运算后从 top 输出一个 blob 数据。在运算过程中,没有改变数据的大小,即输入数据和输出数据大小是相等的。常用的激活函数由 sigmoid、tanh、relu 等,下文展开讲解。

二、 Sigmoid 激活函数

       对于每个输入数据,利用 Sigmoid 函数执行操作。这种层设置比较简单,没有额外的参数。

      Sigmoid函数公式:      S(x) = 1 / (1+e^{-x})

typeSigmoid
layer {
  name: "encode1neuron"
  bottom: "encode1"
  top: "encode1neuron"
  type: "Sigmoid"
}

三、 ReLu / Rectified-Linear and Leaky-ReLu 激活函数

       ReLu 是目前使用最多的激活函数,主要因为其收敛更快,并且能保持同样效果。ReLu层支持 in-place 计算,这意味着 bottom的输出和输入相同以避免内存的消耗。

       ReLu 函数: f(x) = max( x, 0)  

typeReLu
negative_slope默认为0。如果设置了这个值,当数据为负数时,就不再设置为0,而是用原始数据乘以 negative_slope。
layer {
  name: "relu1"
  type: "ReLU"
  bottom: "pool1"
  top: "pool1"
}

四、 Tanh / Hyperbolic Tangent

        利用双曲正切函数对数据进行变换。

        Tanh函数公式:tanh (x) = \frac{sinh x}{ cosh x} = (e^{x} - e^{-x}) / (e^{x} + e^{-x})

typeTanH
layer {
  name: "layer"
  bottom: "in"
  top: "out"
  type: "TanH"
}

五、Absolute Value 激活函数

       求每个输入数据的绝对值。

       函数公式: f(x) = Abs(x)   层类型: AbsVal

layer {
  name: "layer"
  bottom: "in"
  top: "out"
  type: "AbsVal"
}

六、 Power 激活函数

       对每一个输入数据进行幂运算。

       函数公式:f(x) = (shift + scale * x) ^ power 

typePower
power默认为1
scale默认为1
shift默认为0
layer {
  name: "layer"
  bottom: "in"
  top: "out"
  type: "Power"
  power_param {
    power: 2
    scale: 1
    shift: 0
  }
}

七、BNLL 激活函数

       Binomial Normal Log Likelihood 的简称。

       函数公式: f(x) = log ( 1 + exp(x) )

       层类型: BNLL

layer {
  name: "layer"
  bottom: "in"
  top: "out"
  type: "BNLL"
}

 

 

 

 

 

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值