Class: Transformers::GELUActivation
- Inherits:
-
Torch::NN::Module
- Object
- Torch::NN::Module
- Transformers::GELUActivation
- Defined in:
- lib/transformers/activations.rb
Instance Method Summary collapse
- #_gelu_python(input) ⇒ Object
- #forward(input) ⇒ Object
-
#initialize(use_gelu_python: false) ⇒ GELUActivation
constructor
A new instance of GELUActivation.
Constructor Details
#initialize(use_gelu_python: false) ⇒ GELUActivation
Returns a new instance of GELUActivation.
17 18 19 20 21 22 23 24 |
# File 'lib/transformers/activations.rb', line 17 def initialize(use_gelu_python: false) super() if use_gelu_python @act = _gelu_python else @act = Torch::NN::Functional.method(:gelu) end end |
Instance Method Details
#_gelu_python(input) ⇒ Object
26 27 28 |
# File 'lib/transformers/activations.rb', line 26 def _gelu_python(input) input * 0.5 * (1.0 + Torch.erf(input / Math.sqrt(2.0))) end |
#forward(input) ⇒ Object
30 31 32 |
# File 'lib/transformers/activations.rb', line 30 def forward(input) @act.(input) end |