ramon-oliveira/aorun

View on GitHub
aorun/activations.py

Summary

Maintainability
A
25 mins
Test Coverage
from torch.nn.functional import relu, softmax


def get(obj):
    if callable(obj):
        return obj
    elif type(obj) is str:
        if obj in globals():
            return globals()[obj]
        else:
            raise Exception(f'Unknown activation: {obj}')
    else:
        raise Exception('Activation must be a callable or str')