Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 10 additions & 7 deletions model_constructor/activations.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
import torch
from torch import nn as nn
from torch.nn import functional as F
from torch.nn import Mish


__all__ = ['mish', 'Mish', 'mish_jit', 'MishJit', 'mish_jit_fwd', 'mish_jit_bwd', 'MishJitAutoFn', 'mish_me', 'MishMe',
Expand All @@ -16,14 +17,16 @@ def mish(x, inplace: bool = False):
return x.mul(F.softplus(x).tanh())


class Mish(nn.Module):
"""Mish: A Self Regularized Non-Monotonic Neural Activation Function - https://arxiv.org/abs/1908.08681"""
def __init__(self, inplace: bool = False):
"""NOTE: inplace variant not working """
super(Mish, self).__init__()
# from torch v 1.9 Mish is in pytorch.

def forward(self, x):
return mish(x)
# class Mish(nn.Module):
# """Mish: A Self Regularized Non-Monotonic Neural Activation Function - https://arxiv.org/abs/1908.08681"""
# def __init__(self, inplace: bool = False):
# """NOTE: inplace variant not working """
# super(Mish, self).__init__()

# def forward(self, x):
# return mish(x)


@torch.jit.script
Expand Down
2 changes: 1 addition & 1 deletion model_constructor/yaresnet.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
from collections import OrderedDict
from .layers import SEBlock, ConvLayer, act_fn, noop, SimpleSelfAttention
from .net import Net
from .activations import Mish
from torch.nn import Mish


__all__ = ['YaResBlock', 'yaresnet_parameters', 'yaresnet34', 'yaresnet50']
Expand Down