Class: Transformers::Mpnet::MPNetIntermediate
- Inherits:
-
Torch::NN::Module
- Object
- Torch::NN::Module
- Transformers::Mpnet::MPNetIntermediate
- Defined in:
- lib/transformers/models/mpnet/modeling_mpnet.rb
Instance Method Summary collapse
- #forward(hidden_states) ⇒ Object
-
#initialize(config) ⇒ MPNetIntermediate
constructor
A new instance of MPNetIntermediate.
Constructor Details
#initialize(config) ⇒ MPNetIntermediate
Returns a new instance of MPNetIntermediate.
220 221 222 223 224 225 226 227 228 |
# File 'lib/transformers/models/mpnet/modeling_mpnet.rb', line 220 def initialize(config) super() @dense = Torch::NN::Linear.new(config.hidden_size, config.intermediate_size) if config.hidden_act.is_a?(String) @intermediate_act_fn = ACT2FN[config.hidden_act] else @intermediate_act_fn = config.hidden_act end end |
Instance Method Details
#forward(hidden_states) ⇒ Object
230 231 232 233 234 |
# File 'lib/transformers/models/mpnet/modeling_mpnet.rb', line 230 def forward(hidden_states) hidden_states = @dense.(hidden_states) hidden_states = @intermediate_act_fn.(hidden_states) hidden_states end |