Class: Transformers::XlmRoberta::XLMRobertaSelfOutput

Inherits:
Torch::NN::Module
  • Object
show all
Defined in:
lib/transformers/models/xlm_roberta/modeling_xlm_roberta.rb

Instance Method Summary collapse

Constructor Details

#initialize(config) ⇒ XLMRobertaSelfOutput

Returns a new instance of XLMRobertaSelfOutput.



325
326
327
328
329
330
# File 'lib/transformers/models/xlm_roberta/modeling_xlm_roberta.rb', line 325

def initialize(config)
  super()
  @dense = Torch::NN::Linear.new(config.hidden_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



332
333
334
335
336
337
# File 'lib/transformers/models/xlm_roberta/modeling_xlm_roberta.rb', line 332

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