Keras编写 Mish 激活函数

Mish激活函数
网上给出的Mish激活函数多是pytorch写的,今天折腾了一会儿写了keras框架下的Mish函数。如有不对,请大家指正:

from keras.engine.base_layer import Layer
class Mish(Layer):
    def __init__(self):
        super().__init__()

    def forward(self, x):
        '''
        Forward pass of the function.
        '''
        return x * (K.tanh(K.softplus(x)))

def bn_mish(input):
     return Mish()(BatchNormalization(axis=CHANNEL_AXIS)(input))
发布了34 篇原创文章 · 获赞 17 · 访问量 2万+

猜你喜欢

转载自blog.csdn.net/weixin_39393430/article/details/104845088