详解激活函数Mish

8 篇文章 2 订阅
5 篇文章 0 订阅

激活函数Mish


  对YOLO有了解的或者从事人工智能的相关人员,都知道前段时间yolov4出来了,而且相对于yolov3在精度上有一个质的飞跃,让人感觉匪夷所思,于是在好奇心的驱使下,了解了一下yolov4;与yolov3相比较,主要有几个不同点:网络层更深了、激活函数将leakyRelu替换为mish、采用了SPP(空间金字塔池化)等。下面主要学习一下激活函数mish:
  在论文“ Mish: A Self Regularized Non-Monotonic Neural Activation Function”中, Diganta Misra有这样的描述:“Over the years of theoretical research, many activation functions have been proposed, however, only a few are widely used in mostly all applications which include ReLU (Rectified Linear Unit), TanH (Tan Hyperbolic), Sigmoid, Leaky ReLU and Swish. ” 和 “For instance, in
Squeeze Excite Net- 18 for CIFAR 100 classification, the network with Mish had an increase in Top-1 test accuracy by 0.494% and 1.671% as compared to the same network with Swish and ReLU respectively”。大概意思是,现在仍被广泛应用的激活函数有ReLU、TanH、Sigmoid、Leaky ReLU 和 Swish;而在这篇论文中,提出了一个新的激活函数Mish,并且经过验证得出一个结论mish的精度比Swish高0.494%,比ReLU高1.671%。
Mish的公式: f ( x ) = x ∗ t a n h ( s o f t p l u s ( x ) ) f(x)=x*tanh(softplus(x)) f(x)=xtanh(softplus(x))
Mish公式分步合并:

Mish的输入数据为x
1. softplus: y1 = ln(1+e^x)
2. tanh:     y2 = (e^y1 - e^(y1 * -1)) / (e^y1 - e^(y1 * -1))
3. Mish:     y  = y2 * x

下图为,Mish和其他常用的激活函数的函数对比,从中可以总结出Mish和Swish比较相似的:
在这里插入图片描述

常见激活函数对比

下图主要说明了,经过ReLU、Swish、Mish三个不同激活函数后的输出对比,从中可以发现Mish相对于ReLU、Swish显得更加平滑一些。
在这里插入图片描述

ReLU、Swish、Mish的结果对比

在这里插入图片描述

Mish的属性

代码事例

import numpy as np
import matplotlib.pyplot as plt

def mish_fun(x):
    tmp = np.log(1 + np.exp(x))
    tmp = np.tanh(tmp)
    tmp = tmp * x
    return tmp

if __name__ == '__main__':

    input = np.array([-15, -11, -10.5, -10, -4.5, -4, -3.5, -3, -2.5, -2, -1.5, -1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 10.5])
    output = mish_fun(input)
    plt.plot(input, output)
    plt.show()
    print(input)
    print(output)

在这里插入图片描述

Mish激活函数
  • 5
    点赞
  • 34
    收藏
    觉得还不错? 一键收藏
  • 3
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 3
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值