Class: Transformers::Bert::BertOutput
- Inherits:
-
Torch::NN::Module
- Object
- Torch::NN::Module
- Transformers::Bert::BertOutput
- Defined in:
- lib/transformers/models/bert/modeling_bert.rb
Instance Method Summary collapse
- #forward(hidden_states, input_tensor) ⇒ Object
-
#initialize(config) ⇒ BertOutput
constructor
A new instance of BertOutput.
Constructor Details
#initialize(config) ⇒ BertOutput
Returns a new instance of BertOutput.
274 275 276 277 278 279 |
# File 'lib/transformers/models/bert/modeling_bert.rb', line 274 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
281 282 283 284 285 286 |
# File 'lib/transformers/models/bert/modeling_bert.rb', line 281 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 |