Python torch.nn.Softshrink() Examples
The following are 2
code examples of torch.nn.Softshrink().
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example.
You may also want to check out all available functions/classes of the module
torch.nn
, or try the search function
.
Example #1
Source File: Base_Network.py From nn_builder with MIT License | 5 votes |
def create_str_to_activations_converter(self): """Creates a dictionary which converts strings to activations""" str_to_activations_converter = {"elu": nn.ELU(), "hardshrink": nn.Hardshrink(), "hardtanh": nn.Hardtanh(), "leakyrelu": nn.LeakyReLU(), "logsigmoid": nn.LogSigmoid(), "prelu": nn.PReLU(), "relu": nn.ReLU(), "relu6": nn.ReLU6(), "rrelu": nn.RReLU(), "selu": nn.SELU(), "sigmoid": nn.Sigmoid(), "softplus": nn.Softplus(), "logsoftmax": nn.LogSoftmax(), "softshrink": nn.Softshrink(), "softsign": nn.Softsign(), "tanh": nn.Tanh(), "tanhshrink": nn.Tanhshrink(), "softmin": nn.Softmin(), "softmax": nn.Softmax(dim=1), "none": None} return str_to_activations_converter
Example #2
Source File: activation.py From claf with MIT License | 5 votes |
def get_activation_fn(name): """ PyTorch built-in activation functions """ activation_functions = { "linear": lambda: lambda x: x, "relu": nn.ReLU, "relu6": nn.ReLU6, "elu": nn.ELU, "prelu": nn.PReLU, "leaky_relu": nn.LeakyReLU, "threshold": nn.Threshold, "hardtanh": nn.Hardtanh, "sigmoid": nn.Sigmoid, "tanh": nn.Tanh, "log_sigmoid": nn.LogSigmoid, "softplus": nn.Softplus, "softshrink": nn.Softshrink, "softsign": nn.Softsign, "tanhshrink": nn.Tanhshrink, } if name not in activation_functions: raise ValueError( f"'{name}' is not included in activation_functions. use below one. \n {activation_functions.keys()}" ) return activation_functions[name]