File tree Expand file tree Collapse file tree 1 file changed +1
-15
lines changed Expand file tree Collapse file tree 1 file changed +1
-15
lines changed Original file line number Diff line number Diff line change 44
44
"vocab_size" : 50257
45
45
}
46
46
47
- import math
48
- from torch import Tensor
49
-
50
47
51
48
# from transformers
52
49
class Conv1D (nn .Module ):
@@ -74,23 +71,12 @@ def forward(self, x):
74
71
return x
75
72
76
73
77
- # from transformers
78
- class NewGELUActivation (nn .Module ):
79
- """
80
- Implementation of the GELU activation function currently in Google BERT repo (identical to OpenAI GPT). Also see
81
- the Gaussian Error Linear Units paper: https://arxiv.org/abs/1606.08415
82
- """
83
-
84
- def forward (self , input : Tensor ) -> Tensor :
85
- return 0.5 * input * (1.0 + torch .tanh (math .sqrt (2.0 / math .pi ) * (input + 0.044715 * torch .pow (input , 3.0 ))))
86
-
87
-
88
74
class HeadFFN (nn .Module ): # todo rename
89
75
def __init__ (self , dim ):
90
76
super ().__init__ ()
91
77
self .c_fc = Conv1D (dim , config ['n_embd' ])
92
78
self .c_proj = Conv1D (config ['n_embd' ], dim )
93
- self .act = NewGELUActivation ()
79
+ self .act = nn . functional . gelu
94
80
self .dropout = nn .Dropout (config ['resid_pdrop' ])
95
81
96
82
def forward (self , hidden_states ):
You can’t perform that action at this time.
0 commit comments