From b3532a4cb91409756631e1d23fe5a99aabe5b57a Mon Sep 17 00:00:00 2001 From: Gustaf Rydholm Date: Mon, 22 Nov 2021 22:39:11 +0100 Subject: Remove unused utils --- text_recognizer/networks/util.py | 29 ----------------------------- 1 file changed, 29 deletions(-) delete mode 100644 text_recognizer/networks/util.py (limited to 'text_recognizer/networks') diff --git a/text_recognizer/networks/util.py b/text_recognizer/networks/util.py deleted file mode 100644 index 6cf102f..0000000 --- a/text_recognizer/networks/util.py +++ /dev/null @@ -1,29 +0,0 @@ -"""Miscellaneous neural network utility functionality.""" -from functools import partial -from importlib import import_module -from typing import Any, Type - -from torch import nn - - -def activation_function(activation: str) -> Type[nn.Module]: - """Returns the callable activation function.""" - activation_fns = nn.ModuleDict( - [ - ["elu", nn.ELU(inplace=True)], - ["gelu", nn.GELU()], - ["glu", nn.GLU()], - ["leaky_relu", nn.LeakyReLU(negative_slope=1.0e-2, inplace=False)], - ["none", nn.Identity()], - ["relu", nn.ReLU(inplace=True)], - ["selu", nn.SELU(inplace=True)], - ["mish", nn.Mish(inplace=True)], - ] - ) - return activation_fns[activation.lower()] - - -def load_partial_fn(fn: str, **kwargs: Any) -> partial: - """Loads partial function/class.""" - module = import_module(".".join(fn.split(".")[:-1])) - return partial(getattr(module, fn.split(".")[-1]), **kwargs) -- cgit v1.2.3-70-g09d2