函数公式
y = x*tanh(ln(1+exp(x)))
函数图像
函数作用
激活函数每一点更加平滑,允许更好的信息深入神经网络,负值的时候允许较小的负梯度流入,保证信息不会中断,从而得到更好的准确性和泛化能力。
代码实现
class Mish(Layer):
def __init__(self, **kwargs):
super(Mish, self).__init__(**kwargs)
self.supports_masking = True
def call(self, inputs):
return inputs * K.tanh(K.softplus(inputs))
def get_config(self):
config = super(Mish, self).get_config()
return config
def compute_output_shape(self, input_shape):
return input_shape