We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
2 parents 1ef598a + 1e5b2b2 commit 6c61abcCopy full SHA for 6c61abc
DeepFried2/layers/GELU.py
@@ -0,0 +1,9 @@
1
+import DeepFried2 as df
2
+
3
+class GELU(df.Module):
4
+ """ Gaussian Error Linear Unit (https://arxiv.org/abs/1606.08415) """
5
6
+ def symb_forward(self, x):
7
+ """ A very close, much more efficient approximation. """
8
+ return 0.5 * x * (1 + df.T.tanh(0.79788456 * (x + 0.044715 * x*x*x)))
9
DeepFried2/layers/__init__.py
@@ -3,6 +3,7 @@
from .Bias import Bias
from .Dropout import Dropout
from .Embedding import Embedding
+from .GELU import GELU
from .Identity import Identity
from .Linear import Linear
from .Log import Log
0 commit comments