Last active
August 12, 2019 00:27
-
-
Save digantamisra98/eef3a1504c8c0a34b3957f58d91383d0 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
''' | |
Applies the mish function element-wise: | |
mish(x) = x * tanh(softplus(x)) = x * tanh(ln(1 + exp(x))) | |
''' | |
# import pytorch | |
from torch import nn | |
# import activation functions | |
import functional as Func | |
class Mish(nn.Module): | |
''' | |
Applies the mish function element-wise: | |
mish(x) = x * tanh(softplus(x)) = x * tanh(ln(1 + exp(x))) | |
Shape: | |
- Input: (N, *) where * means, any number of additional | |
dimensions | |
- Output: (N, *), same shape as the input | |
Examples: | |
>>> m = Mish() | |
>>> input = torch.randn(2) | |
>>> output = m(input) | |
''' | |
def __init__(self): | |
''' | |
Init method. | |
''' | |
super().__init__() | |
def forward(self, input): | |
''' | |
Forward pass of the function. | |
''' | |
return Func.mish(input) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment