Пример #1
0
 def forward(self, data: torch.Tensor) -> torch.Tensor:
     return torch.mul(data, torch.sigmoid(data))
Пример #2
0
def test_swish():
    layer = Swish()
    input_tensor = torch.Tensor([[1, 2, 3], [4, 5, 6]])
    target_tensor = torch.mul(input_tensor, torch.sigmoid(input_tensor))
    assert torch.all(torch.eq(layer(input_tensor), target_tensor))