def __init__(self, in_features, activation_fn="Sigmoid"): """@TODO: Docs. Contribution is welcome.""" super().__init__() activation_fn = REGISTRY.get_if_str(activation_fn) self.attn = nn.Sequential( nn.Conv2d(in_features, 1, kernel_size=1, stride=1, padding=0, bias=False), activation_fn(), )
def _activation_fn(activation_fn, f_in, f_out, **kwargs): activation_fn = REGISTRY.get_if_str(activation_fn) activation_fn = activation_fn( **kwargs) if activation_fn is not None else None return activation_fn
def _normalization_fn(normalization_fn, f_in, f_out, **kwargs): normalization_fn = REGISTRY.get_if_str(normalization_fn) normalization_fn = normalization_fn( f_out, **kwargs) if normalization_fn is not None else None return normalization_fn
def _dropout_fn(dropout_fn, f_in, f_out, **kwargs): dropout_fn = REGISTRY.get_if_str(dropout_fn) dropout_fn = dropout_fn(**kwargs) if dropout_fn is not None else None return dropout_fn
def _layer_fn(layer_fn, f_in, f_out, **kwargs): layer_fn = REGISTRY.get_if_str(layer_fn) layer_fn = layer_fn(f_in, f_out, **kwargs) return layer_fn