Class: Transformers::DebertaV2::DebertaV2Intermediate

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) ⇒ DebertaV2Intermediate

Returns a new instance of DebertaV2Intermediate.



198
199
200
201
202
203
204
205
206
# File 'lib/transformers/models/deberta_v2/modeling_deberta_v2.rb', line 198

def initialize(config)
  super()
  @dense = Torch::NN::Linear.new(config.hidden_size, config.intermediate_size)
  if config.hidden_act.is_a?(String)
    @intermediate_act_fn = ACT2FN[config.hidden_act]
  else
    @intermediate_act_fn = config.hidden_act
  end
end

Instance Method Details

#forward(hidden_states) ⇒ Object



208
209
210
211
212
# File 'lib/transformers/models/deberta_v2/modeling_deberta_v2.rb', line 208

def forward(hidden_states)
  hidden_states = @dense.(hidden_states)
  hidden_states = @intermediate_act_fn.(hidden_states)
  hidden_states
end