tom:

class LearnedSoftPlus(torch.nn.Module): def init(self, init_beta=1.0, threshold=20): # keep beta > 0 self.log_beta = torch.nn.Parameter(torch.tensor(float(init_beta)).log()) self.threshold = 20 def forward(self, x): beta = self.log_beta.exp() beta_x = beta * x return torch.where(beta_x < 20, torch.log1p(beta_x.exp()) / beta, x)


Thank you. I have checked it and it seems to work correctly (just missed the super().init() line.)