Class: Transformers::DebertaV2::DebertaV2Output

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

Instance Method Summary collapse

Constructor Details

#initialize(config) ⇒ DebertaV2Output

Returns a new instance of DebertaV2Output.



216
217
218
219
220
221
222
# File 'lib/transformers/models/deberta_v2/modeling_deberta_v2.rb', line 216

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 = StableDropout.new(config.hidden_dropout_prob)
  @config = config
end

Instance Method Details

#forward(hidden_states, input_tensor) ⇒ Object



224
225
226
227
228
229
# File 'lib/transformers/models/deberta_v2/modeling_deberta_v2.rb', line 224

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