Spaces:
Build error
Build error
Commit
·
cb3973b
1
Parent(s):
7c8fb33
Upload Swish.py
Browse files
Swish.py
ADDED
@@ -0,0 +1,18 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# Copyright 2020 Johns Hopkins University (Shinji Watanabe)
|
2 |
+
# Northwestern Polytechnical University (Pengcheng Guo)
|
3 |
+
# Apache 2.0 (http://www.apache.org/licenses/LICENSE-2.0)
|
4 |
+
# Adapted by Florian Lux 2021
|
5 |
+
|
6 |
+
import torch
|
7 |
+
|
8 |
+
|
9 |
+
class Swish(torch.nn.Module):
|
10 |
+
"""
|
11 |
+
Construct an Swish activation function for Conformer.
|
12 |
+
"""
|
13 |
+
|
14 |
+
def forward(self, x):
|
15 |
+
"""
|
16 |
+
Return Swish activation function.
|
17 |
+
"""
|
18 |
+
return x * torch.sigmoid(x)
|