Mish

digantamisra98MIT活跃维护

Mish 是一种自正则化、非单调的神经网络激活函数,论文发表于 BMVC 2020,官方仓库提供实现与实验代码,可直接替换 ReLU 等激活函数,用于图像分类、目标检测等任务。

Official Repository for "Mish: A Self Regularized Non-Monotonic Neural Activation Function" [BMVC 2020]

暂无版本1,301star129fork同步于 2026-11-07 07:30 UTC

怎么上手

README 里没有找到可直接复制的安装命令

README 里没有找到可直接复制的安装命令,请到 README 或官方文档查看安装方式。

硬件要求按 README 说明

README 未说明

需要 CUDA
下载:源码 zip·GitHub Releases(安装包)本站不镜像安装包

项目说明

由 README 自动翻译提炼

Mish 激活函数的官方仓库,提供论文、基准测试与各框架实现入口

Mish 是一种自正则化、非单调的神经网络激活函数,论文发表于 BMVC 2020,官方仓库提供实现与实验代码,可直接替换 ReLU 等激活函数,用于图像分类、目标检测等任务。

核心能力

  • 给出 Mish 的数学定义与导数推导
  • 汇总 ImageNet、MS-COCO 等任务上的对比结果
  • 提供 PyTorch 基准测试与预训练模型
  • 记录 Mish 被 PyTorch、TensorFlow 等框架收录的进展

容易踩的坑

README 为论文与实验汇总,未给出可直接安装运行的命令;CUDA 加速版需另装第三方 mish-cuda 仓库

内容由模型根据 README 生成,可能不完整或不准确,以官方文档为准。看原文 README

最近发版

0 个版本

暂无 release 数据(可能没有发版,或尚未同步)。

用户点评

