Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
chenpangpang
transformers
Commits
edb17023
Unverified
Commit
edb17023
authored
Jan 15, 2024
by
amyeroberts
Committed by
GitHub
Jan 15, 2024
Browse files
SiLU activation wrapper for safe importing (#28509)
Add back in wrapper for safe importing
parent
ff86bc36
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
9 additions
and
0 deletions
+9
-0
src/transformers/activations.py
src/transformers/activations.py
+9
-0
No files found.
src/transformers/activations.py
View file @
edb17023
...
@@ -13,6 +13,7 @@
...
@@ -13,6 +13,7 @@
# limitations under the License.
# limitations under the License.
import
math
import
math
import
warnings
from
collections
import
OrderedDict
from
collections
import
OrderedDict
import
torch
import
torch
...
@@ -137,6 +138,14 @@ class AccurateGELUActivation(nn.Module):
...
@@ -137,6 +138,14 @@ class AccurateGELUActivation(nn.Module):
return
0.5
*
input
*
(
1
+
torch
.
tanh
(
self
.
precomputed_constant
*
(
input
+
0.044715
*
torch
.
pow
(
input
,
3
))))
return
0.5
*
input
*
(
1
+
torch
.
tanh
(
self
.
precomputed_constant
*
(
input
+
0.044715
*
torch
.
pow
(
input
,
3
))))
class
SiLUActivation
(
nn
.
SiLU
):
def
__init__
(
self
,
*
args
,
**
kwargs
):
warnings
.
warn
(
"The SiLUActivation class has been deprecated and will be removed in v4.39. Please use nn.SiLU instead."
,
)
super
().
__init__
(
*
args
,
**
kwargs
)
class
MishActivation
(
nn
.
Module
):
class
MishActivation
(
nn
.
Module
):
"""
"""
See Mish: A Self-Regularized Non-Monotonic Activation Function (Misra., https://arxiv.org/abs/1908.08681). Also
See Mish: A Self-Regularized Non-Monotonic Activation Function (Misra., https://arxiv.org/abs/1908.08681). Also
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment