Bernstein_Poster_2024/basis_nnmf_x8/L1NormLayer.py
David Rotermund 12eb04e446 New Sims
2024-11-05 18:20:02 +01:00

13 lines
319 B
Python

import torch
class L1NormLayer(torch.nn.Module):
epsilon: float
def __init__(self, epsilon: float = 10e-20) -> None:
super().__init__()
self.epsilon = epsilon
def forward(self, input: torch.Tensor) -> torch.Tensor:
return input / (input.sum(dim=1, keepdim=True) + self.epsilon)