登录用户的真实使用记录,可按版本和硬件筛选
共 0 条

    还没有人点评。第一个说出真实体验的人最有价值。

    README 原文

    未翻译
    • A considerably faster version based on CUDA can be found here - Mish CUDA (All credits to Thomas Brandon for the same)
    • Memory Efficient Experimental version of Mish can be found here
    • Faster variants for Mish and H-Mish by Yashas Samaga can be found here - ConvolutionBuildingBlocks
    • Alternative (experimental improved) variant of H-Mish developed by Páll Haraldsson can be found here - H-Mish (Available in Julia)
    • Variance based initialization method for Mish (experimental) by Federico Andres Lois can be found here - Mish_init

    News/ Media Coverage:

    • (02/2020): Talk on Mish and Non-Linear Dynamics at Sicara is out now. Watch on:
    • (07/2020): CROWN: A comparison of morphology for Mish, Swish and ReLU produced in collaboration with Javier Ideami. Watch on:
    • (12/2020): Talk on From Smooth Activations to Robustness to Catastrophic Forgetting at Weights & Biases Salon is out now. Watch on:
    1. Mish a. Loss landscape
    2. ImageNet Scores
    3. MS-COCO
    4. Variation of Parameter Comparison a. MNIST b. CIFAR10
    5. Significance Level
    6. Results a. Summary of Results (Vision Tasks) b. Summary of Results (Language Tasks)
    7. Try It!
    8. Acknowledgements
    9. Cite this work

    Mish:

    Minimum of f(x) is observed to be ≈-0.30884 at x≈-1.1924 Mish has a parametric order of continuity of: C∞

    Derivative of Mish with respect to Swish and Δ(x) preconditioning:

    Further simplifying:

    Alternative derivative form:

    where:

    We hypothesize the Δ(x) to be exhibiting the properties of a pre-conditioner making the gradient more smoother. Further details are provided in the paper.

    Loss Landscape:

    To visit the interactive Loss Landscape visualizer, click here.

    Loss landscape visualizations for a ResNet-20 for CIFAR 10 using ReLU, Mish and Swish (from L-R) for 200 epochs training:

    Mish provides much better accuracy, overall lower loss, smoother and well conditioned easy-to-optimize loss landscape as compared to both Swish and ReLU. For all loss landscape visualizations please visit this readme.

    We also investigate the output landscape of randomly initialized neural networks as shown below. Mish has a much smoother profile than ReLU.

    ImageNet Scores:

    PWC

    For Installing DarkNet framework, please refer to darknet(Alexey AB)

    For PyTorch based ImageNet scores, please refer to this readme

    NetworkActivationTop-1 AccuracyTop-5 AccuracycfgWeightsHardware
    ResNet-50Mish74.244%92.406%cfgweightsAWS p3.16x large, 8 Tesla V100
    DarkNet-53Mish77.01%93.75%cfgweightsAWS p3.16x large, 8 Tesla V100
    DenseNet-201Mish76.584%93.47%cfgweightsAWS p3.16x large, 8 Tesla V100
    ResNext-50Mish77.182%93.318%cfgweightsAWS p3.16x large, 8 Tesla V100
    NetworkActivationTop-1 AccuracyTop-5 Accuracy
    CSPResNet-50Leaky ReLU77.1%94.1%
    CSPResNet-50Mish78.1%94.2%
    Pelee NetLeaky ReLU70.7%90%
    Pelee NetMish71.4%90.4%
    Pelee NetSwish71.5%90.7%
    CSPPelee NetLeaky ReLU70.9%90.2%
    CSPPelee NetMish71.2%90.3%

    Results on CSPResNext-50:

    MixUpCutMixMosaicBlurLabel SmoothingLeaky ReLUSwishMishTop -1 AccuracyTop-5 Accuracycfgweights
    :heavy_check_mark:77.9%(=)94%(=)
    :heavy_check_mark::heavy_check_mark:77.2%(-)94%(=)
    :heavy_check_mark::heavy_check_mark:78%(+)94.3%(+)
    :heavy_check_mark::heavy_check_mark:78.1%(+)94.5%(+)
    :heavy_check_mark::heavy_check_mark:77.5%(-)93.8%(-)
    :heavy_check_mark::heavy_check_mark:78.1%(+)94.4%(+)
    :heavy_check_mark:64.5%(-)86%(-)
    :heavy_check_mark:78.9%(+)94.5%(+)
    :heavy_check_mark::heavy_check_mark::heavy_check_mark::heavy_check_mark:78.5%(+)94.8%(+)
    :heavy_check_mark::heavy_check_mark::heavy_check_mark::heavy_check_mark:79.8%(+)95.2%(+)cfgweights

    Results on CSPResNet-50:

    CutMixMosaicLabel SmoothingLeaky ReLUMishTop -1 AccuracyTop-5 Accuracycfgweights
    :heavy_check_mark:76.6%(=)93.3%(=)
    :heavy_check_mark::heavy_check_mark::heavy_check_mark::heavy_check_mark:77.1%(+)94.1%(+)
    :heavy_check_mark::heavy_check_mark::heavy_check_mark::heavy_check_mark:78.1%(+)94.2%(+)cfgweights

    Results on CSPDarkNet-53:

    CutMixMosaicLabel SmoothingLeaky ReLUMishTop -1 AccuracyTop-5 Accuracycfgweights
    :heavy_check_mark:77.2%(=)93.6%(=)
    :heavy_check_mark::heavy_check_mark::heavy_check_mark::heavy_check_mark:77.8%(+)94.4%(+)
    :heavy_check_mark::heavy_check_mark::heavy_check_mark::heavy_check_mark:78.7%(+)94.8%(+)cfgweights

    Results on SpineNet-49:

    CutMixMosaicLabel SmoothingReLUSwishMishTop -1 AccuracyTop-5 Accuracycfgweights
    :heavy_check_mark:77%(=)93.3%(=)--
    :heavy_check_mark::heavy_check_mark:78.1%(+)94%(+)--
    :heavy_check_mark::heavy_check_mark::heavy_check_mark::heavy_check_mark:78.3%(+)94.6%(+)--

    MS-COCO:

    PWC PWC

    For PyTorch based MS-COCO scores, please refer to this readme

    ModelMishAP50...95mAP50CPU - 90 Watt - FP32 (Intel Core i7-6700K, 4GHz, 8 logical cores) OpenCV-DLIE, FPSVPU-2 Watt- FP16 (Intel MyriadX) OpenCV-DLIE, FPSGPU-175 Watt- FP32/16 (Nvidia GeForce RTX 2070) DarkNet-cuDNN, FPS
    CSPDarkNet-53 (512 x 512)42.4%64.5%3.51.2343
    CSPDarkNet-53 (512 x 512):heavy_check_mark:43%64.9%--41
    CSPDarkNet-53 (608 x 608):heavy_check_mark:43.5%65.7%--26
    ArchitectureMishCutMixMosaicLabel SmoothingSizeAPAP50AP75
    CSPResNext50-PANet-SPP512 x 51242.4%64.4%45.9%
    CSPResNext50-PANet-SPP:heavy_check_mark::heavy_check_mark::heavy_check_mark:512 x 51242.3%64.3%45.7%
    CSPResNext50-PANet-SPP:heavy_check_mark::heavy_check_mark::heavy_check_mark::heavy_check_mark:512 x 51242.3%64.2%45.8%
    CSPDarkNet53-PANet-SPP:heavy_check_mark::heavy_check_mark::heavy_check_mark:512 x 51242.4%64.5%46%
    CSPDarkNet53-PANet-SPP:heavy_check_mark::heavy_check_mark::heavy_check_mark::heavy_check_mark:512 x 51243%64.9%46.5%

    Credits to AlexeyAB, Wong Kin-Yiu and Glenn Jocher for all the help with benchmarking MS-COCO and ImageNet.

    Variation of Parameter Comparison:

    MNIST:

    To observe how increasing the number of layers in a network while maintaining other parameters constant affect the test accuracy, fully connected networks of varying depths on MNIST, with each layer having 500 neurons were trained. Residual Connections were not used because they enable the training of arbitrarily deep networks. BatchNorm was used to lessen the dependence on initialization along with a dropout of 25%. The network is optimized using SGD on a batch size of 128, and for fair comparison, the same learning rates for each activation function was maintained. In the experiments, all 3 activations maintained nearly the same test accuracy for 15 layered Network. Increasing number of layers from 15 gradually resulted in a sharp decrease in test accuracy for Swish and ReLU, however, Mish outperformed them both in large networks where optimization becomes difficult.

    The consistency of Mish providing better test top-1 accuracy as compared to Swish and ReLU was also observed by increasing Batch Size for a ResNet v2-20 on CIFAR-10 for 50 epochs while keeping all other network parameters to be constant for fair comparison.

    Gaussian Noise with varying standard deviation was added to the input in case of MNIST classification using a simple conv net to observe the trend in decreasing test top-1 accuracy for Mish and compare it to that of ReLU and Swish. Mish mostly maintained a consistent lead over that of Swish and ReLU (Less than ReLU in just 1 instance and less than Swish in 3 instance) as shown below. The trend for test loss was also observed following the same procedure. (Mish has better loss than both Swish and ReLU except in 1 instance)

    CIFAR10:

    Significance Level:

    The P-values were computed for different activation functions in comparison to that of Mish on terms of Top-1 Testing Accuracy of a Squeeze Net Model on CIFAR-10 for 50 epochs for 23 runs using Adam Optimizer at a Learning Rate of 0.001 and Batch Size of 128. It was observed that Mish beats most of the activation functions at a high significance level in the 23 runs, specifically it beats ReLU at a high significance of P < 0.0001. Mish also had a comparatively lower standard deviation across 23 runs which proves the consistency of performance for Mish.

    Activation FunctionMean AccuracyMean LossStandard Deviation of AccuracyP-valueCohen's d Score95% CI
    Mish87.48%4.13%0.3967---
    Swish-187.32%4.22%0.414P = 0.19730.386-0.3975 to 0.0844
    E-Swish (β=1.75)87.49%4.156%0.411P = 0.90750.034444-0.2261 to 0.2539
    GELU87.37%4.339%0.472P = 0.40030.250468-0.3682 to 0.1499
    ReLU86.66%4.398%0.584P < 0.00011.645536-1.1179 to -0.5247
    ELU(α=1.0)86.41%4.211%0.3371P < 0.00012.918232-1.2931 to -0.8556
    Leaky ReLU(α=0.3)86.85%4.112%0.4569P < 0.00011.47632-0.8860 to -0.3774
    RReLU86.87%4.138%0.4478P < 0.00011.444091-0.8623 to -0.3595
    SELU83.91%4.831%0.5995P < 0.00017.020812-3.8713 to -3.2670
    SoftPlus(β = 1)83.004%5.546%1.4015P < 0.00014.345453-4.7778 to -4.1735
    HardShrink(λ = 0.5)75.03%7.231%0.98345P < 0.000116.601747-12.8948 to -12.0035
    Hardtanh82.78%5.209%0.4491P < 0.000111.093842-4.9522 to -4.4486
    LogSigmoid81.98%5.705%1.6751P < 0.00014.517156-6.2221 to -4.7753
    PReLU85.66%5.101%2.2406P = 0.00041.128135-2.7715 to -0.8590
    ReLU686.75%4.355%0.4501P < 0.00011.711482-0.9782 to -0.4740
    CELU(α=1.0)86.23%4.243%0.50941P < 0.00012.741669-1.5231 to -0.9804
    Sigmoid74.82%8.127%5.7662P < 0.00013.098289-15.0915 to -10.2337
    Softshrink(λ = 0.5)82.35%5.4915%0.71959P < 0.00018.830541-5.4762 to -4.7856
    Tanhshrink82.35%5.446%0.94508P < 0.00017.083564-5.5646 to -4.7032
    Tanh83.15%5.161%0.6887P < 0.00017.700198-4.6618 to -3.9938
    Softsign82.66%5.258%0.6697P < 0.00018.761157-5.1493 to -4.4951
    Aria-2(β = 1, α=1.5)81.31%6.0021%2.35475P < 0.00013.655362-7.1757 to -5.1687
    Bent's Identity85.03%4.531%0.60404P < 0.00014.80211-2.7576 to -2.1502
    SQNL83.44%5.015%0.46819P < 0.00019.317237-4.3009 to -3.7852
    ELisH87.38%4.288%0.47731P = 0.42830.235784-0.3643 to 0.1573
    Hard ELisH85.89%4.431%0.62245P < 0.00013.048849-1.9015 to -1.2811
    SReLU85.05%4.541%0.5826P < 0.00014.883831-2.7306 to -2.1381
    ISRU (α=1.0)86.85%4.669%0.1106P < 0.00015.302987-4.4855 to -3.5815
    Flatten T-Swish86.93%4.459%0.40047P < 0.00011.378742-0.7865 to -0.3127
    SineReLU (ε = 0.001)86.48%4.396%0.88062P < 0.00011.461675-1.4041 to -0.5924
    Weighted Tanh (Weight = 1.7145)80.66%5.985%1.19868P < 0.00017.638298-7.3502 to -6.2890
    LeCun's Tanh82.72%5.322%0.58256P < 0.00019.551812-5.0566 to -4.4642
    Soft Clipping (α=0.5)55.21%18.518%10.831994P < 0.00014.210373-36.8255 to -27.7154
    ISRLU (α=1.0)86.69%4.231%0.5788P < 0.00011.572874-1.0753 to -0.4856

    Values rounded up which might cause slight deviation in the statistical values reproduced from these tests

    Results:

    PWC PWC

    News: Ajay Arasanipalai recently submitted benchmark for CIFAR-10 training for the Stanford DAWN Benchmark using a Custom ResNet-9 + Mish which achieved 94.05% accuracy in just 10.7 seconds in 14 epochs on the HAL Computing Cluster. This is the current fastest training of CIFAR-10 in 4 GPUs and 2nd fastest training of CIFAR-10 overall in the world.

    Summary of Results (Vision Tasks):

    Comparison is done based on the high priority metric, for image classification the Top-1 Accuracy while for Generative Networks and Image Segmentation the Loss Metric. Therefore, for the latter, Mish > Baseline is indicative of better loss and vice versa. For Embeddings, the AUC metric is considered.

    Activation FunctionMish > Baseline ModelMish < Baseline Model
    ReLU5520
    Swish-15322
    SELU261
    Sigmoid240
    TanH240
    HardShrink(λ = 0.5)230
    Tanhshrink230
    PReLU(Default Parameters)232
    Softsign221
    Softshrink (λ = 0.5)221
    Hardtanh212
    ELU(α=1.0)217
    LogSigmoid204
    GELU193
    E-Swish (β=1.75)197
    CELU(α=1.0)185
    SoftPlus(β = 1)177
    Leaky ReLU(α=0.3)178
    Aria-2(β = 1, α=1.5)162
    ReLU6168
    SQNL131
    Weighted TanH (Weight = 1.7145)121
    RReLU1211
    ISRU (α=1.0)111
    Le Cun's TanH102
    Bent's Identity105
    Hard ELisH91
    Flatten T-Swish93
    Soft Clipping (α=0.5)93
    SineReLU (ε = 0.001)94
    ISRLU (α=1.0)94
    ELisH73
    SReLU76
    Hard Sigmoid10
    Thresholded ReLU(θ=1.0)10

    Summary of Results (Language Tasks):

    Comparison is done based on the best metric score (Test accuracy) across 3 runs.

    Activation FunctionMish > Baseline ModelMish < Baseline Model
    Penalized TanH50
    ELU50
    Sigmoid50
    SReLU40
    TanH41
    Swish32
    ReLU23
    Leaky ReLU23
    GELU12

    Try It!

    TorchDarkNetJuliaFastAITensorFlowKerasCUDA
    SourceSourceSourceSourceSourceSourceSource

    Thanks to all the people who have helped and supported me massively through this project who include:

    1. Alexandra Deis
    2. Alexey Bochkovskiy
    3. Chien-Yao Wang
    4. Thomas Brandon
    5. Less Wright
    6. Manjunath Bhat
    7. Ajay Uppili Arasanipalai
    8. Federico Lois
    9. Javier Ideami
    10. Ioannis Anifantakis
    11. George Christopoulos
    12. Miklos Toth

    And many more including the Fast AI community, Weights and Biases Community, TensorFlow Addons team, SpaCy/Thinc team, Sicara team, Udacity scholarships team to name a few. Apologies if I missed out anyone.

    Cite this work:

    @article{misra2019mish,
      title={Mish: A self regularized non-monotonic neural activation function},
      author={Misra, Diganta},
      journal={arXiv preprint arXiv:1908.08681},
      year={2019}
    }