Python torch.nn.Hardshrink() Examples
The following are 2
code examples of torch.nn.Hardshrink().
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: memory_module.py From memae-anomaly-detection with MIT License | 5 votes |
def __init__(self, mem_dim, fea_dim, shrink_thres=0.0025): super(MemoryUnit, self).__init__() self.mem_dim = mem_dim self.fea_dim = fea_dim self.weight = Parameter(torch.Tensor(self.mem_dim, self.fea_dim)) # M x C self.bias = None self.shrink_thres= shrink_thres # self.hard_sparse_shrink_opt = nn.Hardshrink(lambd=shrink_thres) self.reset_parameters()