Class: Transformers::Mpnet::MPNetOutput
- Inherits:
-
Torch::NN::Module
- Object
- Torch::NN::Module
- Transformers::Mpnet::MPNetOutput
- Defined in:
- lib/transformers/models/mpnet/modeling_mpnet.rb
Instance Method Summary collapse
- #forward(hidden_states, input_tensor) ⇒ Object
-
#initialize(config) ⇒ MPNetOutput
constructor
A new instance of MPNetOutput.
Constructor Details
#initialize(config) ⇒ MPNetOutput
Returns a new instance of MPNetOutput.
238 239 240 241 242 243 |
# File 'lib/transformers/models/mpnet/modeling_mpnet.rb', line 238 def initialize(config) super() @dense = Torch::NN::Linear.new(config.intermediate_size, config.hidden_size) @LayerNorm = Torch::NN::LayerNorm.new(config.hidden_size, eps: config.layer_norm_eps) @dropout = Torch::NN::Dropout.new(p: config.hidden_dropout_prob) end |
Instance Method Details
#forward(hidden_states, input_tensor) ⇒ Object
245 246 247 248 249 250 |
# File 'lib/transformers/models/mpnet/modeling_mpnet.rb', line 245 def forward(hidden_states, input_tensor) hidden_states = @dense.(hidden_states) hidden_states = @dropout.(hidden_states) hidden_states = @LayerNorm.(hidden_states + input_tensor) hidden_states end |