Class: Transformers::Mpnet::MPNetIntermediate

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

Instance Method Summary collapse

Constructor Details

#initialize(config) ⇒ MPNetIntermediate

Returns a new instance of MPNetIntermediate.



220
221
222
223
224
225
226
227
228
# File 'lib/transformers/models/mpnet/modeling_mpnet.rb', line 220

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



230
231
232
233
234
# File 'lib/transformers/models/mpnet/modeling_mpnet.rb', line 230

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