diff options
-rw-r--r-- | text_recognizer/network/transformer/swiglu.py | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/text_recognizer/network/transformer/swiglu.py b/text_recognizer/network/transformer/swiglu.py new file mode 100644 index 0000000..e61662a --- /dev/null +++ b/text_recognizer/network/transformer/swiglu.py @@ -0,0 +1,8 @@ +from torch import nn +import torch.nn.functional as F + + +class SwiGLU(nn.Module): + def forward(self, x): + x, gate = x.chunk(2, dim=-1) + return F.silu(gate) * x |