feishen29's picture
Upload 179 files
29d49a9 verified
raw
history blame contribute delete
483 Bytes
"""
Script based on:
Wang, Xueliang, Honge Ren, and Achuan Wang.
"Smish: A Novel Activation Function for Deep Learning Methods.
" Electronics 11.4 (2022): 540.
"""
# import pytorch
import torch
@torch.jit.script
def smish(input):
"""
Applies the mish function element-wise:
mish(x) = x * tanh(softplus(x)) = x * tanh(ln(1 + exp(sigmoid(x))))
See additional documentation for mish class.
"""
return input * torch.tanh(torch.log(1 + torch.sigmoid(input)))