Class: Transformers::XlmRoberta::XLMRobertaOutput
- Inherits:
-
Torch::NN::Module
- Object
- Torch::NN::Module
- Transformers::XlmRoberta::XLMRobertaOutput
- Defined in:
- lib/transformers/models/xlm_roberta/modeling_xlm_roberta.rb
Instance Method Summary collapse
- #forward(hidden_states, input_tensor) ⇒ Object
-
#initialize(config) ⇒ XLMRobertaOutput
constructor
A new instance of XLMRobertaOutput.
Constructor Details
#initialize(config) ⇒ XLMRobertaOutput
Returns a new instance of XLMRobertaOutput.
403 404 405 406 407 408 |
# File 'lib/transformers/models/xlm_roberta/modeling_xlm_roberta.rb', line 403 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
410 411 412 413 414 415 |
# File 'lib/transformers/models/xlm_roberta/modeling_xlm_roberta.rb', line 410 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 |